Method: OpenC3::DecomMicroservice#run

Defined in:
lib/openc3/microservices/decom_microservice.rb

#runObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/openc3/microservices/decom_microservice.rb', line 107

def run
  @limits_response_thread = LimitsResponseThread.new(microservice_name: @name, queue: @limits_response_queue, logger: @logger, metric: @metric, scope: @scope)
  @limits_response_thread.start()

  setup_microservice_topic()
  while true
    break if @cancel_thread

    begin
      OpenC3.in_span("read_topics") do
        Topic.read_topics(@topics) do |topic, msg_id, msg_hash, redis|
          break if @cancel_thread
          if topic == @microservice_topic
            microservice_cmd(topic, msg_id, msg_hash, redis)
          elsif topic =~ /__DECOMINTERFACE/
            if msg_hash.key?('inject_tlm')
              handle_inject_tlm(msg_hash['inject_tlm'])
              next
            end
            if msg_hash.key?('build_cmd')
              handle_build_cmd(msg_hash['build_cmd'], msg_id)
              next
            end
          else
            decom_packet(topic, msg_id, msg_hash, redis)
            @metric.set(name: 'decom_total', value: @count, type: 'counter')
          end
          @count += 1
        end
      end
      LimitsEventTopic.sync_system_thread_body(scope: @scope)
    rescue => e
      @error_count += 1
      @metric.set(name: 'decom_error_total', value: @error_count, type: 'counter')
      @error = e
      @logger.error("Decom error: #{e.formatted}")
    end
  end

  @limits_response_thread.stop()
  @limits_response_thread = nil
end