Class: NatsClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_url: 'localhost:4222', stream: '', subject: '', callback: nil, token: '') ⇒ NatsClient

Returns a new instance of NatsClient.



10
11
12
13
14
15
# File 'lib/tailslide/nats_client.rb', line 10

def initialize(server_url: 'localhost:4222', stream: '', subject: '', callback: nil, token: '')
  @stream = stream
  @subject = format_subject(subject)
  @connection_string = "nats://#{token}#{'@' if token}#{server_url}"
  @callback = callback
end

Instance Attribute Details

#callbackObject (readonly)

Returns the value of attribute callback.



8
9
10
# File 'lib/tailslide/nats_client.rb', line 8

def callback
  @callback
end

#connection_stringObject (readonly)

Returns the value of attribute connection_string.



8
9
10
# File 'lib/tailslide/nats_client.rb', line 8

def connection_string
  @connection_string
end

#jetstreamObject

Returns the value of attribute jetstream.



7
8
9
# File 'lib/tailslide/nats_client.rb', line 7

def jetstream
  @jetstream
end

#nats_connectionObject

Returns the value of attribute nats_connection.



7
8
9
# File 'lib/tailslide/nats_client.rb', line 7

def nats_connection
  @nats_connection
end

#streamObject (readonly)

Returns the value of attribute stream.



8
9
10
# File 'lib/tailslide/nats_client.rb', line 8

def stream
  @stream
end

#subjectObject (readonly)

Returns the value of attribute subject.



8
9
10
# File 'lib/tailslide/nats_client.rb', line 8

def subject
  @subject
end

#subscribed_streamObject

Returns the value of attribute subscribed_stream.



7
8
9
# File 'lib/tailslide/nats_client.rb', line 7

def subscribed_stream
  @subscribed_stream
end

Instance Method Details

#initialize_flagsObject



17
18
19
20
21
# File 'lib/tailslide/nats_client.rb', line 17

def initialize_flags
  connect
  fetch_latest_message
  fetch_ongoing_event_messages
end