MoonkiHong / protocol-ezmq-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ezmq library (go)

protocol-ezmq-go is a go package which provides a standard messaging interface over various data streaming and serialization / deserialization middlewares along with some added functionalities.

  • Currently supports streaming using 0mq and serialization / deserialization using protobuf.
  • Publisher -> Multiple Subscribers broadcasting.
  • Topic based subscription and data routing at source (read publisher).
  • High speed serialization and deserialization.

Prerequisites

  • You must install basic prerequisites for build

    • Make sure that libtool, pkg-config, build-essential, autoconf, and automake are installed.
      $ sudo apt-get install libtool pkg-config build-essential autoconf automake
      
  • Python

  • SCons

  • Go compiler

  • You must install libsodium: [It is required for secured mode]

    $ sudo apt-get install libsodium-dev 
    

How to build

  1. Goto: ~/protocol-ezmq-go/
  2. Run the script:
    ./build_auto.sh <options>
    

Notes:
(a) For getting help about script option: $ ./build_auto.sh --help
(b) Currently, Script needs sudo permission for installing zeroMQ and protobuf libraries. In future need for sudo will be removed by installing those libraries in ezmq library. (c) While doing cross compilation, permission denied error may come.
For example: The below error while building for armhf:
go install runtime/internal/sys: mkdir /usr/local/go/pkg/linux_arm: permission denied
Do the following:
- sudo mkdir /usr/local/go/pkg/linux_arm/
- sudo chmod 777 /usr/local/go/pkg/linux_arm/

How to run ezmq samples

Prerequisites

Built ezmq library

Subscriber sample [Secured]

  1. Goto: ~/${GOPATH}/src/go/samples/
  2. Run the sample:
     ./subscriber_secured
    
    • It will give list of options for running the sample.
    • Update ip, port and topic as per requirement.
    • With secured sample unsecured features can be tested

Publisher sample [Secured]

  1. Goto: ~/${GOPATH}/src/go/samples/
  2. Run the sample:
    ./publisher_secured
    
    • It will give list of options for running the sample.
    • Update port and topic as per requirement.
    • With secured sample unsecured features can be tested

Subscriber sample

  1. Goto: ~/${GOPATH}/src/go/samples/
  2. Run the sample:
     ./subscriber
    
    • It will give list of options for running the sample.
    • Update ip, port and topic as per requirement.
    • This sample will be built, only if ezmq package is built in unsecured mode.

Publisher sample

  1. Goto: ~/${GOPATH}/src/go/samples/
  2. Run the sample:
    ./publisher
    
    • It will give list of options for running the sample.
    • Update port and topic as per requirement.
    • This sample will be built, only if ezmq package is built in unsecured mode.

Unit test and code coverage report

Pre-requisite

Built ezmq package.

Run the unit test cases

  1. Goto: ~/protocol-ezmq-go/src/go/unittests
  2. Run the script
    $ build.sh

Generate the code coverage report

  1. Goto ~/protocol-ezmq-go/src/go/unittests
  2. Run the script
    $ build.sh
  3. Run the below command to open coverage report in web browser:
    $ go tool cover -html=coverage.out

Usage guide for ezmq library (For micro-services)

  1. The microservice which wants to use ezmq GO library has to import ezmq package: import go/ezmq
  2. Reference ezmq library APIs : doc/godoc/ezmq.html

Running static analyzer for ezmq library

  1. Goto: ~/${GOPATH}/src/go/
  2. Run the below command:
    $ go tool vet -all .
    

Future Work

  • High speed parallel ordered serialization / deserialization based on streaming load.
  • Threadpool for multi-subscriber handling.
  • Router pattern. For number of subscribers to single publisher use case.
  • Clustering Support.

About


Languages

Language:Go 80.5%Language:Shell 19.5%