Class: Mayu::Metrics::Collector::Server

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mayu/metrics/collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ Server



107
108
109
# File 'lib/mayu/metrics/collector.rb', line 107

def initialize(endpoint)
  @endpoint = endpoint
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



104
105
106
# File 'lib/mayu/metrics/collector.rb', line 104

def endpoint
  @endpoint
end

Instance Method Details

#all_values(metric_name) ⇒ Object

Raises:

  • (NotImplementedError)


112
113
114
# File 'lib/mayu/metrics/collector.rb', line 112

def all_values(metric_name)
  raise NotImplementedError, "Should this even be implemented?"
end

#run(internal_store, name: self.class.name.to_s, restart: true) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/mayu/metrics/collector.rb', line 131

def run(internal_store, name: self.class.name.to_s, restart: true)
  wrapper = Wrapper.new

  Console.logger.info(
    self,
    "Starting metrics collection on #{File.expand_path(@endpoint.path)}"
  )

  @endpoint.accept do |peer|
    store = internal_store.store(peer, {})

    unpacker = wrapper.unpacker(peer)

    unpacker.each do |message|
      case message
      in [:store, data]
        store.merge!(data)
      else
        Console
          .logger
          .warn(self) { "Unhandled mesage: #{message.inspect}" }
      end
    end
  ensure
    internal_store.delete(peer)
  end
end

#startObject



117
118
# File 'lib/mayu/metrics/collector.rb', line 117

def start
end

#stopObject



121
122
# File 'lib/mayu/metrics/collector.rb', line 121

def stop
end