Giter Site home page Giter Site logo

bpulse-go-client's Introduction

What is this?

This is a Go client for BPulse monitoring tool.

Use it!

To use it, the next environment variables must be set:

  • GO_COMMON_LIB_CONFIGURATION_FILE This variable is set to the path of the configurtion file BPulseGoClient.ini
  • GO_COMMON_LIB_EVENTS_FILE This variable is set to the path of the configuration file EventsConfiguration.json

In addition, the steps to integrate this BPulse client in your project is:

  • Define your pulse in BPulse:
    • Its typeId
    • Its attributes list
  • Integrating Go BPulse client in your project:
    • Add the BPulse client libraries to your Godeps (or another libraries manager you use)

      # BPulse
      github.com/pineda89/bpulse-go-client # Go client for BPulse 
      github.com/pineda89/bpulse-protobuf-go # MDH protobuf messages
    • Implement the necessary interfaces:

      • rq maker: com.bpulse.client.go.bpulseclient/bpulsegoclient/lib_pulses_sender.PulseRQMaker
      • rs instance builder: com.bpulse.client.go.bpulseclient/bpulsegoclient/lib_send_channel_adapter.PulseRSInstanceGetter
      • rs processor (optional): com.bpulse.client.go.bpulseclient/bpulsegoclient/lib_pulses_sender.PulseRSProcessor
    • Start the bpulse client:

         if err := bpulsegoclient.StartBPulseClient(rq_maker, rs_processor,rs_instance_getter); err!=nil {
           panic(err)
         }
    • Send pulses:

      /**
                * There are several way to use the aggregators:
                *
                * 1.- The first option is taking an aggregator once, and to use it for all of the application.
                *     In this case, we'll use always the same aggregator. By this way, we'll have only a unique block of pulse to send.
                *     It is necessary to keep in mind that the input channel of the aggregator is buffered to the Pulse RQ block size.
                *     Therefore, if we think there will be more concurrent pulse than the block size, this option is not a good idea
                *     unless we expand the size of the pulse RQ size.
                *
                * 2.- Another option is to take an aggregator from the pool every time we need it. In this case, we must to understand
                *     that each aggregator has its own slice of pulses, and that, until it not have as many pulses as RQ size,
                *     the aggregator does not put all of them into a PulseRQ to send it.
                */
      
                // Take the pulses aggregator from the aggregator's container.
                if aggregator, err := AGG_CONTAINER.Container.GetPulseAggregator(AGG_CONTENT.DEFAULT_AGGREGATOR_NAME); err!=nil {
                    panic(err)
                }else {
      
                    // Take the aggregator channel
                    if ch, err := aggregator.GetPulsesAggregationChannel(); err!=nil {
                        panic(err)
                    }else {
      
                        // Send the pulse
                        ch <- pulse
      
                        // Restore the aggregator to the aggregator's container
                        AGG_CONTAINER.Container.ReleasePulseAggregator(AGG_CONTENT.DEFAULT_AGGREGATOR_NAME, aggregator)
                    }
                }
    • Shutdown the client:

      errors_list := bpulsegoclient.ShutdownBPulseClient()
      for e:=errors_list.Front();e!=nil;e=e.Next(){
          fmt.Println(e.Value.(error).Error())
      }

#Example There is an example of use at bpulse-go-client/com.bpulse.client.go.bpulseclient/bpulsegoclient/example To execute this example:

  • Clone the project and go to its root directory:

    git clone https://github.com/pineda89/bpulse-go-client.git
    cd bpulse-go-client
  • Set the correct values in the configuration file bpulse-go-client/conf/BPulseGoClient.ini : RESTFUL_SEND_CHANNEL_ADAPTER_HOST BPulse host name. RESTFUL_SEND_CHANNEL_ADAPTER_URL_PORT BPulse host port. RESTFUL_SEND_CHANNEL_ADAPTER_USER BPulse user login. RESTFUL_SEND_CHANNEL_ADAPTER_URL_PWD BPulse user password.

  • Execute the example:

    cd bpulse-go-client/com.bpulse.client.go.bpulseclient/bpulsegoclient/example
    go build ("go build -tags debug" if we want debug traces) 
    source ./set_env.sh
    ./example

Start as a Docker container

The example also can be started as a docker container. To do it, you must go to com.bpulse.client.go.pbulseclient/bpulseclient/example/assets and do this:

  • Install Docker Engine and Docker Compose in your system.

  • Edit the docker-compose.yml file to set the properties:

    • BPULSEID
    • BPULSE_HOST
    • BPULSE_PORT
    • BPULSE_USER
    • BPULSE_PWD
  • Build the Docker image and run the container:

    docker build -t theskyinflames/bpc
    docker-compose up -d bpc
  • Examine BPulse client logs.

bpulse-go-client's People

Contributors

pineda89 avatar

Watchers

James Cloos 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.