Class: Lumberjack::Socket
- Inherits:
-
Object
- Object
- Lumberjack::Socket
- Defined in:
- lib/lumberjack/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#sequence ⇒ Object
readonly
Create a new Lumberjack Socket.
-
#window_size ⇒ Object
readonly
Returns the value of attribute window_size.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Socket
constructor
A new instance of Socket.
- #write_hash(hash) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Socket
Returns a new instance of Socket.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/lumberjack/client.rb', line 64 def initialize(opts={}) @sequence = 0 @last_ack = 0 @opts = { :port => 0, :address => "127.0.0.1", :ssl_certificate => nil, :window_size => 5000 }.merge(opts) @host = @opts[:address] @window_size = @opts[:window_size] tcp_socket = TCPSocket.new(@opts[:address], @opts[:port]) openssl_cert = OpenSSL::X509::Certificate.new(File.read(@opts[:ssl_certificate])) @socket = OpenSSL::SSL::SSLSocket.new(tcp_socket) @socket.connect #if @socket.peer_cert.to_s != openssl_cert.to_s # raise "Client and server certificates do not match." #end @socket.syswrite(["1", "W", @window_size].pack("AAN")) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
63 64 65 |
# File 'lib/lumberjack/client.rb', line 63 def host @host end |
#sequence ⇒ Object (readonly)
Create a new Lumberjack Socket.
-
options is a hash. Valid options are:
-
:port - the port to listen on
-
:address - the host/address to bind to
-
:ssl_certificate - the path to the ssl cert to use
61 62 63 |
# File 'lib/lumberjack/client.rb', line 61 def sequence @sequence end |
#window_size ⇒ Object (readonly)
Returns the value of attribute window_size.
62 63 64 |
# File 'lib/lumberjack/client.rb', line 62 def window_size @window_size end |
Instance Method Details
#write_hash(hash) ⇒ Object
101 102 103 104 105 |
# File 'lib/lumberjack/client.rb', line 101 def write_hash(hash) frame = to_frame(hash, inc) ack if (@sequence - (@last_ack + 1)) >= @window_size write frame end |