Class: Thin::Backends::SwiftiplyClient

Inherits:
Base
  • Object
show all
Defined in:
lib/thin/backends/swiftiply_client.rb

Overview

Backend to act as a Swiftiply client (swiftiply.swiftcore.org).

Instance Attribute Summary collapse

Attributes inherited from Base

#maximum_connections, #maximum_persistent_connections, #no_epoll, #persistent_connection_count, #server, #ssl, #ssl_options, #threaded, #threadpool_size, #timeout

Instance Method Summary collapse

Methods inherited from Base

#close, #config, #connection_finished, #empty?, #running?, #size, #ssl?, #start, #started_reactor?, #stop, #stop!, #threaded?

Constructor Details

#initialize(host, port, options = {}) ⇒ SwiftiplyClient

Returns a new instance of SwiftiplyClient.



9
10
11
12
13
14
# File 'lib/thin/backends/swiftiply_client.rb', line 9

def initialize(host, port, options = {})
  @host = host
  @port = port.to_i
  @key  = options[:swiftiply].to_s
  super()
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/thin/backends/swiftiply_client.rb', line 7

def host
  @host
end

#keyObject

Returns the value of attribute key.



5
6
7
# File 'lib/thin/backends/swiftiply_client.rb', line 5

def key
  @key
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/thin/backends/swiftiply_client.rb', line 7

def port
  @port
end

Instance Method Details

#connectObject

Connect the server



17
18
19
# File 'lib/thin/backends/swiftiply_client.rb', line 17

def connect
  EventMachine.connect(@host, @port, SwiftiplyConnection, &method(:initialize_connection))
end

#disconnectObject

Stops the server



22
23
24
# File 'lib/thin/backends/swiftiply_client.rb', line 22

def disconnect
  EventMachine.stop
end

#to_sObject



26
27
28
# File 'lib/thin/backends/swiftiply_client.rb', line 26

def to_s
  "#{@host}:#{@port} swiftiply"
end