Giter Club home page Giter Club logo

pip-templates-microservice-dotnet's Introduction

Pip Sample Beacons Application

A simple Pip Sample Beacons Application that serves two purposes:

  • It can be used as the template when creating new projects
  • It is a reference for building and publishing custom microservices

The microservice contains list of beacons where each becaon have basic information and absolute location.

The microservice currently supports the following deployment options:

  • Deployment platforms: Standalone Process, Docker
  • External APIs: HTTP/REST
  • Persistence: Memory, Flat Files, MongoDB
  • Logging, Maintaining

Quick Links:

Microservice Interface

Logical contract of the microservice is presented below and define in Interface project. For physical implementation (HTTP/REST, Lambda, etc.), please, refer to documentation of the specific protocol.

    public class BeaconV1 : IStringIdentifiable
    {
        public string Id { get; set; }
        public string SiteId { get; set; }
        public string Type { get; set; }
        public string Udi { get; set; }
        public string Label { get; set; }
        public CenterObjectV1 Center { get; set; }
        public double Radius { get; set; }
    }
    
    public class CenterObjectV1
    {
        public string Type { get; set; }
        public double[] Coordinates { get; set; }
    }
    
    public interface IBeaconsClientV1
    {
        Task<DataPage<BeaconV1>> GetBeaconsAsync(string correlationId, FilterParams filter, PagingParams paging);
        Task<BeaconV1> GetBeaconByIdAsync(string correlationId, string id);
        Task<BeaconV1> GetBeaconByUdiAsync(string correlationId, string udi);
        Task<CenterObjectV1> CalculatePositionAsync(string correlationId, string siteId, string[] udis);
        Task<BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon);
        Task<BeaconV1> UpdateBeaconAsync(string correlationId, BeaconV1 beacon);
        Task<BeaconV1> DeleteBeaconByIdAsync(string correlationId, string id);
    }

Run from Docker

Step 1. Install Docker Desctop

Step 2. Execute following command to download Docker image with predefined microservice and run

git docker run pip-templates-microservice-dotnet

More information about how to configure microservice and run in docker container can be found in Deployment Guide

Run from source code

Prerequisite:

Step 1. Check it out latest source code directly from github repository

git clone [email protected]:pip-templates/pip-templates-microservice-dotnet.git

Step 2. Compile source code

dotnet build ./pip-samples-beacons.sln

Step 3 Run compuled binaries

cd ./src
dotnet ./Process/bin/Debug/netcoreapp2.1/run.dll

Use

Add beacons

curl --header "Content-Type: application/json" --request POST --data "{\"correlationId\":\"d42fd72c-02d2-4944-8631-4d94bc5fd75f\",\"beacon\":{\"id\":\"1\", \"site_id\":\"Site1\", \"type\":\"tracker\",\"udi\":\"12345\", \"label\":\"basic tracker\", \"radius\":4.0, \"center\": {\"type\": \"absolute\", \"coordinates\": [123.0,456.0,789.0]}}}" http://localhost:8080/v1/beacons/create_beacon

curl --header "Content-Type: application/json" --request POST --data "{\"correlationId\":\"d42fd72c-02d2-4944-8631-4d94bc5fd75f\",\"beacon\":{\"id\":\"2\", \"site_id\":\"Site2\", \"type\":\"tracker\",\"udi\":\"12345\", \"label\":\"basic tracker\", \"radius\":4.0, \"center\": {\"type\": \"absolute\", \"coordinates\": [123.0,456.0,789.0]}}}" http://localhost:8080/v1/beacons/create_beacon

Get all beacons

curl --header "Content-Type: application/json" --data "{\"correlationId\":\"d42fd72c-02d2-4944-8631-4d94bc5fd75f\",\"filter\":null,\"paging\":null}" --request POST localhost:8080/v1/beacons/get_beacons

Update beacon

curl --header "Content-Type: application/json" --request POST --data "{\"correlationId\":\"d42fd72c-02d2-4944-8631-4d94bc5fd75f\",\"beacon\":{\"id\":\"2\", \"site_id\":\"New Site2\", \"type\":\"tracker\",\"udi\":\"12345\", \"label\":\"basic tracker\", \"radius\":4.0, \"center\": {\"type\": \"absolute\", \"coordinates\": [123.0,456.0,789.0]}}}" http://localhost:8080/v1/beacons/update_beacon

Get beacon

curl --header "Content-Type: application/json" --data "{\"correlationId\":\"d42fd72c-02d2-4944-8631-4d94bc5fd75f\",\"beacon_id\":\"2\"}" --request POST localhost:8080/v1/beacons/get_beacon_by_id

Delete beacon

curl --header "Content-Type: application/json" --data "{\"correlationId\":\"d42fd72c-02d2-4944-8631-4d94bc5fd75f\",\"beacon_id\":\"2\"}" --request POST localhost:8080/v1/beacons/delete_beacon_by_id

Acknowledgements

This microservice was created and currently maintained by Sergey Seroukhov, Sergey Merkuriev, Egor Nuzhnykh.

pip-templates-microservice-dotnet's People

Contributors

mrumka avatar dvoikin avatar egornuzhnykh avatar alexander-mazur avatar seroukhov avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.