google-pubsub-enhancer 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/google_pubsub_enhancer/constants.rb +8 -0
- data/lib/google_pubsub_enhancer/version.rb +1 -1
- data/lib/google_pubsub_enhancer.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dc8568d671d6eab7c897c473d88ac3b650a144d
|
4
|
+
data.tar.gz: 37a518956fae4794e141190ecac3d7794916201e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 149e0d2cc061f5c8ac057701df1ab148f0c443025716811a0605daedcd580d9eb5d9f5de9048335ccf26a3cc19ffb908ad637b15d715135bf5d97eb2a488b5e1
|
7
|
+
data.tar.gz: f9c3cd8304cafc902d7fde8cfb4c217f25b4804f33d138f692dd0034decaf4256288a528cd9444c7e0b08d3206c77b0cf66bb9513fadf04898af9e163e9b047f
|
data/README.md
CHANGED
@@ -38,6 +38,10 @@ app.run(subscription_name)
|
|
38
38
|
|
39
39
|
```
|
40
40
|
|
41
|
+
## ENV
|
42
|
+
|
43
|
+
To configure how much message should be pulled, use the GOOGLE_PUBSUB_ENHANCER_MAX_PULL_SIZE env variable with an integer value
|
44
|
+
|
41
45
|
## Development
|
42
46
|
|
43
47
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module GooglePubsubEnhancer::Constants
|
2
|
+
MAX_PULL_SIZE = proc do
|
3
|
+
user_defined = ::ENV['GOOGLE_PUBSUB_ENHANCER_MAX_PULL_SIZE']
|
4
|
+
pull_size = (user_defined || 100).to_i
|
5
|
+
raise('GOOGLE_PUBSUB_ENHANCER_MAX_PULL_SIZE') if pull_size == 0
|
6
|
+
pull_size
|
7
|
+
end.call.freeze
|
8
|
+
end
|
@@ -4,6 +4,7 @@ require 'google/cloud/pubsub'
|
|
4
4
|
|
5
5
|
class GooglePubsubEnhancer
|
6
6
|
|
7
|
+
require_relative 'google_pubsub_enhancer/constants'
|
7
8
|
require_relative 'google_pubsub_enhancer/middleware'
|
8
9
|
|
9
10
|
class << self
|
@@ -33,7 +34,7 @@ class GooglePubsubEnhancer
|
|
33
34
|
private
|
34
35
|
|
35
36
|
def work(subscription, opts)
|
36
|
-
while received_messages = subscription.pull
|
37
|
+
while received_messages = subscription.pull(:max => GooglePubsubEnhancer::Constants::MAX_PULL_SIZE)
|
37
38
|
break if opts[:shutdown].call || received_messages == nil
|
38
39
|
next if received_messages.empty?
|
39
40
|
@stack.call({received_messages: received_messages})
|
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.5
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- bin/setup
|
100
100
|
- google-pubsub-enhancer.gemspec
|
101
101
|
- lib/google_pubsub_enhancer.rb
|
102
|
+
- lib/google_pubsub_enhancer/constants.rb
|
102
103
|
- lib/google_pubsub_enhancer/middleware.rb
|
103
104
|
- lib/google_pubsub_enhancer/middleware/logger.rb
|
104
105
|
- lib/google_pubsub_enhancer/middleware/logger/duration.rb
|