In this tutorial, we’ll be writing from scratch a fully-functional Data microservice, using the patterns and mechanisms available in the Pip.Services toolkit, as well as the programming language you have selected. The microservice that we are going to be using as an example in this tutorial is called [The Beacons microservice], which is part of [The IoT Microservices Collection]. This microservice is meant to perform the following simple tasks:
- Store a list of BLE beacons (a.k.a. iBeacons), their unique identifiers, and the positions at which they were installed.
- Calculate the position of a device, using the beacons it “sees” in its vicinity.
Imagine the following situation: you are walking through a building that has beacons installed at various locations throughout the entire building. These beacons are broadcasting signals via bluetooth, at regular time intervals, which can be “seen” from about 200 feet away. The beacons, along with their positions, are stored in our microservice. When your smartphone starts “seeing” some of these signals, it sends a list of the beacons it “sees” to the microservice, which then calculates the position of your phone as being in the middle of the beacons it “sees”. Simple, but effective - wouldn’t you agree?
The Beacons microservice that we are going to be developing will consist of a number of loosely-coupled components, following the componentized microservice design. The structure of this microservice is displayed on the diagram below:
To make it easier to follow along, we’ve divided the tutorial into the following 7 steps:
- Step 1. Setting up the project
- Step 2. Data model development
- Step 3. Implementing persistence components (with tests)
- Step 4. Implementing a controller (with tests)
- Step 5. Implementing an HTTP service (with tests)
- Step 6. Wrapping microservice into container
- Step 7. Running and testing the microservice