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.
412 413 414 415 416 417 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 412 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.
770 771 772 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 770 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.
773 774 775 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 773 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.
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 733 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.91.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
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
# File 'lib/aws-sdk-kinesis/async_client.rb', line 711 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 |