Giter VIP home page Giter VIP logo

mortar-demo's Introduction

Mortar Demo

There are 2 services in this repository, clone it and follow the instructions on how to run it below.

Running the demo

Docker

Before you run either Workshop/Sub Workshop services it is advised to run docker-compose first.

Open a shell, change directory to mortar-demo/docker now run the following

docker-compose up

This should bring up the following services

Workshop/Sub Workshop

  • Workshop

    Open a shell, change your directory to mortar-demo/workshop and run the following

    make run
  • Sub Workshop

    Open a shell, change your directory to mortar-demo/subworkshop and run the following

    make run

Now you should have Workshop and Sub Workshop services running. It's time to execute different HTTP calls.

HTTP Calls to Workshop service http://localhost:5381/v1/workshop

  • Register a new car

    curl -X "POST" "http://localhost:5381/v1/workshop/cars" \
      -H 'Content-Type: application/json; charset=utf-8' \
      -d $'{
    "number": "ABCD4248",
    "owner": "Mr. Smith",
    "body_style": "SEDAN",
    "color": "red"
    }'
  • Paint ABCD4248 Car

    curl -X "PUT" "http://localhost:5381/v1/workshop/cars/ABCD4248/paint" \
         -H 'Content-Type: application/json; charset=utf-8' \
         -d $'{
      "desired_color": "green"
    }'

So what's there to see...

  • You can see the logs of each service [Workshop/Sub Workshop] in their respective shells.

    A lot of implicit information injected to the log entry [error, git-hash, trace-info, app, host]

    w.deps.Logger.WithError(err).Debug(ctx, "sending car to be painted") // Line 56

    logs

  • Jaeger can show you all the requests you've made including how they traveled if any to a remote services.

    jaeger

  • Prometheus/Grafana can be used to visualise different metrics that are recorded implicitly or explicitly.

    counter := w.deps.Metrics.WithTags(monitor.Tags{
            "color": request.GetDesiredColor(),
            "success" : fmt.Sprintf("%t", err == nil),
           }).Counter("paint_desired_color", "New paint color for car")
    
    counter.Inc()

    grafana

Services

Workshop is used as a "front" to accept cars, requests for paint, etc.

There is one special request which is actually a proxy to Sub Workshop service. In this case we are calling Sub Workshop using *http.Client a.k.a REST. This request really shows how different middleware/interceptors help you achieve great visibility.

  • Open-Tracing is used to report how request is traveling between different services
  • Logs implicitly inject Trace information, so you can later aggregate all the logs from different services related to a particular request.
  • Metrics used to count different application insights (What 'color' is most popular)

All this is achieved mostly implicitly by using multiple middleware/interceptors.

Sub Workshop is here to serve as a remote service call.

This service only accepts one request - SubPaintCarRequest.

rpc PaintCar(SubPaintCarRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v1/subworkshop/paint"
      body: "*"
    };
}

As part of its logic it will callback our Workshop service using gRPC.

This will complete our request cycle. You can see the entire Trace using Jaeger UI.

mortar-demo's People

Contributors

talgendler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.