ml-mutant-srv

module
v0.0.0-...-ef3eba0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2018 License: GPL-3.0

README

Mutant solution with Go-Micro Go Report Card Build Status

This repo contains an examples solution for serving microservices via the micro api. We use the following technologies:

Go Micro

Go Micro is a pluggable RPC framework for distributed systems development.

The micro philosophy is sane defaults with a pluggable architecture. It provides defaults to get you started quickly but everything can be easily swapped out. It comes with built in support for {json,proto}-rpc encoding, consul or multicast dns for service discovery, http for communication and random hashed client side load balancing.

Consul

Consul is a service mesh solution providing a full featured control plane with service discovery, configuration, and segmentation functionality. Each of these features can be used individually as needed, or they can be used together to build a full service mesh. Consul requires a data plane and supports both a proxy and native integration model. Consul ships with a simple built-in proxy so that everything works out of the box, but also supports 3rd party proxy integrations such as Envoy.

Micro API

The micro api is an API gateway which serves HTTP and routes to RPC based services. In the micro ecosystem we logically separate concerns via architecture and tooling. Read more on buiding an API layer of services in the architecture blog post.

ElasticSearch

Elasticsearch is a distributed, RESTful search and analytics engine capable of solving a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data so you can discover the expected and uncover the unexpected.

Service Architecture

Project Overview

The technologies used are the followings:

  • GoLang: Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
  • Go Dep: Golang dependency manager.
  • Protobuf: This is protobuf code generation for micro, to use Google's data interchange format.

Project code structure:

doc/            Some documentation resources

srv/            ml-mutant micreoservices
  gateway
  mutant
  stats

deploy/          Deployment instruction and resources

verndor/         Dependency folder created by dep

Getting Started

Let's start setting up our workspace doing the following:

Then get the repository using go get:

go get github.com/rodrigodmd/ml-mutant-srv

Resolve Dependencies with dep:

cd $GOPATH/src/github.com/rodrigodmd/ml-mutant-srv
dep ensure

To run all the services locally we can use docker compose.

docker-compose up

Local endpoints:

http://localhost:8080/api/mutant
http://localhost:8080/api/stats

Try with curl

Mutant DNA:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{ "dna": ["ATGCAA","CAGTTT","TTATTT","AGAAGG","CCACTA","TCACTG"] }}' \
	http://localhost:8080/api/mutant

Human DNA:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{ "dna": ["ATGC", "CAGT", "TATT", "AGAA"] }}' \
	http://localhost:8080/api/mutant

Invalid DNA structure:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{ "dna": ["ATGCAA","invalid","TTATTT","AGAAGG","CCACTA","TCACTG"] }}' \
	http://localhost:8080/api/mutant

Get stats:

curl --header "Content-Type: application/json" \
  --request GET \
	http://localhost:8080/api/stats

Try with go micro web

You can also play with the go micro development web: http://localhost:8082

Web 1 Web 2

Congratulations! Now you are ready to work in each micro service:

Build and push base docker image:

make docker-push

Deploymeny

Go to deployment section.

Directories

Path Synopsis
srv
mutant/proto/mutant
Package go_micro_srv_mutant is a generated protocol buffer package.
Package go_micro_srv_mutant is a generated protocol buffer package.
stats/proto/elastic
Package go_micro_srv_elastic is a generated protocol buffer package.
Package go_micro_srv_elastic is a generated protocol buffer package.
stats/proto/stats
Package go_micro_srv_stats is a generated protocol buffer package.
Package go_micro_srv_stats is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL