Project

combi

0.0
No commit activity in last 3 years
No release in over 3 years
Provides implementation for in process, amqp or web socket service bus
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.2
 Project Readme

combi: A mini bus for micro services

A Volkswagen Combi

###Implemented buses

  • In Process: for testing or fast running implementations
  • Web Sockets: for remote (may be behind proxy) clients
  • Queue: for inter server communications (based on AMQP)
  • HTTP: for consumer only services (not session, stateless). Probably will work in any TCP capable network

Disclaimer

This is a work in progress. Expect serious refactors, breaking changes.

How to use

###Server

Define a new service:

module Service
  module Salutation

    def actions
      [:salute]
    end

    def say_hello(params)
      "hello #{params[:name]}"
    end

  end
end

Launch the server (web sockets):

require 'combi'
require 'combi/reactor'
require 'em-websocket'

Combi::Reactor.start
bus = Combi::ServiceBus.for(:web_socket)
bus.start!
bus.add_service(Service::Salutation)

ws_handler = Class.new do
  def new_session(arg); end
end.new

port = 9292
EM::next_tick do
  EM::WebSocket.start(host: '0.0.0.0', port: port) do |ws|
    bus.manage_ws_event(ws, ws_handler)
  end
end
Combi::Reactor.join_thread

###Client Launch the client (web sockets):

require 'combi'
require 'combi/reactor'
Combi::Reactor.start

ws_handler = Class.new do
  def on_open; end
end.new

port = 9292
bus = Combi::ServiceBus.for(:web_socket, remote_api: "ws://localhost:#{port}/", handler: ws_handler)
bus.start!

request = bus.request(:salute, :say_hello, {name: 'world'}) # :salute is the name of action declared in service
request.callback do |response|
  puts "Server says: #{response}"
end

Combi::Reactor.join_thread

Testing

rspec, the integration suite, test services requesting other services through other buses (composition).

For AMQP buses, a RabbitMQ server is required. We provide a setup/teardown based in docker.

OSX users, you will need docker and boot2docker installed. Linux users, you will need docker installed, and make some adjustments to spec/support/rabbitmq_server.rb (the ssh tunnel is not needed)

##Contributors

Abel Muino German DZ

License

MIT License.