Class: MagicPipe::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/magic_pipe/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



3
4
5
6
7
8
9
10
11
12
13
14
15
# 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

Instance Attribute Details

#codecObject (readonly)

Returns the value of attribute codec.



17
18
19
# File 'lib/magic_pipe/client.rb', line 17

def codec
  @codec
end

#configObject (readonly)

Returns the value of attribute config.



17
18
19
# File 'lib/magic_pipe/client.rb', line 17

def config
  @config
end

#loaderObject (readonly)

Returns the value of attribute loader.



17
18
19
# File 'lib/magic_pipe/client.rb', line 17

def loader
  @loader
end

#metricsObject (readonly)

Returns the value of attribute metrics.



17
18
19
# File 'lib/magic_pipe/client.rb', line 17

def metrics
  @metrics
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/magic_pipe/client.rb', line 17

def name
  @name
end

#senderObject (readonly)

Returns the value of attribute sender.



17
18
19
# File 'lib/magic_pipe/client.rb', line 17

def sender
  @sender
end

#transportObject (readonly)

Returns the value of attribute transport.



17
18
19
# File 'lib/magic_pipe/client.rb', line 17

def transport
  @transport
end

Instance Method Details

#send_data(object:, topic:, wrapper: nil, time: Time.now.utc) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# 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