Class: Phobos::Producer::PublicAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/phobos/producer.rb

Constant Summary collapse

MissingRequiredArgumentsError =
Class.new(StandardError) do
  def initialize
    super('You need to provide a topic name and a payload')
  end
end

Instance Method Summary collapse

Constructor Details

#initialize(host_obj) ⇒ PublicAPI

Returns a new instance of PublicAPI.



20
21
22
# File 'lib/phobos/producer.rb', line 20

def initialize(host_obj)
  @host_obj = host_obj
end

Instance Method Details

#async_publish(*args, **kwargs) ⇒ Object



31
32
33
34
35
36
# File 'lib/phobos/producer.rb', line 31

def async_publish(*args, **kwargs)
  Phobos.deprecate(deprecate_positional_args_message('async_publish')) if kwargs.empty?

  args = normalize_arguments(*args, **kwargs)
  class_producer.async_publish(**args)
end

#async_publish_list(messages) ⇒ Object



48
49
50
# File 'lib/phobos/producer.rb', line 48

def async_publish_list(messages)
  class_producer.async_publish_list(messages)
end

#publish(*args, **kwargs) ⇒ Object



24
25
26
27
28
29
# File 'lib/phobos/producer.rb', line 24

def publish(*args, **kwargs)
  Phobos.deprecate(deprecate_positional_args_message('publish')) if kwargs.empty?

  args = normalize_arguments(*args, **kwargs)
  class_producer.publish(**args)
end

#publish_list(messages) ⇒ Object

Parameters:

  • messages (Array(Hash(:topic, :payload, :key, :headers)))

    e.g.: [

    { topic: 'A', payload: 'message-1', key: '1', headers: { foo: 'bar' } },
    { topic: 'B', payload: 'message-2', key: '2', headers: { foo: 'bar' } }
    

    ]



44
45
46
# File 'lib/phobos/producer.rb', line 44

def publish_list(messages)
  class_producer.publish_list(messages)
end