Giter Site home page Giter Site logo

micro-serv's Introduction

Micro-serv - mock of microservice

A tiny golang application simulating a microservice. It

  • listens for inbound connections
  • connects to other named microservices specified on the command line
  • sends messages containing a sequence number
  • logs sent and received messages
  • attempts to reconnect on failure

Build

Using Go natively

make micro-serv

Usage

Usage of ./micro-serv:
  -a string
        listening address
  -i duration
        message sending interval (default 2s)
  -l    listen
  -r duration
        connection retry interval (default 1s)
  -t duration
        connect/send/recv timeout (default 5s)

Example

The following example will start micro-serv in listen mode, and attempt to connect to a different instance of micro-serv, on host "test-host".

./micro-serv -l test-host

Micro-Serv on Docker Compose and Weave Cloud

Micro-Serv is a small application that simulates a microservice. It listens for connections and initiates connection to other services specified as a parameter on the command line, and exchanges messages with those services. It is ideal for building a quick topology of services that talk to each other.

The instructions on this page will allow you to get started with a Docker Compose setup that uses multiple micro-serv containers to build a topology simulating different layouts of app services for deployment. The advantage is that that the required download is only 5 MB and the whole setup starts very fast.

Pre-requisites

git clone https://github.com/micro-serv/micro-serv
cd micro-serv

Launch Weave Scope

Get a token by registering on Weave Cloud. Once you have the token you can download and start the Scope instance.

sudo curl -L git.io/scope -o /usr/local/bin/scope
sudo chmod a+x /usr/local/bin/scope
scope launch --service-token=<token>

Open https://cloud.weave.works/app/, login and see your services running.

Prepare docker-compose.yaml configuration file

minimal compose for a simulation of https://github.com/weaveworks/weaveDemo:

version: '2'

services:
  load_balancer:
    image: euknyaz/micro-serv
    container_name: load_balancer
    command: frontend
    ports:
      - '80:80'
      - '8080:8080'
    networks:
      - frontend
  frontend:
    image: euknyaz/micro-serv
    command: -l backend
    networks:
      - frontend
      - backend
  backend:
    image: euknyaz/micro-serv
    command: -l mongo_db redis_cache rabbitmq_queue
    networks:
      - backend
      - storage
  mongo_db:
    image: euknyaz/micro-serv
    container_name: mongo_db 
    command: -l
    networks:
      - storage
  redis_cache:
    image: euknyaz/micro-serv
    container_name: redis_cache
    command: -l
    networks:
      - storage
  rabbitmq_queue:
    image: euknyaz/micro-serv
    container_name: rabbitmq_queue
    command: -l processor_worker
    networks:
      - storage
      - processor
  processor_worker:
    image: euknyaz/micro-serv
    command: -l data-db
    networks:
      - processor
      - storage
networks:
  frontend:
  backend:
  processor:
  storage:

Provision infrastructure

docker-compose -f docker-compose.yaml up -d

Scale infrastructure

docker-compose -f docker-compose.yaml scale frontend=2 backend=2 processor_worker=3

Check Weave Cloud

Once you started the application using Docker Compose, you can visit Weave Cloud to see how the containers are connected to each other. You should be seeing something like this:

Micro-Serv  in Scope

Cleaning up

docker-compose -f docker-compose.yaml down

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.