Module: Serfx

Defined in:
lib/serfx.rb,
lib/serfx/log.rb,
lib/serfx/utils.rb,
lib/serfx/version.rb,
lib/serfx/commands.rb,
lib/serfx/response.rb,
lib/serfx/connection.rb,
lib/serfx/exceptions.rb

Overview

Provides version as a contsant for the serf gem

Defined Under Namespace

Modules: Commands, Utils Classes: Connection, Log, RPCError, Response

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.connect(opts = {}) ⇒ Object

Creates a serf rpc connection, performs handshake and auth (if authkey is supplied), if a block if provided, the connection will be closed after the block’s execution. Params:

opts

An optional hash which can have following keys:

  • host => Serf host’s rpc bind address (127.0.0.1 by default)

  • port => Serf host’s rpc port (7373 by default)

  • authkey => Encryption key for RPC communiction



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/serfx.rb', line 18

def self.connect(opts = {})
  conn = Serfx::Connection.new(opts)
  conn.handshake
  conn.auth if opts.key?(:authkey)
  if block_given?
    yield conn
    conn.close unless conn.closed?
  else
    conn
  end
end