Class: Pollen::Server
- Inherits:
-
Object
- Object
- Pollen::Server
- Includes:
- Configurable
- Defined in:
- lib/pollen/server.rb
Instance Method Summary collapse
- #accept(socket, stream) ⇒ Object
- #configuration ⇒ Object
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #push(stream_id, *args) ⇒ Object
- #start! ⇒ Object
- #started? ⇒ Boolean
Methods included from Configurable
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
61 62 63 |
# File 'lib/pollen/server.rb', line 61 def initialize @partitioner = Partitioner.new(configuration) end |
Instance Method Details
#accept(socket, stream) ⇒ Object
82 83 84 85 86 |
# File 'lib/pollen/server.rb', line 82 def accept(socket, stream) executor(stream.id).accept( IncomingConnection.new(stream.id, socket, stream.status, stream.payload, Time.now.to_i + stream.timeout) ) end |
#configuration ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/pollen/server.rb', line 88 def configuration return @configuration if @configuration @configuration = CompositeConfiguration.new( ServerConfiguration.new, Pollen.common.configuration ) end |
#push(stream_id, *args) ⇒ Object
78 79 80 |
# File 'lib/pollen/server.rb', line 78 def push(stream_id, *args) executor(stream_id).push(stream_id, *args) end |
#start! ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/pollen/server.rb', line 65 def start! @executors = Array.new(configuration.concurrency).map do Executor.new.start! end Subscriber.new(self).start! @started = true self end |
#started? ⇒ Boolean
74 75 76 |
# File 'lib/pollen/server.rb', line 74 def started? !!@started end |