Class: PostcardRB

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

Instance Method Summary collapse

Constructor Details

#initialize(dispatcher:) ⇒ PostcardRB

Returns a new instance of PostcardRB.



4
5
6
7
8
9
# File 'lib/postcard_rb.rb', line 4

def initialize dispatcher:
  @CONNECTION_RETRIES = 10
  @CONNECTION_INTERVAL = 2

  @dispatcher = dispatcher 
end

Instance Method Details

#connectObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/postcard_rb.rb', line 11

def connect
  begin
    @dispatcher.connect(
      connectionInterval: @CONNECTION_INTERVAL, 
      connectionRetries: @CONNECTION_RETRIES
    )
  rescue DispatcherConnectionRefused
    raise PostcardConnectionRefused
  end  
end

#createTopic(name:, routing:) ⇒ Object



22
23
24
25
26
# File 'lib/postcard_rb.rb', line 22

def createTopic name:, routing:
  topic = @dispatcher.createTopic(name: name, routing: routing)

  return topic
end