module Pokan::Cluster

Cluster module, to be included on all classes that want to implement a custom Gossip server. Including this module enables the developer to customize the configuration file location (and format, as long as she provided a parser for that format). The user can also pass manually the values for the configuration options. However, this is not the recommended way, of course.

Example

class MyCustomGossiper
  include Pokan::Cluster

  config { JSON.parse(CONFIG_PATH) }

end

The ‘config` method expects a hash containing values for network connection, seed address, log information, and others. If you want to see an example of a valid configuration hash, you can parse the following YAML (recommened config format for pokan-cluster):

pokan:
  address: "10.10.10.8" # your IP address

  connect:
    tcp: 4444
    udp: 8787 # ports that will be binded
    epoll: true # Linux machine?

  gossip:
    every: 2 # seconds
    share: "cpu,memory,load" # these are the valid options (separated by comma).

  seed: "10.10.10.2" # will be contacted on startup

  log:
    enabled: true # always good!
    level: "info"
    file: "/path/to/my/log" # default is STDOUT

Optionally, you can directly pass a file, using the ‘config_file` method. However, only the YAML format is currently supported

class MyCustomGossiper
  include Pokan::Cluster

  config_file = '/path/to/my/config.yml'
end

Constants

DEFAULTS

Default values for configuration, specifying:

  • TCP and UDP ports

  • epoll set to false

  • CPU, memory and load average sharing

  • logging enabled to ‘STDOUT`

  • gossip interval: 1 second

LOG_MESSAGES
VERSION

Public Class Methods

included(klass) click to toggle source

When a server includes the Pokan::Cluster module, it gains access to its class methods, allowing the user to set configuration and behavior of the server. It is also configured to automatically run when the server class is loaded.

# File lib/pokan-cluster.rb, line 70
def self.included(klass)
  klass.extend ClassMethods
  Autorunner.register_server(klass)
end
m(string) click to toggle source
# File lib/pokan-cluster/log_messages.rb, line 4
def self.m(string)
  PreparedString.new(string)
end