Class: RGossip2::Context
- Inherits:
-
Object
- Object
- RGossip2::Context
- Defined in:
- lib/rgossip2/context.rb
Overview
class Context ゴシッププロトコルのための各種変数格納クラス ほとんどのクラスから参照される
Instance Attribute Summary collapse
-
#allowance ⇒ Object
Returns the value of attribute allowance.
-
#auth_key ⇒ Object
HMACの秘密鍵.
-
#buffer_size ⇒ Object
バッファサイズと遊び 「buffer_size * allowance + digest_length」が 65515bytes 以下になるようにする.
-
#callback_handler ⇒ Object
各種ハンドラ.
-
#digest_algorithm ⇒ Object
ハッシュ関数のアルゴリズムと長さ.
-
#digest_length ⇒ Object
Returns the value of attribute digest_length.
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
-
#gossip_interval ⇒ Object
送信インターバル.
-
#logger ⇒ Object
ロガー.
-
#node_lifetime ⇒ Object
Nodeの寿命.
-
#ping_count ⇒ Object
Returns the value of attribute ping_count.
-
#ping_init_nodes ⇒ Object
初期ノードのpingチェックの有無.
-
#ping_interval ⇒ Object
Returns the value of attribute ping_interval.
-
#ping_timeout ⇒ Object
Returns the value of attribute ping_timeout.
-
#port ⇒ Object
ポート番号.
-
#receive_timeout ⇒ Object
受信タイムアウト.
-
#udp_timeout ⇒ Object
初期ノードのUDPスキャンのタイムアウト.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(options = {}) ⇒ Context
Returns a new instance of Context.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rgossip2/context.rb', line 56 def initialize( = {}) unless @auth_key = [:auth_key] raise ':auth_key is required' end default_logger = Logger.new($stderr) default_logger.level = Logger::INFO defaults = { :port => 10870, :buffer_size => 512, :allowance => 3, :node_lifetime => 10, :gossip_interval => 0.1, :receive_timeout => 3, :digest_algorithm => OpenSSL::Digest::SHA256, :digest_length => 32, # 256 / 8 :logger => default_logger, :udp_timeout => 0.3, :ping_init_nodes => false, :ping_count => 3, :ping_interval => 0.1, :ping_timeout => 0.1, :callback_handler => nil, } defaults[:error_handler] = lambda do |e| = (["#{e.class}: #{e.}"] + (e.backtrace || [])).join("\n\tfrom ") if self.logger self.logger.error() else $stderr.puts() end end defaults.each do |k, v| self.instance_variable_set("@#{k}", .fetch(k, v)) end end |
Instance Attribute Details
#allowance ⇒ Object
Returns the value of attribute allowance.
22 23 24 |
# File 'lib/rgossip2/context.rb', line 22 def allowance @allowance end |
#auth_key ⇒ Object
HMACの秘密鍵
29 30 31 |
# File 'lib/rgossip2/context.rb', line 29 def auth_key @auth_key end |
#buffer_size ⇒ Object
バッファサイズと遊び 「buffer_size * allowance + digest_length」が 65515bytes 以下になるようにする
21 22 23 |
# File 'lib/rgossip2/context.rb', line 21 def buffer_size @buffer_size end |
#callback_handler ⇒ Object
各種ハンドラ
53 54 55 |
# File 'lib/rgossip2/context.rb', line 53 def callback_handler @callback_handler end |
#digest_algorithm ⇒ Object
ハッシュ関数のアルゴリズムと長さ
25 26 27 |
# File 'lib/rgossip2/context.rb', line 25 def digest_algorithm @digest_algorithm end |
#digest_length ⇒ Object
Returns the value of attribute digest_length.
26 27 28 |
# File 'lib/rgossip2/context.rb', line 26 def digest_length @digest_length end |
#error_handler ⇒ Object
Returns the value of attribute error_handler.
54 55 56 |
# File 'lib/rgossip2/context.rb', line 54 def error_handler @error_handler end |
#gossip_interval ⇒ Object
送信インターバル
35 36 37 |
# File 'lib/rgossip2/context.rb', line 35 def gossip_interval @gossip_interval end |
#logger ⇒ Object
ロガー
50 51 52 |
# File 'lib/rgossip2/context.rb', line 50 def logger @logger end |
#node_lifetime ⇒ Object
Nodeの寿命
32 33 34 |
# File 'lib/rgossip2/context.rb', line 32 def node_lifetime @node_lifetime end |
#ping_count ⇒ Object
Returns the value of attribute ping_count.
45 46 47 |
# File 'lib/rgossip2/context.rb', line 45 def ping_count @ping_count end |
#ping_init_nodes ⇒ Object
初期ノードのpingチェックの有無
44 45 46 |
# File 'lib/rgossip2/context.rb', line 44 def ping_init_nodes @ping_init_nodes end |
#ping_interval ⇒ Object
Returns the value of attribute ping_interval.
46 47 48 |
# File 'lib/rgossip2/context.rb', line 46 def ping_interval @ping_interval end |
#ping_timeout ⇒ Object
Returns the value of attribute ping_timeout.
47 48 49 |
# File 'lib/rgossip2/context.rb', line 47 def ping_timeout @ping_timeout end |
#port ⇒ Object
ポート番号
17 18 19 |
# File 'lib/rgossip2/context.rb', line 17 def port @port end |
#receive_timeout ⇒ Object
受信タイムアウト
38 39 40 |
# File 'lib/rgossip2/context.rb', line 38 def receive_timeout @receive_timeout end |
#udp_timeout ⇒ Object
初期ノードのUDPスキャンのタイムアウト
41 42 43 |
# File 'lib/rgossip2/context.rb', line 41 def udp_timeout @udp_timeout end |