class MagicPipe::Client

Attributes

codec[R]
config[R]
loader[R]
metrics[R]
name[R]
sender[R]
transport[R]

Public Class Methods

new(config) click to toggle source
# File lib/magic_pipe/client.rb, line 3
def initialize(config)
  @config = config
  @name = config.client_name

  @metrics = Metrics.new(@config)

  @transport = build_transport

  @codec = Codecs.lookup(config.codec)
  @sender = Senders.lookup(config.sender)

  @loader = Loaders.lookup(config.loader)
end

Public Instance Methods

send_data(object:, topic:, wrapper: nil, time: Time.now.utc) click to toggle source
# File lib/magic_pipe/client.rb, line 19
def send_data(object:, topic:, wrapper: nil, time: Time.now.utc)
  sender.new(
    object,
    topic,
    wrapper,
    time,
    codec,
    transport,
    @config,
    @metrics
  ).call
  true
end

Private Instance Methods

build_transport() click to toggle source
# File lib/magic_pipe/client.rb, line 36
def build_transport
  klass = Transports.lookup(@config.transport)
  klass.new(@config, @metrics)
end