Class: Aws::Kinesis::AsyncClient
- Inherits:
-
Seahorse::Client::AsyncBase
- Object
- Seahorse::Client::AsyncBase
- Aws::Kinesis::AsyncClient
- Includes:
- AsyncClientStubs
- Defined in:
- lib/aws-sdk-kinesis/async_client.rb
Overview
An API async client for Kinesis. To construct an async client, you need to configure a ‘:region` and `:credentials`.
async_client = Aws::Kinesis::AsyncClient.new(
region: region_name,
credentials: credentials,
# ...
)
For details on configuring region and credentials see the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).
See #initialize for a full list of supported configuration options.
Class Attribute Summary collapse
- .identifier ⇒ Object readonly private
API Operations collapse
-
#subscribe_to_shard(params = {}) ⇒ Types::SubscribeToShardOutput
This operation establishes an HTTP/2 connection between the consumer you specify in the ‘ConsumerARN` parameter and the shard you specify in the `ShardId` parameter.
Class Method Summary collapse
- .errors_module ⇒ Object private
Instance Method Summary collapse
- #build_request(operation_name, params = {}) ⇒ Object private
-
#initialize(options) ⇒ AsyncClient
constructor
A new instance of AsyncClient.
Constructor Details
#initialize(options) ⇒ AsyncClient
Returns a new instance of AsyncClient.
405 406 407 408 409 410 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 405 def initialize(*args) unless Kernel.const_defined?("HTTP2") raise "Must include http/2 gem to use AsyncClient instances." end super end |
Class Attribute Details
.identifier ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
763 764 765 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 763 def identifier @identifier end |
Class Method Details
.errors_module ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
766 767 768 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 766 def errors_module Errors end |
Instance Method Details
#build_request(operation_name, params = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 726 def build_request(operation_name, params = {}) handlers = @handlers.for(operation_name) tracer = config.telemetry_provider.tracer_provider.tracer( Aws::Telemetry.module_to_tracer_name('Aws::Kinesis') ) context = Seahorse::Client::RequestContext.new( operation_name: operation_name, operation: config.api.operation(operation_name), client: self, params: params, http_response: Seahorse::Client::Http::AsyncResponse.new, config: config, tracer: tracer ) context[:gem_name] = 'aws-sdk-kinesis' context[:gem_version] = '1.79.0' Seahorse::Client::Request.new(handlers, context) end |
#subscribe_to_shard(params = {}) ⇒ Types::SubscribeToShardOutput
This operation establishes an HTTP/2 connection between the consumer you specify in the ‘ConsumerARN` parameter and the shard you specify in the `ShardId` parameter. After the connection is successfully established, Kinesis Data Streams pushes records from the shard to the consumer over this connection. Before you call this operation, call RegisterStreamConsumer to register the consumer with Kinesis Data Streams.
When the ‘SubscribeToShard` call succeeds, your consumer starts receiving events of type SubscribeToShardEvent over the HTTP/2 connection for up to 5 minutes, after which time you need to call `SubscribeToShard` again to renew the subscription if you want to continue to receive records.
You can make one call to ‘SubscribeToShard` per second per registered consumer per shard. For example, if you have a 4000 shard stream and two registered stream consumers, you can make one `SubscribeToShard` request per second for each combination of shard and registered consumer, allowing you to subscribe both consumers to all 4000 shards in one second.
If you call ‘SubscribeToShard` again with the same `ConsumerARN` and `ShardId` within 5 seconds of a successful call, you’ll get a ‘ResourceInUseException`. If you call `SubscribeToShard` 5 seconds or more after a successful call, the second call takes over the subscription and the previous connection expires or fails with a `ResourceInUseException`.
For an example of how to use this operation, see [Enhanced Fan-Out Using the Kinesis Data Streams API].
[1]: docs.aws.amazon.com/streams/latest/dev/building-enhanced-consumers-api.html
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 704 def subscribe_to_shard(params = {}, = {}) params = params.dup output_event_stream_handler = _event_stream_handler( :output, params.delete(:output_event_stream_handler) || params.delete(:event_stream_handler), EventStreams::SubscribeToShardEventStream ) yield(output_event_stream_handler) if block_given? req = build_request(:subscribe_to_shard, params) req.context[:output_event_stream_handler] = output_event_stream_handler req.handlers.add(Aws::Binary::DecodeHandler, priority: 55) req.send_request() end |