google-pubsub-enhancer 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google_pubsub_enhancer/middleware/logger/duration.rb +19 -0
- data/lib/google_pubsub_enhancer/middleware/logger.rb +3 -0
- data/lib/google_pubsub_enhancer/{publisher.rb → middleware/publisher.rb} +1 -1
- data/lib/google_pubsub_enhancer/middleware.rb +4 -0
- data/lib/google_pubsub_enhancer/version.rb +1 -1
- data/lib/google_pubsub_enhancer.rb +5 -3
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e657a0b10ebce1330b9195f68b30b936eb99d554
|
4
|
+
data.tar.gz: 71b758294f17f45e75c13a10dcec95cf5e2930a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c104c12e93ddba540095e3498d2a8fed9821906ebc3a41419e62f86203bf5cbb496c96fa1fe7404486a164de17d69a2affb97fa2066a23b4e4bd1cf6a1b8c402
|
7
|
+
data.tar.gz: ddd4ba14b6c55faf41330824c5231a56ce6faccedc25b7f57150c9fd77166b6bd67c984f2d00442161810e4b6db835d63c506e0b02d8531518b74763a49b7b60
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class GooglePubsubEnhancer::Middleware::Logger::Duration
|
2
|
+
|
3
|
+
def initialize(app,opts={},&substack)
|
4
|
+
@app = app
|
5
|
+
@logger = opts[:logger]
|
6
|
+
@log_severity = opts[:log_severity]
|
7
|
+
@substack = ::Middleware::Builder.new &substack
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
measure_started = Time.now
|
12
|
+
@substack.call(env)
|
13
|
+
measure_stopped = Time.now
|
14
|
+
@logger.send(@log_severity, "duration: #{measure_stopped - measure_started} sec")
|
15
|
+
@app.call(env)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
end
|
@@ -3,7 +3,9 @@ require 'middleware'
|
|
3
3
|
require 'google/cloud/pubsub'
|
4
4
|
|
5
5
|
class GooglePubsubEnhancer
|
6
|
-
|
6
|
+
|
7
|
+
require_relative 'google_pubsub_enhancer/middleware'
|
8
|
+
|
7
9
|
class << self
|
8
10
|
def name_by(type, name)
|
9
11
|
raise unless %w(topics subscriptions).include?(type)
|
@@ -17,7 +19,7 @@ class GooglePubsubEnhancer
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def initialize(&block)
|
20
|
-
@stack = Middleware::Builder.new(&block)
|
22
|
+
@stack = ::Middleware::Builder.new(&block)
|
21
23
|
end
|
22
24
|
|
23
25
|
def run(subscription_short_name, opts={})
|
@@ -35,7 +37,7 @@ class GooglePubsubEnhancer
|
|
35
37
|
break if opts[:shutdown].call || received_messages == nil
|
36
38
|
next if received_messages.empty?
|
37
39
|
@stack.call({received_messages: received_messages})
|
38
|
-
subscription.acknowledge(received_messages)
|
40
|
+
subscription.acknowledge(received_messages)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-pubsub-enhancer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bejczib
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,7 +99,10 @@ files:
|
|
99
99
|
- bin/setup
|
100
100
|
- google-pubsub-enhancer.gemspec
|
101
101
|
- lib/google_pubsub_enhancer.rb
|
102
|
-
- lib/google_pubsub_enhancer/
|
102
|
+
- lib/google_pubsub_enhancer/middleware.rb
|
103
|
+
- lib/google_pubsub_enhancer/middleware/logger.rb
|
104
|
+
- lib/google_pubsub_enhancer/middleware/logger/duration.rb
|
105
|
+
- lib/google_pubsub_enhancer/middleware/publisher.rb
|
103
106
|
- lib/google_pubsub_enhancer/version.rb
|
104
107
|
homepage: http://github.com/bejczib/google-pubsub-enhancer
|
105
108
|
licenses:
|