gcpc-interceptors 0.0.1 → 0.0.2
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/Gemfile.lock +12 -12
- data/README.md +2 -2
- data/lib/gcpc/interceptors/subscriber/decode_interceptor.rb +20 -3
- data/lib/gcpc/interceptors/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7a246c860601cbce4eb3f8b88d0219aaeecc73b9abf9f1dd2b968dd8f5fc3cd
|
4
|
+
data.tar.gz: fc1c11399d6e4e8275dbeea6451f657f60318b840c4485775533ec9bed6dfe53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51800714d63e6858ba698b3a0c195926b30dba979b29ab9be1e0abc19958d6c8b006772aa84622b302b03a271448af18775aef1b2384b95c911cee428f7b5967
|
7
|
+
data.tar.gz: 40abd794fd9629468cf0c2294d41287eca844a9ecca8c7d3eda20a22c2e63939eefd8bd861de711afbd24789632ff07abf685c53eae31f00096ebc7af9168174
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gcpc-interceptors (0.0.
|
4
|
+
gcpc-interceptors (0.0.2)
|
5
5
|
gcpc
|
6
6
|
|
7
7
|
GEM
|
@@ -14,25 +14,25 @@ GEM
|
|
14
14
|
diff-lcs (1.3)
|
15
15
|
faraday (0.15.4)
|
16
16
|
multipart-post (>= 1.2, < 3)
|
17
|
-
gcpc (0.0.
|
18
|
-
google-cloud-pubsub
|
17
|
+
gcpc (0.0.4)
|
18
|
+
google-cloud-pubsub
|
19
19
|
google-cloud-core (1.3.0)
|
20
20
|
google-cloud-env (~> 1.0)
|
21
|
-
google-cloud-env (1.0
|
21
|
+
google-cloud-env (1.2.0)
|
22
22
|
faraday (~> 0.11)
|
23
|
-
google-cloud-pubsub (0.
|
24
|
-
concurrent-ruby (~> 1.
|
23
|
+
google-cloud-pubsub (0.37.0)
|
24
|
+
concurrent-ruby (~> 1.1)
|
25
25
|
google-cloud-core (~> 1.2)
|
26
26
|
google-gax (~> 1.3)
|
27
27
|
googleapis-common-protos (>= 1.3.9, < 2.0)
|
28
28
|
grpc-google-iam-v1 (~> 0.6.9)
|
29
|
-
google-gax (1.
|
29
|
+
google-gax (1.7.0)
|
30
30
|
google-protobuf (~> 3.2)
|
31
31
|
googleapis-common-protos (>= 1.3.5, < 2.0)
|
32
32
|
googleauth (>= 0.6.2, < 0.10.0)
|
33
33
|
grpc (>= 1.7.2, < 2.0)
|
34
34
|
rly (~> 0.2.3)
|
35
|
-
google-protobuf (3.
|
35
|
+
google-protobuf (3.8.0)
|
36
36
|
googleapis-common-protos (1.3.9)
|
37
37
|
google-protobuf (~> 3.0)
|
38
38
|
googleapis-common-protos-types (~> 1.0)
|
@@ -46,13 +46,13 @@ GEM
|
|
46
46
|
multi_json (~> 1.11)
|
47
47
|
os (>= 0.9, < 2.0)
|
48
48
|
signet (~> 0.7)
|
49
|
-
grpc (1.
|
49
|
+
grpc (1.21.0)
|
50
50
|
google-protobuf (~> 3.7)
|
51
|
-
googleapis-common-protos-types (~> 1.0
|
51
|
+
googleapis-common-protos-types (~> 1.0)
|
52
52
|
grpc-google-iam-v1 (0.6.9)
|
53
53
|
googleapis-common-protos (>= 1.3.1, < 2.0)
|
54
54
|
grpc (~> 1.0)
|
55
|
-
jwt (2.1
|
55
|
+
jwt (2.2.1)
|
56
56
|
memoist (0.16.0)
|
57
57
|
method_source (0.9.2)
|
58
58
|
mock_redis (0.20.0)
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
pry (0.12.2)
|
63
63
|
coderay (~> 1.1.0)
|
64
64
|
method_source (~> 0.9.0)
|
65
|
-
public_suffix (3.1.
|
65
|
+
public_suffix (3.1.1)
|
66
66
|
rake (10.5.0)
|
67
67
|
rly (0.2.3)
|
68
68
|
rspec (3.8.0)
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
require "gcpc"
|
27
|
-
require "gcpc
|
27
|
+
require "gcpc/interceptors"
|
28
28
|
|
29
29
|
publisher = Gcpc::Publisher.new(
|
30
30
|
project_id: "project-example-1",
|
@@ -51,7 +51,7 @@ publisher.publish(jsondata, attributes) # published as `{"key":"value"}`, {"pub
|
|
51
51
|
|
52
52
|
```ruby
|
53
53
|
require "gcpc"
|
54
|
-
require "gcpc
|
54
|
+
require "gcpc/interceptors"
|
55
55
|
|
56
56
|
class LogHandler < Gcpc::Subscriber::BaseHandler
|
57
57
|
LOGGER = Logger.new(STDOUT)
|
@@ -19,8 +19,12 @@ module Gcpc
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# @param [BaseStrategy] strategy
|
22
|
-
|
23
|
-
|
22
|
+
# @param [Logger] logger
|
23
|
+
# @param [Boolean] ignore_on_error Ignore the message when decode failed
|
24
|
+
def initialize(strategy:, logger: Logger.new(STDOUT), ignore_on_error: true)
|
25
|
+
@strategy = strategy
|
26
|
+
@logger = logger
|
27
|
+
@ignore_on_error = ignore_on_error
|
24
28
|
end
|
25
29
|
|
26
30
|
# @param [String] data
|
@@ -28,7 +32,20 @@ module Gcpc
|
|
28
32
|
# @param [Google::Cloud::Pubsub::ReceivedMessage] message
|
29
33
|
# @param [Proc] block
|
30
34
|
def handle(data, attributes, message, &block)
|
31
|
-
|
35
|
+
begin
|
36
|
+
m = @strategy.decode(data, attributes, message)
|
37
|
+
rescue => e
|
38
|
+
@logger.error(e)
|
39
|
+
|
40
|
+
if @ignore_on_error
|
41
|
+
@logger.info("Ack a message{data=#{message.data}, attributes=#{message.attributes}} because it can't be decoded!")
|
42
|
+
message.ack! # Ack immediately if decode failed
|
43
|
+
return
|
44
|
+
else
|
45
|
+
raise e
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
32
49
|
yield m, attributes, message
|
33
50
|
end
|
34
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gcpc-interceptors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nao Minami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|