Class: Evesync::Handler
- Inherits:
-
Object
- Object
- Evesync::Handler
- Defined in:
- lib/evesync/handler.rb,
lib/evesync/handler/file.rb,
lib/evesync/handler/package.rb
Overview
Handles package changes, sent via Package class and queue Sends messages to evedatad and available evehands.
- See
-
Evesync::Trigger::File
-
Evesync::Trigger::Package
-
- Handlers available:
-
Evesync::Handler::Package
-
Evesync::Handler::File
-
Example:
handler = Evesync::Handler.new(queue)
Evesync::IPC::Server.new(
:proxy => handler,
...
)
Example call:
Evesync::IPC::Client.new(
:port => :evehand
).handle(IPC::Data::Package.new(
:name => 'tree',
:version => '0.0.1',
:command => :install
)
TODO:
* Make anoter daemon\Thread to search for available
evehands daemons
* Delegate +handle+ to another daemon if not found
Defined Under Namespace
Instance Method Summary collapse
-
#events ⇒ Object
For syncing and other remove db access.
- #handle(message) ⇒ Object
-
#initialize ⇒ Handler
constructor
A new instance of Handler.
- #messages(*args) ⇒ Object
Constructor Details
#initialize ⇒ Handler
Returns a new instance of Handler.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/evesync/handler.rb', line 43 def initialize @package_handler = Handler::Package.new @files_handler = Handler::File.new @monitor = IPC::Client.new( port: :evemond ) @database = IPC::Client.new( port: :evedatad ) Log.debug('Handler initialization done!') end |
Instance Method Details
#events ⇒ Object
For syncing and other remove db access
81 82 83 |
# File 'lib/evesync/handler.rb', line 81 def events @database.events end |
#handle(message) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/evesync/handler.rb', line 55 def handle() Log.info "Handler triggered with: #{}" handler = if .is_a? IPC::Data::Package @package_handler elsif .is_a? IPC::Data::File @files_handler else Log.error('Handler: unknown message type') nil end return unless handler @monitor.ignore() # TODO: add PackageManagerLock exception # FIXME: package manger may be locked # Add sleep and ones again try if PackageManagerLock # exception is cought handler.handle() || @monitor.unignore() @database.save() true end |
#messages(*args) ⇒ Object
85 86 87 |
# File 'lib/evesync/handler.rb', line 85 def (*args) @database.(*args) end |