https://github.com/tomasbasham/blunderlist-todo
Contrived todo app example todo service
https://github.com/tomasbasham/blunderlist-todo
Last synced: 4 months ago
JSON representation
Contrived todo app example todo service
- Host: GitHub
- URL: https://github.com/tomasbasham/blunderlist-todo
- Owner: tomasbasham
- Created: 2019-02-14T20:19:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-11T16:21:54.000Z (over 6 years ago)
- Last Synced: 2025-02-22T00:28:04.784Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# blunderlist-todo [](https://travis-ci.com/tomasbasham/blunderlist-todo) [](https://codeclimate.com/github/tomasbasham/blunderlist-todo/maintainability)
A fictitious todo application through which to teach how to implement a
microservice architecture. For the full list of services required to run this
application visit
[Blunderlist](https://github.com/tomasbasham?utf8=✓&tab=repositories&q=blunderlist)
on GitHub.
This repository implements an API that manages tasks and their creation,
providing an isolated data abstraction from other components of the overall
system. Data from this service may be further decorated with data obtained from
other services in some downstream closer to the client.
The intent of this repository is to provide the most optimal API surface for
the domain with which it is concerned, issuing unique resource handles that may
be referred to in other services.
The code here attempts to follow the principles of [Domain Driven
Design](https://www.google.com/search?q=domain-driven+design); where my take on
the subject can be seen on [my
blog](https://tomasbasham.dev/development/2019/10/26/domain-driven-design-in-practice).
## Prerequisites
You will need the following things properly installed on your computer.
* [Git](https://git-scm.com/)
* [Go](https://golang.org/)
* [Docker](https://www.docker.com/)
## Installation
* `git clone ` this repository
* `cd blunderlist-todo`
* `docker build -t todo .`
## Running / Development
* `docker run --rm -it -p 8080:8080 --env-file .env todo`
* Visit your app at [http://localhost:8080](http://localhost:8080).
### Rebuilding Protobuf Definitions
When changes to the API surface are made it is necessary to update the
generated protobuf definitions and any code that uses them. A docker image with
the `protoc` compiler has been made to make this far simpler.
* `docker run --rm -v $(pwd):/usr/src/app tomasbasham/protoc:3.6.1-go -I ./proto --go_out=plugins=grpc:. todo.proto`
## Creating a Client
This repository includes generated protobuf files that may be used in consuming
applications to establish a connection to this service. For convenience a
client package is provided to perform any per-request setup in addition to
initialising any gRPC dial options.
```go
import (
"context"
"fmt"
todopb "github.com/tomasbasham/blunderlist-todo/blunderlist_todo_v1"
"github.com/tomasbasham/blunderlist-todo/grpc"
)
func main() {
client, err := grpc.NewClientWithTarget(context.Background(), "1.2.3.4:50051")
if err != nil {
panic("unable to create client. terminating.")
}
query := &todopb.TaskQuery{
Id: 1,
}
task, err := client.GetTask(context.Background(), query)
if err != nil {
panic("unable to get task. terminating.")
}
fmt.Println(task)
}
```
## Further Reading / Useful Links
* [Go](https://golang.org/)
* [gRPC](https://grpc.io/)
* [protobuf](https://developers.google.com/protocol-buffers/)