gcpc-interceptors 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d912277cfed4f48ca432e81df7009dab03fe82ec588ef16caa335bbf152e55aa
4
- data.tar.gz: cc61dfbae21ee3aba534c9da50f933993520040152483fd8c4b954e056bfb3b3
3
+ metadata.gz: e7a246c860601cbce4eb3f8b88d0219aaeecc73b9abf9f1dd2b968dd8f5fc3cd
4
+ data.tar.gz: fc1c11399d6e4e8275dbeea6451f657f60318b840c4485775533ec9bed6dfe53
5
5
  SHA512:
6
- metadata.gz: 1d1603e37ddd88dfff50ae5274a32212261c69ea69567efc50e1281c5ebce6ce8832b6caede36d9455334a190206993176b6244b342435ade05a41532f041768
7
- data.tar.gz: 77c336c0bd1ca8a1c0485250f0bad572fd33db2194a7bda0d3dd33e271949a2a84e1e9163e11aed945dd86bd202b11f903b47be4fcc81e794050b679a2fe3252
6
+ metadata.gz: 51800714d63e6858ba698b3a0c195926b30dba979b29ab9be1e0abc19958d6c8b006772aa84622b302b03a271448af18775aef1b2384b95c911cee428f7b5967
7
+ data.tar.gz: 40abd794fd9629468cf0c2294d41287eca844a9ecca8c7d3eda20a22c2e63939eefd8bd861de711afbd24789632ff07abf685c53eae31f00096ebc7af9168174
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gcpc-interceptors (0.0.1)
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.3)
18
- google-cloud-pubsub (~> 0.34)
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.5)
21
+ google-cloud-env (1.2.0)
22
22
  faraday (~> 0.11)
23
- google-cloud-pubsub (0.36.0)
24
- concurrent-ruby (~> 1.0)
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.5.0)
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.7.1)
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.20.0)
49
+ grpc (1.21.0)
50
50
  google-protobuf (~> 3.7)
51
- googleapis-common-protos-types (~> 1.0.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.0)
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.0)
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-interceptors"
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-interceptors"
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
- def initialize(strategy:)
23
- @strategy = strategy
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
- m = @strategy.decode(data, attributes, message)
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
@@ -1,5 +1,5 @@
1
1
  module Gcpc
2
2
  module Interceptors
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  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.1
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-06 00:00:00.000000000 Z
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler