Class: Cosmos::RouterMicroservice
- Inherits:
-
InterfaceMicroservice
- Object
- Microservice
- InterfaceMicroservice
- Cosmos::RouterMicroservice
- Defined in:
- lib/cosmos/microservices/router_microservice.rb
Constant Summary
Constants inherited from InterfaceMicroservice
InterfaceMicroservice::UNKNOWN_BYTES_TO_PRINT
Instance Attribute Summary
Attributes inherited from Microservice
#count, #custom, #error, #microservice_status_thread, #name, #scope, #state
Instance Method Summary collapse
Methods inherited from InterfaceMicroservice
#attempting, #connect, #disconnect, #graceful_kill, #handle_connection_failed, #handle_connection_lost, #initialize, #inject_tlm, #run, #shutdown, #stop
Methods inherited from Microservice
#as_json, #initialize, run, #run, #shutdown
Constructor Details
This class inherits a constructor from Cosmos::InterfaceMicroservice
Instance Method Details
#handle_packet(packet) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cosmos/microservices/router_microservice.rb', line 24 def handle_packet(packet) @count += 1 RouterStatusModel.set(@interface.as_json, scope: @scope) if !packet.identified? # Need to identify so we can find the target identified_packet = System.commands.identify(packet.buffer(false), @target_names) packet = identified_packet if identified_packet end begin RouterTopic.route_command(packet, @target_names, scope: @scope) @count += 1 rescue Exception => err @error = err Logger.error "Error routing command from #{@interface.name}\n#{err.formatted}" end end |