Class: Google::Cloud::PubSub::V1::Subscriber::Client
- Inherits:
-
Object
- Object
- Google::Cloud::PubSub::V1::Subscriber::Client
- Includes:
- Paths
- Defined in:
- lib/google/cloud/pubsub/v1/subscriber/client.rb
Overview
Client for the Subscriber service.
The service that an application uses to manipulate subscriptions and to
consume messages from a subscription via the Pull
method or by
establishing a bi-directional stream using the StreamingPull
method.
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the Subscriber Client class.
Instance Method Summary collapse
-
#acknowledge(request, options = nil) {|response, operation| ... } ⇒ ::Google::Protobuf::Empty
Acknowledges the messages associated with the
ack_ids
in theAcknowledgeRequest
. -
#configure {|config| ... } ⇒ Client::Configuration
Configure the Subscriber Client instance.
-
#create_snapshot(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::Snapshot
Creates a snapshot from the requested subscription.
-
#create_subscription(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::Subscription
Creates a subscription to a given topic.
-
#delete_snapshot(request, options = nil) {|response, operation| ... } ⇒ ::Google::Protobuf::Empty
Removes an existing snapshot.
-
#delete_subscription(request, options = nil) {|response, operation| ... } ⇒ ::Google::Protobuf::Empty
Deletes an existing subscription.
-
#get_snapshot(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::Snapshot
Gets the configuration details of a snapshot.
-
#get_subscription(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::Subscription
Gets the configuration details of a subscription.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new Subscriber client object.
-
#list_snapshots(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot>
Lists the existing snapshots.
-
#list_subscriptions(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription>
Lists matching subscriptions.
-
#modify_ack_deadline(request, options = nil) {|response, operation| ... } ⇒ ::Google::Protobuf::Empty
Modifies the ack deadline for a specific message.
-
#modify_push_config(request, options = nil) {|response, operation| ... } ⇒ ::Google::Protobuf::Empty
Modifies the
PushConfig
for a specified subscription. -
#pull(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::PullResponse
Pulls messages from the server.
-
#seek(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::SeekResponse
Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request.
-
#streaming_pull(request, options = nil) {|response, operation| ... } ⇒ ::Enumerable<::Google::Cloud::PubSub::V1::StreamingPullResponse>
Establishes a stream with the server, which sends messages down to the client.
-
#update_snapshot(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::Snapshot
Updates an existing snapshot.
-
#update_subscription(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::PubSub::V1::Subscription
Updates an existing subscription.
Methods included from Paths
#project_path, #snapshot_path, #subscription_path, #topic_path
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new Subscriber client object.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 191 def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/pubsub/v1/pubsub_services_pb" # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint && !@config.endpoint.split(".").first.include?("-") credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @subscriber_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::PubSub::V1::Subscriber::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the Subscriber Client class.
See Configuration for a description of the configuration fields.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 58 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "PubSub", "V1"] parent_config = while namespace.any? parent_name = namespace.join "::" parent_const = const_get parent_name break parent_const.configure if parent_const.respond_to? :configure namespace.pop end default_config = Client::Configuration.new parent_config default_config.rpcs.create_subscription.timeout = 60.0 default_config.rpcs.create_subscription.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14] } default_config.rpcs.get_subscription.timeout = 60.0 default_config.rpcs.get_subscription.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14] } default_config.rpcs.update_subscription.timeout = 60.0 default_config.rpcs.update_subscription.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.list_subscriptions.timeout = 60.0 default_config.rpcs.list_subscriptions.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14] } default_config.rpcs.delete_subscription.timeout = 60.0 default_config.rpcs.delete_subscription.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.modify_ack_deadline.timeout = 60.0 default_config.rpcs.modify_ack_deadline.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.acknowledge.timeout = 60.0 default_config.rpcs.acknowledge.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.pull.timeout = 60.0 default_config.rpcs.pull.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14] } default_config.rpcs.streaming_pull.timeout = 900.0 default_config.rpcs.streaming_pull.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 8, 10, 13, 14] } default_config.rpcs.modify_push_config.timeout = 60.0 default_config.rpcs.modify_push_config.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.get_snapshot.timeout = 60.0 default_config.rpcs.get_snapshot.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14] } default_config.rpcs.list_snapshots.timeout = 60.0 default_config.rpcs.list_snapshots.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14] } default_config.rpcs.create_snapshot.timeout = 60.0 default_config.rpcs.create_snapshot.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.update_snapshot.timeout = 60.0 default_config.rpcs.update_snapshot.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.delete_snapshot.timeout = 60.0 default_config.rpcs.delete_snapshot.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.seek.timeout = 60.0 default_config.rpcs.seek.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14] } default_config end yield @configure if block_given? @configure end |
Instance Method Details
#acknowledge(request, options = nil) ⇒ ::Google::Protobuf::Empty #acknowledge(subscription: nil, ack_ids: nil) ⇒ ::Google::Protobuf::Empty
Acknowledges the messages associated with the ack_ids
in the
AcknowledgeRequest
. The Pub/Sub system can remove the relevant messages
from the subscription.
Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 813 def acknowledge request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::AcknowledgeRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.acknowledge..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription" => request.subscription } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.acknowledge.timeout, metadata: , retry_policy: @config.rpcs.acknowledge.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :acknowledge, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#configure {|config| ... } ⇒ Client::Configuration
Configure the Subscriber Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.
See Configuration for a description of the configuration fields.
170 171 172 173 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 170 def configure yield @config if block_given? @config end |
#create_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot #create_snapshot(name: nil, subscription: nil, labels: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot
Creates a snapshot from the requested subscription. Snapshots are used in
Seek operations,
which allow you to manage message acknowledgments in bulk. That is, you can
set the acknowledgment state of messages in an existing subscription to the
state captured by a snapshot.
If the snapshot already exists, returns ALREADY_EXISTS
.
If the requested subscription doesn't exist, returns NOT_FOUND
.
If the backlog in the subscription is too old -- and the resulting snapshot
would expire in less than 1 hour -- then FAILED_PRECONDITION
is returned.
See also the Snapshot.expire_time
field. If the name is not provided in
the request, the server will assign a random
name for this snapshot on the same project as the subscription, conforming
to the resource name format. The
generated name is populated in the returned Snapshot object. Note that for
REST API requests, you must specify a name in the request.
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1291 def create_snapshot request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::CreateSnapshotRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_snapshot..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.create_snapshot.timeout, metadata: , retry_policy: @config.rpcs.create_snapshot.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :create_snapshot, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#create_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription #create_subscription(name: nil, topic: nil, push_config: nil, ack_deadline_seconds: nil, retain_acked_messages: nil, message_retention_duration: nil, labels: nil, enable_message_ordering: nil, expiration_policy: nil, filter: nil, dead_letter_policy: nil, retry_policy: nil, detached: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription
Creates a subscription to a given topic. See the resource name rules.
If the subscription already exists, returns ALREADY_EXISTS
.
If the corresponding topic doesn't exist, returns NOT_FOUND
.
If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic, conforming to the resource name format. The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request.
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 360 def create_subscription request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::Subscription # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_subscription..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.create_subscription.timeout, metadata: , retry_policy: @config.rpcs.create_subscription.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :create_subscription, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_snapshot(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_snapshot(snapshot: nil) ⇒ ::Google::Protobuf::Empty
Removes an existing snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1444 def delete_snapshot request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSnapshotRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_snapshot..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "snapshot" => request.snapshot } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.delete_snapshot.timeout, metadata: , retry_policy: @config.rpcs.delete_snapshot.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :delete_snapshot, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_subscription(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_subscription(subscription: nil) ⇒ ::Google::Protobuf::Empty
Deletes an existing subscription. All messages retained in the subscription
are immediately dropped. Calls to Pull
after deletion will return
NOT_FOUND
. After a subscription is deleted, a new one may be created with
the same name, but the new one has no association with the old
subscription or its topic unless the same topic is specified.
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 650 def delete_subscription request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSubscriptionRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_subscription..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription" => request.subscription } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.delete_subscription.timeout, metadata: , retry_policy: @config.rpcs.delete_subscription.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :delete_subscription, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#get_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot #get_snapshot(snapshot: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot
Gets the configuration details of a snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1110 def get_snapshot request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSnapshotRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_snapshot..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "snapshot" => request.snapshot } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.get_snapshot.timeout, metadata: , retry_policy: @config.rpcs.get_snapshot.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :get_snapshot, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#get_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription #get_subscription(subscription: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription
Gets the configuration details of a subscription.
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 429 def get_subscription request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSubscriptionRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_subscription..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription" => request.subscription } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.get_subscription.timeout, metadata: , retry_policy: @config.rpcs.get_subscription.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :get_subscription, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#list_snapshots(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot> #list_snapshots(project: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot>
Lists the existing snapshots. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1189 def list_snapshots request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSnapshotsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_snapshots..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "project" => request.project } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.list_snapshots.timeout, metadata: , retry_policy: @config.rpcs.list_snapshots.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :list_snapshots, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @subscriber_stub, :list_snapshots, request, response, operation, yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#list_subscriptions(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription> #list_subscriptions(project: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription>
Lists matching subscriptions.
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 576 def list_subscriptions request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSubscriptionsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_subscriptions..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "project" => request.project } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.list_subscriptions.timeout, metadata: , retry_policy: @config.rpcs.list_subscriptions.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :list_subscriptions, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @subscriber_stub, :list_subscriptions, request, response, operation, yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#modify_ack_deadline(request, options = nil) ⇒ ::Google::Protobuf::Empty #modify_ack_deadline(subscription: nil, ack_ids: nil, ack_deadline_seconds: nil) ⇒ ::Google::Protobuf::Empty
Modifies the ack deadline for a specific message. This method is useful
to indicate that more time is needed to process a message by the
subscriber, or to make the message available for redelivery if the
processing was interrupted. Note that this does not modify the
subscription-level ackDeadlineSeconds
used for subsequent messages.
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 734 def modify_ack_deadline request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.modify_ack_deadline..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription" => request.subscription } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.modify_ack_deadline.timeout, metadata: , retry_policy: @config.rpcs.modify_ack_deadline.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :modify_ack_deadline, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#modify_push_config(request, options = nil) ⇒ ::Google::Protobuf::Empty #modify_push_config(subscription: nil, push_config: nil) ⇒ ::Google::Protobuf::Empty
Modifies the PushConfig
for a specified subscription.
This may be used to change a push subscription to a pull one (signified by
an empty PushConfig
) or vice versa, or change the endpoint URL and other
attributes of a push subscription. Messages will accumulate for delivery
continuously through the call regardless of changes to the PushConfig
.
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1037 def modify_push_config request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ModifyPushConfigRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.modify_push_config..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription" => request.subscription } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.modify_push_config.timeout, metadata: , retry_policy: @config.rpcs.modify_push_config.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :modify_push_config, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#pull(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::PullResponse #pull(subscription: nil, return_immediately: nil, max_messages: nil) ⇒ ::Google::Cloud::PubSub::V1::PullResponse
Pulls messages from the server. The server may return UNAVAILABLE
if
there are too many concurrent pull requests pending for the given
subscription.
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 896 def pull request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::PullRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.pull..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription" => request.subscription } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.pull.timeout, metadata: , retry_policy: @config.rpcs.pull.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :pull, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#seek(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::SeekResponse #seek(subscription: nil, time: nil, snapshot: nil) ⇒ ::Google::Cloud::PubSub::V1::SeekResponse
Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. Note that both the subscription and the snapshot must be on the same topic.
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1534 def seek request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::SeekRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.seek..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription" => request.subscription } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.seek.timeout, metadata: , retry_policy: @config.rpcs.seek.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :seek, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#streaming_pull(request, options = nil) {|response, operation| ... } ⇒ ::Enumerable<::Google::Cloud::PubSub::V1::StreamingPullResponse>
Establishes a stream with the server, which sends messages down to the
client. The client streams acknowledgements and ack deadline modifications
back to the server. The server will close the stream and return the status
on any error. The server may close the stream with status UNAVAILABLE
to
reassign server-side resources, in which case, the client should
re-establish the stream. Flow control can be achieved by configuring the
underlying RPC channel.
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 957 def streaming_pull request, = nil unless request.is_a? ::Enumerable raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum request = request.to_enum end request = request.lazy.map do |req| ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::PubSub::V1::StreamingPullRequest end # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.streaming_pull..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.streaming_pull.timeout, metadata: , retry_policy: @config.rpcs.streaming_pull.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :streaming_pull, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#update_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot #update_snapshot(snapshot: nil, update_mask: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot
Updates an existing snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1367 def update_snapshot request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::UpdateSnapshotRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_snapshot..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "snapshot.name" => request.snapshot.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.update_snapshot.timeout, metadata: , retry_policy: @config.rpcs.update_snapshot.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :update_snapshot, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#update_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription #update_subscription(subscription: nil, update_mask: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription
Updates an existing subscription. Note that certain properties of a subscription, such as its topic, are not modifiable.
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 501 def update_subscription request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::UpdateSubscriptionRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_subscription..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::PubSub::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "subscription.name" => request.subscription.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.update_subscription.timeout, metadata: , retry_policy: @config.rpcs.update_subscription.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @subscriber_stub.call_rpc :update_subscription, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |