I want you to solve the problem with us, which is described in this post in our blog. We need a database in order to store the tracks of drivers. At the same time, you need to store several tracks for each driver
type (
Location struct {
Latitude float64 `json:"lat"`
Longitude float64 `json:"lon"`
}
Payload struct {
Timestamp int64 `json:"timestamp"`
DriverID int `json:"driver_id"`
Location Location `json:"location"`
}
)
- Data should be added without duplication.
- Need to store the last N points for each driver
Adding data will be via HTTP API
- Add the data to the storage
- Get information on the driver
- Get the nearest drivers by location
We will solve the problem evolutionarily. In the process of implementation, we will start with simple and primitive solutions that are not always effective in speed, but we will introduce certain primitives during the course, explaining them. The process will be something like this:
- We solve the problem by a simple and blunt method
- We think how it can be optimized
- We study a new data structure and understand it
- We are designing a solution with a new structure
- Doing it
- Writing tests
The project needs to clone the project for yourself.
cd $GOPATH
mkdir -p src/github.com/maddevsio
cd src/github.com/maddevsio
git clone [email protected]:maddevsio/gocodelabru.git
cd gocodelab
Codelab is divided into several steps. Each subsequent step can contain an example of what you should get after the previous one. These are kind of checkpoints to check if everything is done correctly or not.
We have learned what task we will solve and how to solve it. Let's start the task in the next step