Git Product home page Git Product logo

ctxms's Introduction

Contextual Microservices

Example code for the blog post "Contexts in Go Microservice Chains"

Running the Experiment

After cloning the repository, open 6 different terminals for each of the services and a seventh to run the client code. Map each of the following commands to one of the server terminals:

$ go run ./cmd/ctxms serve -n alpha -p 9000 -d 10s
$ go run ./cmd/ctxms serve -n bravo -p 9001 -d 3s
$ go run ./cmd/ctxms serve -n charlie -p 9002 -d 7s
$ go run ./cmd/ctxms serve -n delta -p 9003 -d 5s
$ go run ./cmd/ctxms serve -n echo -p 9004 -d 8s
$ go run ./cmd/ctxms serve -n foxtrot -p 9005 -d 4s -t

Note that it is very important to start at port 9000 and to increment the port numbers by 1. Also, note the unique names and the -t flag on the last server - this ensures the service forms a ring where one microservice will pass a message to the next one in a circle. The -d flag specifies the maximum amount of a random delay for "hard work".

You can then run a client command as follows:

$ go run ./cmd/ctxms trace -e localhost:9003 -t 12s

This will run a trace to the "delta" server with a timeout of 12 seconds. Experiment with different timeouts to see the context deadline exceeding at different servers.

ctxms's People

Contributors

bbengfort avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.