stenotype 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9da486b9bc096f52bf0b4f81526d5d4922e0fa10a05141e28f2f55154c41cf3b
4
- data.tar.gz: 2ef09f562429fded9c425086714985ef61736e458c9b111aeeb124d9e276f6db
3
+ metadata.gz: 78f28a1322b09dc099de1351779e15e67247ad5010c907b0cf99efb05e9c3ca4
4
+ data.tar.gz: 949901992d1c976941ca306154f546292bbd7f0df0bcb21a27a4458daa0dcd59
5
5
  SHA512:
6
- metadata.gz: 8db324c94a6d1fdbf2d692df8ae87dca43ede513a1df59e3ba0db91eaa0b2dd4e44ac7f5e7a4c52893049ca1181da61b9a32cca69312693115cc788eb2230125
7
- data.tar.gz: 45292456af9acee8382436aa02452512bd29f7f40c1033f0a548a6b01fe12a6a8d78dd42a20193755a904a1837bf7ecd4831676a7f42aa4cae7b6bab4af7c1f4
6
+ metadata.gz: 18e3d0ea81fc68afbe99cf5da1569e2c87c1819c30430fcc1f23c23b6cb201767cf35885d7d2a643ac3bf284b8ee00d5e26644a08ab0ace902b863fff4f0527e
7
+ data.tar.gz: 63a868b627122e6c46f6b920b6b237f2fa7c88c1827ef7946e226868644a80e43a0c4c9a89e66dfec4909ca54bc53cc7b5c534bf8a9972621016521ffb1faeab
data/CHANGELOG.md CHANGED
@@ -1,9 +1,15 @@
1
1
  # Changelog
2
2
 
3
- *Release Date*: 2020/01/10
3
+ *Release Date*: 2020/01/13
4
4
 
5
- ### 0.1.3: 2020/01/10
5
+ ### 0.1.5 2020/01/13
6
+ * In case `graceful_error_handling` is set to off raise a generic `Stenotype::Error` on any exception in order to intercept a single error type in the client code.
7
+ * Adds an `at_exit` hook to flush the async message queue when using the library in async mode.
8
+
9
+ ### 0.1.4 2020/01/10
6
10
  * Adds a new configuration option `graceful_error_handling` to suppress errors raised from the gem's internals yet logging the error to specified `config.logger`
11
+
12
+ ### 0.1.3: 2020/01/10
7
13
  * Adds a new configuration option `logger` to use during error handling
8
14
  * Adds a new config option `Stenotype.config.enabled`. If the option is set to false then event is not going to be published. The option is `true` by default.
9
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stenotype (0.1.4)
4
+ stenotype (0.1.3)
5
5
  activesupport (>= 5.0.0)
6
6
  google-cloud-pubsub (~> 1.0.0)
7
7
  spicery (>= 0.19.0, < 1.0)
@@ -96,7 +96,7 @@ GEM
96
96
  googleauth (~> 0.9)
97
97
  grpc (~> 1.24)
98
98
  rly (~> 0.2.3)
99
- google-protobuf (3.11.1-universal-darwin)
99
+ google-protobuf (3.11.1)
100
100
  googleapis-common-protos (1.3.9)
101
101
  google-protobuf (~> 3.0)
102
102
  googleapis-common-protos-types (~> 1.0)
@@ -110,7 +110,7 @@ GEM
110
110
  multi_json (~> 1.11)
111
111
  os (>= 0.9, < 2.0)
112
112
  signet (~> 0.12)
113
- grpc (1.25.0-universal-darwin)
113
+ grpc (1.25.0)
114
114
  google-protobuf (~> 3.8)
115
115
  googleapis-common-protos-types (~> 1.0)
116
116
  grpc-google-iam-v1 (0.6.9)
@@ -35,12 +35,25 @@ module Stenotype
35
35
  #
36
36
  # This method is expected to be implemented by subclasses
37
37
  # @abstract
38
- # @raise [NotImplementedError] unless implemented in a subclass
38
+ # @raise {NotImplementedError} unless implemented in a subclass
39
39
  #
40
40
  def publish(_event_data, **_additional_attrs)
41
41
  raise NotImplementedError,
42
42
  "#{self.class.name} must implement method #publish"
43
43
  end
44
+
45
+ #
46
+ # This method is expected to be implemented by subclasses. In case async
47
+ # publisher is used the process might end before the async queue of
48
+ # messages is processed, so this method is going to be used in a
49
+ # `at_exit` hook to flush the queue.
50
+ # @abstract
51
+ # @raise {NotImplementedError} unless implemented in a subclass
52
+ #
53
+ def flush!
54
+ raise NotImplementedError,
55
+ "#{self.class.name} must implement method #flush"
56
+ end
44
57
  end
45
58
  end
46
59
  end
@@ -56,6 +56,16 @@ module Stenotype
56
56
  end
57
57
  end
58
58
 
59
+ #
60
+ # Flushes the topic's async queue
61
+ #
62
+ def flush!
63
+ # a publisher might be uninitialized until the first event is published
64
+ return unless topic.async_publisher
65
+
66
+ topic.async_publisher.stop.wait!
67
+ end
68
+
59
69
  private
60
70
 
61
71
  def publish_sync(event_data, **additional_attrs)
@@ -40,6 +40,13 @@ module Stenotype
40
40
  end
41
41
  end
42
42
 
43
+ #
44
+ # Does nothing
45
+ #
46
+ def flush!
47
+ # noop
48
+ end
49
+
43
50
  private
44
51
 
45
52
  def client
@@ -0,0 +1,8 @@
1
+ require 'stenotype'
2
+
3
+ # :nocov:
4
+ at_exit do
5
+ targets = Stenotype.config.targets
6
+ targets.each(&:flush!)
7
+ end
8
+ # :nocov:
@@ -31,7 +31,7 @@ module Stenotype
31
31
  #
32
32
  Stenotype::Configuration.logger.error(error)
33
33
 
34
- raise unless Stenotype.config.graceful_error_handling
34
+ raise Stenotype::Error unless Stenotype.config.graceful_error_handling
35
35
  end
36
36
  end
37
37
 
@@ -75,7 +75,7 @@ module Stenotype
75
75
  #
76
76
  Stenotype::Configuration.logger.error(error)
77
77
 
78
- raise unless Stenotype.config.graceful_error_handling
78
+ raise Stenotype::Error unless Stenotype.config.graceful_error_handling
79
79
  end
80
80
  end
81
81
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Stenotype
4
4
  # :nodoc:
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.5"
6
6
  # :nodoc:
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stenotype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Kapitonov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-10 00:00:00.000000000 Z
11
+ date: 2020-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -267,6 +267,7 @@ files:
267
267
  - lib/stenotype/adapters/base.rb
268
268
  - lib/stenotype/adapters/google_cloud.rb
269
269
  - lib/stenotype/adapters/stdout_adapter.rb
270
+ - lib/stenotype/at_exit.rb
270
271
  - lib/stenotype/configuration.rb
271
272
  - lib/stenotype/context_handlers.rb
272
273
  - lib/stenotype/context_handlers/base.rb