google-cloud-pubsub 0.26.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. data/.yardopts +12 -2
  3. data/AUTHENTICATION.md +178 -0
  4. data/CHANGELOG.md +659 -0
  5. data/CODE_OF_CONDUCT.md +40 -0
  6. data/CONTRIBUTING.md +187 -0
  7. data/EMULATOR.md +37 -0
  8. data/LICENSE +2 -2
  9. data/LOGGING.md +32 -0
  10. data/OVERVIEW.md +528 -0
  11. data/TROUBLESHOOTING.md +31 -0
  12. data/lib/google/cloud/pubsub/async_publisher/batch.rb +310 -0
  13. data/lib/google/cloud/pubsub/async_publisher.rb +402 -0
  14. data/lib/google/cloud/pubsub/batch_publisher.rb +100 -0
  15. data/lib/google/cloud/pubsub/convert.rb +91 -0
  16. data/lib/google/cloud/pubsub/credentials.rb +26 -10
  17. data/lib/google/cloud/pubsub/errors.rb +85 -0
  18. data/lib/google/cloud/pubsub/message.rb +80 -17
  19. data/lib/google/cloud/pubsub/policy.rb +17 -14
  20. data/lib/google/cloud/pubsub/project.rb +364 -250
  21. data/lib/google/cloud/pubsub/publish_result.rb +103 -0
  22. data/lib/google/cloud/pubsub/received_message.rb +162 -24
  23. data/lib/google/cloud/pubsub/retry_policy.rb +88 -0
  24. data/lib/google/cloud/pubsub/schema/list.rb +180 -0
  25. data/lib/google/cloud/pubsub/schema.rb +310 -0
  26. data/lib/google/cloud/pubsub/service.rb +281 -265
  27. data/lib/google/cloud/pubsub/snapshot/list.rb +21 -21
  28. data/lib/google/cloud/pubsub/snapshot.rb +55 -15
  29. data/lib/google/cloud/pubsub/subscriber/enumerator_queue.rb +54 -0
  30. data/lib/google/cloud/pubsub/subscriber/inventory.rb +173 -0
  31. data/lib/google/cloud/pubsub/subscriber/sequencer.rb +115 -0
  32. data/lib/google/cloud/pubsub/subscriber/stream.rb +400 -0
  33. data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +230 -0
  34. data/lib/google/cloud/pubsub/subscriber.rb +417 -0
  35. data/lib/google/cloud/pubsub/subscription/list.rb +28 -28
  36. data/lib/google/cloud/pubsub/subscription/push_config.rb +268 -0
  37. data/lib/google/cloud/pubsub/subscription.rb +900 -172
  38. data/lib/google/cloud/pubsub/topic/list.rb +21 -21
  39. data/lib/google/cloud/pubsub/topic.rb +674 -95
  40. data/lib/google/cloud/pubsub/version.rb +6 -4
  41. data/lib/google/cloud/pubsub.rb +104 -439
  42. data/lib/google-cloud-pubsub.rb +60 -29
  43. metadata +88 -50
  44. data/README.md +0 -69
  45. data/lib/google/cloud/pubsub/topic/publisher.rb +0 -86
  46. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -77
  47. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -223
  48. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -81
  49. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -503
  50. data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -605
  51. data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -96
  52. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1104
  53. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -127
  54. data/lib/google/cloud/pubsub/v1.rb +0 -17
  55. data/lib/google/pubsub/v1/pubsub_pb.rb +0 -187
  56. data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -159
@@ -1,86 +0,0 @@
1
- # Copyright 2015 Google Inc. All rights reserved.
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
- # http://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
- module Google
17
- module Cloud
18
- module Pubsub
19
- class Topic
20
- ##
21
- # Topic Publisher object used to publish multiple messages at once.
22
- #
23
- # @example
24
- # require "google/cloud/pubsub"
25
- #
26
- # pubsub = Google::Cloud::Pubsub.new
27
- #
28
- # topic = pubsub.topic "my-topic"
29
- # msgs = topic.publish do |t|
30
- # t.publish "task 1 completed", foo: :bar
31
- # t.publish "task 2 completed", foo: :baz
32
- # t.publish "task 3 completed", foo: :bif
33
- # end
34
- class Publisher
35
- ##
36
- # @private The messages to publish
37
- attr_reader :messages
38
-
39
- ##
40
- # @private Create a new instance of the object.
41
- def initialize data = nil, attributes = {}
42
- @messages = []
43
- @mode = :batch
44
- return if data.nil?
45
- @mode = :single
46
- publish data, attributes
47
- end
48
-
49
- ##
50
- # Add multiple messages to the topic.
51
- # All messages added will be published at once.
52
- # See {Google::Cloud::Pubsub::Topic#publish}
53
- def publish data, attributes = {}
54
- # Convert IO-ish objects to strings
55
- if data.respond_to?(:read) && data.respond_to?(:rewind)
56
- data.rewind
57
- data = data.read
58
- end
59
- # Convert data to encoded byte array to match the protobuf defn
60
- data = String(data).force_encoding("ASCII-8BIT")
61
- # Convert attributes to strings to match the protobuf definition
62
- attributes = Hash[attributes.map { |k, v| [String(k), String(v)] }]
63
- @messages << [data, attributes]
64
- end
65
-
66
- ##
67
- # @private Create Message objects with message ids.
68
- def to_gcloud_messages message_ids
69
- msgs = @messages.zip(Array(message_ids)).map do |arr, id|
70
- Message.from_grpc(
71
- Google::Pubsub::V1::PubsubMessage.new(
72
- data: arr[0], attributes: arr[1], message_id: id))
73
- end
74
- # Return just one Message if a single publish,
75
- # otherwise return the array of Messages.
76
- if @mode == :single && msgs.count <= 1
77
- msgs.first
78
- else
79
- msgs
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end
86
- end
@@ -1,77 +0,0 @@
1
- # Copyright 2017, Google Inc. All rights reserved.
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
- # http://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
- module Google
16
- module Protobuf
17
- # A Duration represents a signed, fixed-length span of time represented
18
- # as a count of seconds and fractions of seconds at nanosecond
19
- # resolution. It is independent of any calendar and concepts like "day"
20
- # or "month". It is related to Timestamp in that the difference between
21
- # two Timestamp values is a Duration and it can be added or subtracted
22
- # from a Timestamp. Range is approximately +-10,000 years.
23
- #
24
- # Example 1: Compute Duration from two Timestamps in pseudo code.
25
- #
26
- # Timestamp start = ...;
27
- # Timestamp end = ...;
28
- # Duration duration = ...;
29
- #
30
- # duration.seconds = end.seconds - start.seconds;
31
- # duration.nanos = end.nanos - start.nanos;
32
- #
33
- # if (duration.seconds < 0 && duration.nanos > 0) {
34
- # duration.seconds += 1;
35
- # duration.nanos -= 1000000000;
36
- # } else if (durations.seconds > 0 && duration.nanos < 0) {
37
- # duration.seconds -= 1;
38
- # duration.nanos += 1000000000;
39
- # }
40
- #
41
- # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
42
- #
43
- # Timestamp start = ...;
44
- # Duration duration = ...;
45
- # Timestamp end = ...;
46
- #
47
- # end.seconds = start.seconds + duration.seconds;
48
- # end.nanos = start.nanos + duration.nanos;
49
- #
50
- # if (end.nanos < 0) {
51
- # end.seconds -= 1;
52
- # end.nanos += 1000000000;
53
- # } else if (end.nanos >= 1000000000) {
54
- # end.seconds += 1;
55
- # end.nanos -= 1000000000;
56
- # }
57
- #
58
- # Example 3: Compute Duration from datetime.timedelta in Python.
59
- #
60
- # td = datetime.timedelta(days=3, minutes=10)
61
- # duration = Duration()
62
- # duration.FromTimedelta(td)
63
- # @!attribute [rw] seconds
64
- # @return [Integer]
65
- # Signed seconds of the span of time. Must be from -315,576,000,000
66
- # to +315,576,000,000 inclusive.
67
- # @!attribute [rw] nanos
68
- # @return [Integer]
69
- # Signed fractions of a second at nanosecond resolution of the span
70
- # of time. Durations less than one second are represented with a 0
71
- # +seconds+ field and a positive or negative +nanos+ field. For durations
72
- # of one second or more, a non-zero value for the +nanos+ field must be
73
- # of the same sign as the +seconds+ field. Must be from -999,999,999
74
- # to +999,999,999 inclusive.
75
- class Duration; end
76
- end
77
- end
@@ -1,223 +0,0 @@
1
- # Copyright 2017, Google Inc. All rights reserved.
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
- # http://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
- module Google
16
- module Protobuf
17
- # +FieldMask+ represents a set of symbolic field paths, for example:
18
- #
19
- # paths: "f.a"
20
- # paths: "f.b.d"
21
- #
22
- # Here +f+ represents a field in some root message, +a+ and +b+
23
- # fields in the message found in +f+, and +d+ a field found in the
24
- # message in +f.b+.
25
- #
26
- # Field masks are used to specify a subset of fields that should be
27
- # returned by a get operation or modified by an update operation.
28
- # Field masks also have a custom JSON encoding (see below).
29
- #
30
- # = Field Masks in Projections
31
- #
32
- # When used in the context of a projection, a response message or
33
- # sub-message is filtered by the API to only contain those fields as
34
- # specified in the mask. For example, if the mask in the previous
35
- # example is applied to a response message as follows:
36
- #
37
- # f {
38
- # a : 22
39
- # b {
40
- # d : 1
41
- # x : 2
42
- # }
43
- # y : 13
44
- # }
45
- # z: 8
46
- #
47
- # The result will not contain specific values for fields x,y and z
48
- # (their value will be set to the default, and omitted in proto text
49
- # output):
50
- #
51
- #
52
- # f {
53
- # a : 22
54
- # b {
55
- # d : 1
56
- # }
57
- # }
58
- #
59
- # A repeated field is not allowed except at the last position of a
60
- # paths string.
61
- #
62
- # If a FieldMask object is not present in a get operation, the
63
- # operation applies to all fields (as if a FieldMask of all fields
64
- # had been specified).
65
- #
66
- # Note that a field mask does not necessarily apply to the
67
- # top-level response message. In case of a REST get operation, the
68
- # field mask applies directly to the response, but in case of a REST
69
- # list operation, the mask instead applies to each individual message
70
- # in the returned resource list. In case of a REST custom method,
71
- # other definitions may be used. Where the mask applies will be
72
- # clearly documented together with its declaration in the API. In
73
- # any case, the effect on the returned resource/resources is required
74
- # behavior for APIs.
75
- #
76
- # = Field Masks in Update Operations
77
- #
78
- # A field mask in update operations specifies which fields of the
79
- # targeted resource are going to be updated. The API is required
80
- # to only change the values of the fields as specified in the mask
81
- # and leave the others untouched. If a resource is passed in to
82
- # describe the updated values, the API ignores the values of all
83
- # fields not covered by the mask.
84
- #
85
- # If a repeated field is specified for an update operation, the existing
86
- # repeated values in the target resource will be overwritten by the new values.
87
- # Note that a repeated field is only allowed in the last position of a +paths+
88
- # string.
89
- #
90
- # If a sub-message is specified in the last position of the field mask for an
91
- # update operation, then the existing sub-message in the target resource is
92
- # overwritten. Given the target message:
93
- #
94
- # f {
95
- # b {
96
- # d : 1
97
- # x : 2
98
- # }
99
- # c : 1
100
- # }
101
- #
102
- # And an update message:
103
- #
104
- # f {
105
- # b {
106
- # d : 10
107
- # }
108
- # }
109
- #
110
- # then if the field mask is:
111
- #
112
- # paths: "f.b"
113
- #
114
- # then the result will be:
115
- #
116
- # f {
117
- # b {
118
- # d : 10
119
- # }
120
- # c : 1
121
- # }
122
- #
123
- # However, if the update mask was:
124
- #
125
- # paths: "f.b.d"
126
- #
127
- # then the result would be:
128
- #
129
- # f {
130
- # b {
131
- # d : 10
132
- # x : 2
133
- # }
134
- # c : 1
135
- # }
136
- #
137
- # In order to reset a field's value to the default, the field must
138
- # be in the mask and set to the default value in the provided resource.
139
- # Hence, in order to reset all fields of a resource, provide a default
140
- # instance of the resource and set all fields in the mask, or do
141
- # not provide a mask as described below.
142
- #
143
- # If a field mask is not present on update, the operation applies to
144
- # all fields (as if a field mask of all fields has been specified).
145
- # Note that in the presence of schema evolution, this may mean that
146
- # fields the client does not know and has therefore not filled into
147
- # the request will be reset to their default. If this is unwanted
148
- # behavior, a specific service may require a client to always specify
149
- # a field mask, producing an error if not.
150
- #
151
- # As with get operations, the location of the resource which
152
- # describes the updated values in the request message depends on the
153
- # operation kind. In any case, the effect of the field mask is
154
- # required to be honored by the API.
155
- #
156
- # == Considerations for HTTP REST
157
- #
158
- # The HTTP kind of an update operation which uses a field mask must
159
- # be set to PATCH instead of PUT in order to satisfy HTTP semantics
160
- # (PUT must only be used for full updates).
161
- #
162
- # = JSON Encoding of Field Masks
163
- #
164
- # In JSON, a field mask is encoded as a single string where paths are
165
- # separated by a comma. Fields name in each path are converted
166
- # to/from lower-camel naming conventions.
167
- #
168
- # As an example, consider the following message declarations:
169
- #
170
- # message Profile {
171
- # User user = 1;
172
- # Photo photo = 2;
173
- # }
174
- # message User {
175
- # string display_name = 1;
176
- # string address = 2;
177
- # }
178
- #
179
- # In proto a field mask for +Profile+ may look as such:
180
- #
181
- # mask {
182
- # paths: "user.display_name"
183
- # paths: "photo"
184
- # }
185
- #
186
- # In JSON, the same mask is represented as below:
187
- #
188
- # {
189
- # mask: "user.displayName,photo"
190
- # }
191
- #
192
- # = Field Masks and Oneof Fields
193
- #
194
- # Field masks treat fields in oneofs just as regular fields. Consider the
195
- # following message:
196
- #
197
- # message SampleMessage {
198
- # oneof test_oneof {
199
- # string name = 4;
200
- # SubMessage sub_message = 9;
201
- # }
202
- # }
203
- #
204
- # The field mask can be:
205
- #
206
- # mask {
207
- # paths: "name"
208
- # }
209
- #
210
- # Or:
211
- #
212
- # mask {
213
- # paths: "sub_message"
214
- # }
215
- #
216
- # Note that oneof type names ("test_oneof" in this case) cannot be used in
217
- # paths.
218
- # @!attribute [rw] paths
219
- # @return [Array<String>]
220
- # The set of field mask paths.
221
- class FieldMask; end
222
- end
223
- end
@@ -1,81 +0,0 @@
1
- # Copyright 2017, Google Inc. All rights reserved.
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
- # http://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
- module Google
16
- module Protobuf
17
- # A Timestamp represents a point in time independent of any time zone
18
- # or calendar, represented as seconds and fractions of seconds at
19
- # nanosecond resolution in UTC Epoch time. It is encoded using the
20
- # Proleptic Gregorian Calendar which extends the Gregorian calendar
21
- # backwards to year one. It is encoded assuming all minutes are 60
22
- # seconds long, i.e. leap seconds are "smeared" so that no leap second
23
- # table is needed for interpretation. Range is from
24
- # 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
25
- # By restricting to that range, we ensure that we can convert to
26
- # and from RFC 3339 date strings.
27
- # See {https://www.ietf.org/rfc/rfc3339.txt}[https://www.ietf.org/rfc/rfc3339.txt].
28
- #
29
- # Example 1: Compute Timestamp from POSIX +time()+.
30
- #
31
- # Timestamp timestamp;
32
- # timestamp.set_seconds(time(NULL));
33
- # timestamp.set_nanos(0);
34
- #
35
- # Example 2: Compute Timestamp from POSIX +gettimeofday()+.
36
- #
37
- # struct timeval tv;
38
- # gettimeofday(&tv, NULL);
39
- #
40
- # Timestamp timestamp;
41
- # timestamp.set_seconds(tv.tv_sec);
42
- # timestamp.set_nanos(tv.tv_usec * 1000);
43
- #
44
- # Example 3: Compute Timestamp from Win32 +GetSystemTimeAsFileTime()+.
45
- #
46
- # FILETIME ft;
47
- # GetSystemTimeAsFileTime(&ft);
48
- # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
49
- #
50
- # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
51
- # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
52
- # Timestamp timestamp;
53
- # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
54
- # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
55
- #
56
- # Example 4: Compute Timestamp from Java +System.currentTimeMillis()+.
57
- #
58
- # long millis = System.currentTimeMillis();
59
- #
60
- # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
61
- # .setNanos((int) ((millis % 1000) * 1000000)).build();
62
- #
63
- #
64
- # Example 5: Compute Timestamp from current time in Python.
65
- #
66
- # timestamp = Timestamp()
67
- # timestamp.GetCurrentTime()
68
- # @!attribute [rw] seconds
69
- # @return [Integer]
70
- # Represents seconds of UTC time since Unix epoch
71
- # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
72
- # 9999-12-31T23:59:59Z inclusive.
73
- # @!attribute [rw] nanos
74
- # @return [Integer]
75
- # Non-negative fractions of a second at nanosecond resolution. Negative
76
- # second values with fractions must still have non-negative nanos values
77
- # that count forward in time. Must be from 0 to 999,999,999
78
- # inclusive.
79
- class Timestamp; end
80
- end
81
- end