Class: Phobos::Producer::PublicAPI

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

Instance Method Summary collapse

Constructor Details

#initialize(host_obj) ⇒ PublicAPI

Returns a new instance of PublicAPI.



16
17
18
# File 'lib/phobos/producer.rb', line 16

def initialize(host_obj)
  @host_obj = host_obj
end

Instance Method Details

#async_publish(topic:, payload:, key: nil, partition_key: nil, headers: nil) ⇒ void

This method returns an undefined value.

Parameters:

  • topic (String)
  • payload (String)
  • key (String) (defaults to: nil)
  • partition_key (Integer) (defaults to: nil)
  • headers (Hash) (defaults to: nil)


40
41
42
43
44
45
46
# File 'lib/phobos/producer.rb', line 40

def async_publish(topic:, payload:, key: nil, partition_key: nil, headers: nil)
  class_producer.async_publish(topic: topic,
                               payload: payload,
                               key: key,
                               partition_key: partition_key,
                               headers: headers)
end

#async_publish_list(messages) ⇒ Object

Parameters:

  • messages (Array<Hash>)


59
60
61
# File 'lib/phobos/producer.rb', line 59

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

#publish(topic:, payload:, key: nil, partition_key: nil, headers: nil) ⇒ void

This method returns an undefined value.

Parameters:

  • topic (String)
  • payload (String)
  • key (String) (defaults to: nil)
  • partition_key (Integer) (defaults to: nil)
  • headers (Hash) (defaults to: nil)


26
27
28
29
30
31
32
# File 'lib/phobos/producer.rb', line 26

def publish(topic:, payload:, key: nil, partition_key: nil, headers: nil)
  class_producer.publish(topic: topic,
                         payload: payload,
                         key: key,
                         partition_key: partition_key,
                         headers: headers)
end

#publish_list(messages) ⇒ Object

Parameters:

  • messages (Array<Hash>)

    e.g.: [

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

    ]



54
55
56
# File 'lib/phobos/producer.rb', line 54

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