Skip to content

tomasbasham/blunderlist-todo

Repository files navigation

blunderlist-todo Build Status 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 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; where my take on the subject can be seen on my blog.

Prerequisites

You will need the following things properly installed on your computer.

Installation

  • git clone <repository-url> this repository
  • cd blunderlist-todo
  • docker build -t todo .

Running / Development

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.

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

About

Contrived todo app example todo service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors