Project

tiq

0.0
The project is in a healthy, maintained state
Simple RPC protocol.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0
 Project Readme

Tiq

Github page http://github.com/qadron/tiq
Code Documentation http://rubydoc.info/github/qadron/tiq/
Author Tasos Laskos
Copyright Tasos Laskos
License MPL v2

Synopsis

Tiq is a simple and lightweight clustering solution.

This implementation is based on Toq to cover Remote Procedure Call needs.

Concepts

There are a few key concepts in Tiq:

Node

Tiq::Node offers Node representations, server-side presences if you must.

To start a Node, you need to create a class that inherits from Tiq::Node and instantiate it with a URL to bind to.

cass MyNode < Tiq::Node
end

node = MyNode.new( url: "localhost:9999" ).start

Cluster

To create a Cluster, you need to create another Node and specify any already existing one, as a Cluster member, to be its peer.

Any existing Node would do.

class MySecondNode < Tiq::Node
end

node_2 = MySecondNode.new( url: "localhost:9998", peer: 'localhost:9999' ).start

Client

Tiq::Client offers a Client to enable Node/User communications.

client = MyClient.new( "localhost:9999" ).start

# Issue calls on the server side and get us the responses.
# Client will return `true`.
p client.alive?
# Client will return information about the Grid members.
p client.peers
# Client will return information about the Grid members.
p client.info

Channel

Chanel Nodes offer client-side access to the Shared Data; a Shared HashMap.

This enables the establishment of channels via callbacks upon Data operations.

class MyNode < Tiq::Node
end

class MySecondNode < Tiq::Node
end

class MyChannelNode < Tiq::Node
end

# Set up initial Node, the start of the cluster.
node_1  = MyNode.new( url: "localhost:9999" ).start
node_2  = MySecondNode.new( url: "localhost:9998", peer: 'localhost:9999' ).start
channel = MyChannelNode.new( url: "localhost:9997", peer: 'localhost:9999' ).start.channel
sleep 1

channel.on_set :my_signal do |value|
    p "#{:on_set} - #{value}"
end

node_1.channel.set :my_signal, 'tada!'
sleep 1

Add-ons

Node Add-ons are most commonly Services, and are are immensly easy to deploy and have up and running for every Node.

class MyNode < Tiq::Node
end

# Set up initial Node.
node_1 = MyNode.new( url: "localhost:9999" ).start

# Add a service to the node, called :poll.
Tiq::Addon::Attach node_1, :poll do |arguments = nil|
    p "SERVICE: #{arguments}"
end

# Interact with the service via a Client.
Tiq::Addon "localhost:9999", :poll, 'ping' do |r|
    puts "CLIENT: #{r}"
end

sleep 1

Channel Shared Data

Data can be shared across Nodes by means of broadcasting upon change - optional.

class MyNode < Tiq::Node
end

class MySecondNode < Tiq::Node
end

# Set up initial Node, the start of the cluster.
node_1 = MyNode.new( url: "localhost:9999" ).start
node_2 = MySecondNode.new( url: "localhost:9998", peer: 'localhost:9999' ).start

sleep 1

node_2.channel.on_set :my_signal do |value|
    p "#{:on_set} - #{value}"
end

node_1.channel.set :my_signal, 'tada!'
sleep 1

Custom groups

require 'tiq'

n1 = Tiq::Node.new( url: "localhost:9999" ).start
n2 = Tiq::Node.new( url: "localhost:9998", peer: 'localhost:9999' ).start

# Add as many groups/channels/shared-data structures as you want.
n1.create_channel 'agents'

n1.agents.set :a1, 99
sleep 1

p n2.agents.get :a1

Installation

gem install tiq

License

Tiq is provided under the 3-clause BSD license. See the LICENSE file for more information.