Class: Svix::AutoConfigConsumer
- Inherits:
-
Object
- Object
- Svix::AutoConfigConsumer
- Defined in:
- lib/svix/autoconfig_consumer.rb
Instance Method Summary collapse
- #commit(consumer_id, offset, options = {}) ⇒ Object
-
#initialize(token, sink_in) ⇒ AutoConfigConsumer
constructor
A new instance of AutoConfigConsumer.
- #receive(consumer_id, options = {}) ⇒ Object
- #subscribe ⇒ Object
Constructor Details
#initialize(token, sink_in) ⇒ AutoConfigConsumer
Returns a new instance of AutoConfigConsumer.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/svix/autoconfig_consumer.rb', line 12 def initialize(token, sink_in) content = AutoConfig.decode_token!(token) @app_id = content.fetch("app_id") @sink_id = content.fetch("endpoint_id") @sink_in = sink_in @client = SvixHttpClient.new( content.fetch("token_plaintext"), URI(content.fetch("server_url")) ) end |
Instance Method Details
#commit(consumer_id, offset, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/svix/autoconfig_consumer.rb', line 40 def commit(consumer_id, offset, = {}) MessagePollerv2.new(@client).consumer_commit( @app_id, @sink_id, consumer_id, PollerV2CommitIn.new("offset" => offset), ) end |
#receive(consumer_id, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/svix/autoconfig_consumer.rb', line 31 def receive(consumer_id, = {}) MessagePollerv2.new(@client).consumer_poll( @app_id, @sink_id, consumer_id, ) end |
#subscribe ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/svix/autoconfig_consumer.rb', line 23 def subscribe poller = AutoConfigSinkTypeConfig::Poller.new(@sink_in.serialize) subscribe_in = SubscribeIn.new( "sink" => AutoConfigSinkType.new("config" => poller) ) EndpointAutoConfig.new(@client).update(@app_id, @sink_id, subscribe_in) end |