Class: OpenC3::Topic

Inherits:
Object show all
Defined in:
lib/openc3/topics/topic.rb

Class Method Summary collapse

Class Method Details

.clear_topics(topics, maxlen = 0) ⇒ Object



39
40
41
# File 'lib/openc3/topics/topic.rb', line 39

def self.clear_topics(topics, maxlen = 0)
  topics.each { |topic| EphemeralStore.xtrim(topic, maxlen) }
end

.get_cnt(topic) ⇒ Object



51
52
53
54
# File 'lib/openc3/topics/topic.rb', line 51

def self.get_cnt(topic)
  _, packet = EphemeralStore.get_newest_message(topic)
  packet ? packet["received_count"].to_i : 0
end

.method_missing(message, *args, **kwargs, &block) ⇒ Object

Delegate all unknown class methods to delegate to the EphemeralStore



29
30
31
# File 'lib/openc3/topics/topic.rb', line 29

def self.method_missing(message, *args, &block)
  EphemeralStore.public_send(message, *args, &block)
end

.topics(scope, key) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/openc3/topics/topic.rb', line 43

def self.topics(scope, key)
  EphemeralStore
    .scan_each(match: "#{scope}__#{key}__*", type: 'stream', count: 100)
    .to_a # Change the enumerator into an array
    .uniq # Scan can return duplicates so ensure unique
    .sort # Sort not entirely necessary but nice
end