Class: Atatus::Transport::Worker Private
- Inherits:
-
Object
- Object
- Atatus::Transport::Worker
- Includes:
- Logging
- Defined in:
- lib/atatus/transport/worker.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: FlushMessage, StopMessage
Constant Summary
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Class Attribute Summary collapse
- .adapter ⇒ Object private
Instance Attribute Summary collapse
- #connection ⇒ Object readonly private
- #filters ⇒ Object readonly private
- #name ⇒ Object readonly private
- #queue ⇒ Object readonly private
- #serializers ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(config, queue, serializers:, filters:) ⇒ Worker
constructor
private
A new instance of Worker.
- #process(resource) ⇒ Object private
- #work_forever ⇒ Object private
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(config, queue, serializers:, filters:) ⇒ Worker
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Worker.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/atatus/transport/worker.rb', line 40 def initialize( config, queue, serializers:, filters: ) @config = config @queue = queue @serializers = serializers @filters = filters @connection = self.class.adapter.new(config) end |
Class Attribute Details
.adapter ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/atatus/transport/worker.rb', line 27 def adapter @adapter ||= Connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/atatus/transport/worker.rb', line 55 def connection @connection end |
#filters ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/atatus/transport/worker.rb', line 55 def filters @filters end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/atatus/transport/worker.rb', line 55 def name @name end |
#queue ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/atatus/transport/worker.rb', line 55 def queue @queue end |
#serializers ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/atatus/transport/worker.rb', line 55 def serializers @serializers end |
Instance Method Details
#process(resource) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 76 |
# File 'lib/atatus/transport/worker.rb', line 73 def process(resource) return unless (json = serialize_and_filter(resource)) connection.write(json) end |
#work_forever ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/atatus/transport/worker.rb', line 57 def work_forever while (msg = queue.pop) case msg when StopMessage debug 'Stopping worker [%s]', self connection.flush(:halt) break else process msg end end rescue Exception => e warn 'Worker died with exception: %s', e.inspect debug e.backtrace.join("\n") end |