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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35406261c37aa5be658be4550f8d2690b8d754df
4
- data.tar.gz: 5e3d49644b0a180152d84b24964ac49bd957bd9e
3
+ metadata.gz: e657a0b10ebce1330b9195f68b30b936eb99d554
4
+ data.tar.gz: 71b758294f17f45e75c13a10dcec95cf5e2930a5
5
5
  SHA512:
6
- metadata.gz: dd7022c51c0c34af0fb1f702e41666077ded9c1a0f50b450158544da3ac262d1e9042d777f8d6252d1451a4182ecb69bb825445a493af4557cb531edd2826885
7
- data.tar.gz: 92d0aa01b83f364c0a4b811df450ef6da7c092ec6511c00fac766f4812d22ae67d6ed598c6e9de6d8ceef799972b1d3a0fc27462df97f27ac25e7463fbfa14ca
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
@@ -0,0 +1,3 @@
1
+ class GooglePubsubEnhancer::Middleware::Logger
2
+ require_relative "logger/duration"
3
+ end
@@ -1,4 +1,4 @@
1
- class GooglePubsubEnhancer::Publisher
1
+ class GooglePubsubEnhancer::Middleware::Publisher
2
2
 
3
3
  def initialize(app, opts={})
4
4
  @app = app
@@ -0,0 +1,4 @@
1
+ class GooglePubsubEnhancer::Middleware
2
+ require_relative 'middleware/logger'
3
+ require_relative 'middleware/publisher'
4
+ end
@@ -1,3 +1,3 @@
1
1
  class GooglePubsubEnhancer
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -3,7 +3,9 @@ require 'middleware'
3
3
  require 'google/cloud/pubsub'
4
4
 
5
5
  class GooglePubsubEnhancer
6
- require 'google_pubsub_enhancer/publisher'
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.3
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-27 00:00:00.000000000 Z
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/publisher.rb
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: