Sha256: d6c369f4704c5f7bf44445e1e069662377edc3c66e64123ca73fdfae15cec517

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

# encoding: ascii-8bit

# Copyright 2022 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# This program may also be used under the terms of a commercial or
# enterprise edition license of COSMOS if purchased from the
# copyright holder

require 'cosmos/microservices/interface_microservice'

module Cosmos
  class RouterMicroservice < InterfaceMicroservice
    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
  end
end

Cosmos::RouterMicroservice.run if __FILE__ == $0

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cosmos-5.0.5 lib/cosmos/microservices/router_microservice.rb
cosmos-5.0.4 lib/cosmos/microservices/router_microservice.rb
cosmos-5.0.3 lib/cosmos/microservices/router_microservice.rb
cosmos-5.0.2 lib/cosmos/microservices/router_microservice.rb
cosmos-5.0.2.pre.beta2 lib/cosmos/microservices/router_microservice.rb