google-cloud-pubsub 2.23.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/OVERVIEW.md +188 -144
- data/lib/google/cloud/pubsub/admin_clients.rb +116 -0
- data/lib/google/cloud/pubsub/async_publisher.rb +9 -9
- data/lib/google/cloud/pubsub/batch_publisher.rb +4 -4
- data/lib/google/cloud/pubsub/errors.rb +3 -3
- data/lib/google/cloud/pubsub/message.rb +8 -8
- data/lib/google/cloud/pubsub/{subscriber → message_listener}/enumerator_queue.rb +1 -1
- data/lib/google/cloud/pubsub/{subscriber → message_listener}/inventory.rb +2 -4
- data/lib/google/cloud/pubsub/{subscriber → message_listener}/sequencer.rb +1 -1
- data/lib/google/cloud/pubsub/{subscriber → message_listener}/stream.rb +10 -10
- data/lib/google/cloud/pubsub/{subscriber → message_listener}/timed_unary_buffer.rb +1 -1
- data/lib/google/cloud/pubsub/message_listener.rb +413 -0
- data/lib/google/cloud/pubsub/project.rb +98 -531
- data/lib/google/cloud/pubsub/publisher.rb +373 -0
- data/lib/google/cloud/pubsub/received_message.rb +44 -39
- data/lib/google/cloud/pubsub/service.rb +24 -386
- data/lib/google/cloud/pubsub/subscriber.rb +442 -279
- data/lib/google/cloud/pubsub/version.rb +1 -1
- data/lib/google/cloud/pubsub.rb +8 -15
- data/lib/google-cloud-pubsub.rb +5 -4
- metadata +9 -17
- data/lib/google/cloud/pubsub/policy.rb +0 -188
- data/lib/google/cloud/pubsub/retry_policy.rb +0 -88
- data/lib/google/cloud/pubsub/schema/list.rb +0 -180
- data/lib/google/cloud/pubsub/schema.rb +0 -378
- data/lib/google/cloud/pubsub/snapshot/list.rb +0 -178
- data/lib/google/cloud/pubsub/snapshot.rb +0 -205
- data/lib/google/cloud/pubsub/subscription/list.rb +0 -205
- data/lib/google/cloud/pubsub/subscription/push_config.rb +0 -268
- data/lib/google/cloud/pubsub/subscription.rb +0 -1467
- data/lib/google/cloud/pubsub/topic/list.rb +0 -171
- data/lib/google/cloud/pubsub/topic.rb +0 -1100
@@ -1,171 +0,0 @@
|
|
1
|
-
# Copyright 2015 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
require "delegate"
|
17
|
-
|
18
|
-
module Google
|
19
|
-
module Cloud
|
20
|
-
module PubSub
|
21
|
-
class Topic
|
22
|
-
##
|
23
|
-
# Topic::List is a special case Array with additional values.
|
24
|
-
class List < DelegateClass(::Array)
|
25
|
-
##
|
26
|
-
# If not empty, indicates that there are more topics
|
27
|
-
# that match the request and this value should be passed to
|
28
|
-
# the next {Google::Cloud::PubSub::Project#topics} to continue.
|
29
|
-
attr_accessor :token
|
30
|
-
|
31
|
-
##
|
32
|
-
# @private Create a new Topic::List with an array of values.
|
33
|
-
def initialize arr = []
|
34
|
-
super arr
|
35
|
-
end
|
36
|
-
|
37
|
-
##
|
38
|
-
# Whether there a next page of topics.
|
39
|
-
#
|
40
|
-
# @return [Boolean]
|
41
|
-
#
|
42
|
-
# @example
|
43
|
-
# require "google/cloud/pubsub"
|
44
|
-
#
|
45
|
-
# pubsub = Google::Cloud::PubSub.new
|
46
|
-
#
|
47
|
-
# topics = pubsub.topics
|
48
|
-
# if topics.next?
|
49
|
-
# next_topics = topics.next
|
50
|
-
# end
|
51
|
-
#
|
52
|
-
def next?
|
53
|
-
!token.nil?
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# Retrieve the next page of topics.
|
58
|
-
#
|
59
|
-
# @return [Topic::List]
|
60
|
-
#
|
61
|
-
# @example
|
62
|
-
# require "google/cloud/pubsub"
|
63
|
-
#
|
64
|
-
# pubsub = Google::Cloud::PubSub.new
|
65
|
-
#
|
66
|
-
# topics = pubsub.topics
|
67
|
-
# if topics.next?
|
68
|
-
# next_topics = topics.next
|
69
|
-
# end
|
70
|
-
#
|
71
|
-
def next
|
72
|
-
return nil unless next?
|
73
|
-
ensure_service!
|
74
|
-
options = { token: token, max: @max }
|
75
|
-
grpc = @service.list_topics options
|
76
|
-
self.class.from_grpc grpc, @service, @max
|
77
|
-
end
|
78
|
-
|
79
|
-
##
|
80
|
-
# Retrieves remaining results by repeatedly invoking {#next} until
|
81
|
-
# {#next?} returns `false`. Calls the given block once for each
|
82
|
-
# result, which is passed as the argument to the block.
|
83
|
-
#
|
84
|
-
# An Enumerator is returned if no block is given.
|
85
|
-
#
|
86
|
-
# This method will make repeated API calls until all remaining results
|
87
|
-
# are retrieved. (Unlike `#each`, for example, which merely iterates
|
88
|
-
# over the results returned by a single API call.) Use with caution.
|
89
|
-
#
|
90
|
-
# @param [Integer] request_limit The upper limit of API requests to
|
91
|
-
# make to load all topics. Default is no limit.
|
92
|
-
# @yield [topic] The block for accessing each topic.
|
93
|
-
# @yieldparam [Topic] topic The topic object.
|
94
|
-
#
|
95
|
-
# @return [Enumerator]
|
96
|
-
#
|
97
|
-
# @example Iterating each topic by passing a block:
|
98
|
-
# require "google/cloud/pubsub"
|
99
|
-
#
|
100
|
-
# pubsub = Google::Cloud::PubSub.new
|
101
|
-
#
|
102
|
-
# topics = pubsub.topics
|
103
|
-
# topics.all do |topic|
|
104
|
-
# puts topic.name
|
105
|
-
# end
|
106
|
-
#
|
107
|
-
# @example Using the enumerator by not passing a block:
|
108
|
-
# require "google/cloud/pubsub"
|
109
|
-
#
|
110
|
-
# pubsub = Google::Cloud::PubSub.new
|
111
|
-
#
|
112
|
-
# topics = pubsub.topics
|
113
|
-
# all_names = topics.all.map do |topic|
|
114
|
-
# topic.name
|
115
|
-
# end
|
116
|
-
#
|
117
|
-
# @example Limit the number of API calls made:
|
118
|
-
# require "google/cloud/pubsub"
|
119
|
-
#
|
120
|
-
# pubsub = Google::Cloud::PubSub.new
|
121
|
-
#
|
122
|
-
# topics = pubsub.topics
|
123
|
-
# topics.all(request_limit: 10) do |topic|
|
124
|
-
# puts topic.name
|
125
|
-
# end
|
126
|
-
#
|
127
|
-
def all request_limit: nil, &block
|
128
|
-
request_limit = request_limit.to_i if request_limit
|
129
|
-
return enum_for :all, request_limit: request_limit unless block_given?
|
130
|
-
results = self
|
131
|
-
loop do
|
132
|
-
results.each(&block)
|
133
|
-
if request_limit
|
134
|
-
request_limit -= 1
|
135
|
-
break if request_limit.negative?
|
136
|
-
end
|
137
|
-
break unless results.next?
|
138
|
-
results = results.next
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
##
|
143
|
-
# @private New Topic::List from a
|
144
|
-
# Google::Cloud::PubSub::V1::ListTopicsResponse object.
|
145
|
-
def self.from_grpc grpc_list, service, max = nil
|
146
|
-
topics = new(Array(grpc_list.topics).map do |grpc|
|
147
|
-
Topic.from_grpc grpc, service
|
148
|
-
end)
|
149
|
-
token = grpc_list.next_page_token
|
150
|
-
token = nil if token == "".freeze
|
151
|
-
topics.instance_variable_set :@token, token
|
152
|
-
topics.instance_variable_set :@service, service
|
153
|
-
topics.instance_variable_set :@max, max
|
154
|
-
topics
|
155
|
-
end
|
156
|
-
|
157
|
-
protected
|
158
|
-
|
159
|
-
##
|
160
|
-
# @private Raise an error unless an active connection to the service
|
161
|
-
# is available.
|
162
|
-
def ensure_service!
|
163
|
-
raise "Must have active connection to service" unless @service
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
Pubsub = PubSub unless const_defined? :Pubsub
|
170
|
-
end
|
171
|
-
end
|