Module: Pokan::Cluster::ClassMethods

Defined in:
lib/pokan-cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



128
129
130
# File 'lib/pokan-cluster.rb', line 128

def method_missing(meth, *args, &block)
  @delegator.send(meth, *args, &block)
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def address
  @address
end

#epollObject Also known as: epoll?

Returns the value of attribute epoll.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def epoll
  @epoll
end

#gossip_intervalObject

Returns the value of attribute gossip_interval.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def gossip_interval
  @gossip_interval
end

#log_fileObject

Returns the value of attribute log_file.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def log_file
  @log_file
end

#log_levelObject

Returns the value of attribute log_level.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def log_level
  @log_level
end

#loggingObject Also known as: logging?

Returns the value of attribute logging.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def logging
  @logging
end

#seedObject

Returns the value of attribute seed.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def seed
  @seed
end

#sharesObject

Returns the value of attribute shares.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def shares
  @shares
end

#tcp_portObject

Returns the value of attribute tcp_port.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def tcp_port
  @tcp_port
end

#udp_portObject

Returns the value of attribute udp_port.



84
85
86
# File 'lib/pokan-cluster.rb', line 84

def udp_port
  @udp_port
end

Instance Method Details

#config(&block) ⇒ Object

Loads the server configuration, expecting a valid config hash in a block. This allows you to use whatever configuration format, as long as you can transform it to a valid pokan hash.



94
95
96
97
98
99
# File 'lib/pokan-cluster.rb', line 94

def config(&block)
  @server || load!(block.call)
  initialize_log
  store_hwinfo
  delegate
end

#config_file(path, options = {}) ⇒ Object

Convenience method, allowing the user to set the file containing the configuration in the YAML format. In the future, maybe add builtin support for other different formats.



104
105
106
# File 'lib/pokan-cluster.rb', line 104

def config_file(path, options={})
  config { YAML.load(File.read path) }
end

#disable_logObject

Disables log for the gossip server



109
110
111
# File 'lib/pokan-cluster.rb', line 109

def disable_log
  @logging = false
end

#gossip_with(address, options) ⇒ Object

Sets the seed address and redis port, if specified

class Server
  include Pokan::Cluster

  gossip_with '10.10.10.3', :redis => 6549
end

If no Redis port is specified, 6379 is assumed (as it is the default Redis port).



123
124
125
126
# File 'lib/pokan-cluster.rb', line 123

def gossip_with(address, options)
  update_autorunner_option(:gossip_with, address)
  update_autorunner_option(:redis, options[:redis] || DEFAULTS[:redis])
end