0.0
No commit activity in last 3 years
No release in over 3 years
A simple Ruby client for the Columbo REST and AMQP API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0

Runtime

~> 2.0
 Project Readme

Columbo Ruby Client

This gem provides a ruby integration for Columbo. It provides:

  • HTTP client
  • AMQP client (RabbitMQ implementation only, due to Bunny gem dependance)

For integration with Rails applications, see the columbo-rails-client gem.

Installation

Add this line to your application's Gemfile:

gem 'columbo-client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install columbo-client

Configuration

Using HTTP

Columbo.configure do |config|
  config.system.uid = 'system_uid'
  config.system.label = 'system_label'
  config.system.type = 'system_type'

  config.client = Columbo::Client::HTTP.new('http://example.com/push')
end

Using AMQP

For the AMQP client, the exchange must be configurated through the Columbo::Client::AMQP::exchange method by giving a name and a block as seen in the example below. durable, auto_delete and arguments exchange options can also be set as explained in the Bunny gem here.

Columbo.configure do |config|
  config.system.uid = 'system_uid'
  config.system.label = 'system_label'
  config.system.type = 'system_type'

  config.client = Columbo::Client::AMQP.new("amqp://guest:guest@localhost:5672")

  config.client.exchange 'exchange-name' do |exchange_options|
    exchange_options.type = 'topic'
    exchange_options.durable = true
  end
end

Usage

We show how to push an event to Columbo by sending the next crafted event:

example_event = {
  "system": {
      "uid": "myCompany",
      "type": "application",
      "label": "MyCompany"
  },
  "action": "contact.created",
  "actor": {
      "uid": "john.smith@mycompany.com",
      "type": "commercial",
      "label": "John Smith"
  },
  "resource": {
      "uid": "1",
      "type": "contact",
      "label": "Eric Martin",
      "attributes": {
          "first_name": "Eric",
          "last_name": "Martin",
          "email": "eric.martin@customer.com",
          "phone": "11111111"
      }
  },
  "context": {},
  "related_resources": [],
  "timestamp": "2016-12-29T10:00:00.000000+00:00"
}

For each client (HTTP and AMQP), 2 methods are available:

  • publish will return true or false depending on the successfulness of the publishing.
  • publish! will raise an error if the publishing fails.

Using HTTP

The publish and publish! methods take an event Hash as parameter.

Columbo.client.publish(example_event)

Using AMQP

The publish and publish! methods take an event Hash as first parameter and an optional Hash parameter. The possible values for the second parameter are available in Bunny documentation here.

options[:routing_key] = 'resource.action'

Columbo.client.publish(example_event, options)