Module Toolshed
In: lib/toolshed.rb

This module provides a toolkit of helper methods to Abundance

It uses the Socket Ruby standard library to provide a communication mechanism between Abundance concurent processes. It‘s used as both a namespace for init variables of the different Abundance Classes, using Toolshed‘s Class Method like qualified names, and as mixins methods which access directly the instance variables of the client classes .

Author:lp (lp@spiralix.org)
Copyright:2008 Louis-Philippe Perron - Released under the terms of the MIT license

Methods

Constants

SOCKET_ROOT = '/tmp/abundance/'

Public Class methods

The Toolshed::block_size= method sets the Socket block size for UNIXSocket operations.

Parameters

  • block_size = the block size in bytes

Public Instance methods

The my_socket_path method act as an attribute reader for the @my_socket_path instance variable of the calling object.

The set_my_socket_as_a method sets a UNIXServer socket as an instance variable for the calling object in a role based fashion. When the specified role is not a :garden, the Garden‘s socket path is also stored as an instance variable for the calling object.

Parameters

  • role = the role for which you wish to establish the socket
  • garden_pid = the garden pid that will become the basename for the garden socket. No need to specify this argument when role is :garden.

The socket_duplex method open a UNIXSocket and send packets to a UNIXServer socket, then wait for loopback communication from destination and return results like socket_recv.

Parameters

  • command = command part of the sent packet
  • data = data part of the sent packet
  • server_socket_path = a UNIXServer socket path for the packets to be sent to

The socket_recv method calls accept on a UNIXServer socket, receives all the packets from a UNIXSocket sender, join the packets back as the original block message.

The socket_send method open a UNIXSocket and send packets to a UNIXServer socket. When the server_socket_path is not specified, it defaults sending to the Garden UNIXServer.

Parameters

  • command = command part of the sent packet
  • data = data part of the sent packet
  • server_socket_path = a UNIXServer socket path for the packets to be sent to

[Validate]