delivery_boy 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -2
- data/lib/delivery_boy.rb +12 -0
- data/lib/delivery_boy/railtie.rb +6 -3
- data/lib/delivery_boy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10f4720cca90b30f0b80e5374d359d62ae97eef7
|
4
|
+
data.tar.gz: 443f2c3e7d0a1299115cf3dd8c49ebf1dd7c6cf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f7e7d88d1f821f4aee82724852bf5218e335e8f46f8e8981ed8ed010deb40ed82cfab55c56eb3fc06099de9983f4e03c9279227745780c7ab1ef3bb1bfb7b44
|
7
|
+
data.tar.gz: e1d8ac3dfe2b11280ae372fc2cc5c1c36e03d2d0bf5a05458d86dd6752d5db3ff359826b25e909a86f9aee2a7c47321fb5e5639e2c6af3dd30ea792ae62292a4
|
data/README.md
CHANGED
@@ -59,9 +59,18 @@ end
|
|
59
59
|
|
60
60
|
In addition to improving response time, delivering messages asynchronously also protects your application against Kafka availability issues -- if messages cannot be delivered, they'll be buffered for later and retried automatically.
|
61
61
|
|
62
|
+
Both `deliver` and `deliver_async` take the following options:
|
63
|
+
|
64
|
+
* `topic` – the Kafka topic that should be written to (required).
|
65
|
+
* `key` – the key that should be set on the Kafka message (optional).
|
66
|
+
* `partition` – a specific partition number that should be written to (optional).
|
67
|
+
* `partition_key` – a string that can be used to deterministically select the partition that should be written to (optional).
|
68
|
+
|
69
|
+
Regarding `partition` and `partition_key`: if none are specified, DeliveryBoy will pick a partition at random. If you want to ensure that e.g. all messages related to a user always get written to the same partition, you can pass the user id to `partition_key`. Don't use `partition` directly unless you know what you're doing, since it requires you to know exactly how many partitions each topic has, which can change and cause you pain and misery. Just use `partition_key` or let DeliveryBoy choose at random.
|
70
|
+
|
62
71
|
### Configuration
|
63
72
|
|
64
|
-
You configure DeliveryBoy
|
73
|
+
You configure DeliveryBoy in three different ways: in a YAML config file, in a Ruby config file, or by setting environment variables.
|
65
74
|
|
66
75
|
If you're using Rails, the fastest way to get started is to execute the following in your terminal:
|
67
76
|
|
@@ -71,7 +80,16 @@ $ bundle exec rails generate delivery_boy:install
|
|
71
80
|
|
72
81
|
This will create a config file at `config/delivery_boy.yml` with configurations for each of your Rails environments. Open that file in order to make changes.
|
73
82
|
|
74
|
-
Note that for
|
83
|
+
Note that for all configuration variables, you can pass in an environment variable. These environment variables all take the form `DELIVERY_BOY_X`, where `X` is the upper-case configuration variable name, e.g. `DELIVERY_BOY_CLIENT_ID`.
|
84
|
+
|
85
|
+
You can also configure DeliveryBoy in Ruby if you prefer that. By default, the file `config/delivery_boy.rb` is loaded if present, but you can do this from anywhere – just call `DeliveryBoy.configure` like so:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
DeliveryBoy.configure do |config|
|
89
|
+
config.client_id = "yolo"
|
90
|
+
# ...
|
91
|
+
end
|
92
|
+
```
|
75
93
|
|
76
94
|
The following configuration variables can be set:
|
77
95
|
|
data/lib/delivery_boy.rb
CHANGED
@@ -74,6 +74,18 @@ module DeliveryBoy
|
|
74
74
|
raise ConfigError, e.message
|
75
75
|
end
|
76
76
|
|
77
|
+
# Configure DeliveryBoy in a block.
|
78
|
+
#
|
79
|
+
# DeliveryBoy.configure do |config|
|
80
|
+
# config.client_id = "yolo"
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# @yield [DeliveryBoy::Config]
|
84
|
+
# @return [nil]
|
85
|
+
def configure
|
86
|
+
yield config
|
87
|
+
end
|
88
|
+
|
77
89
|
def test_mode!
|
78
90
|
@instance = testing
|
79
91
|
end
|
data/lib/delivery_boy/railtie.rb
CHANGED
@@ -2,10 +2,13 @@ module DeliveryBoy
|
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
initializer "delivery_boy.load_config" do
|
4
4
|
config = DeliveryBoy.config
|
5
|
-
config_file = "config/delivery_boy.yml"
|
6
5
|
|
7
|
-
if File.exist?(
|
8
|
-
config.load_file(
|
6
|
+
if File.exist?("config/delivery_boy.yml")
|
7
|
+
config.load_file("config/delivery_boy.yml", Rails.env)
|
8
|
+
end
|
9
|
+
|
10
|
+
if File.exist?("config/delivery_boy.rb")
|
11
|
+
require "config/delivery_boy"
|
9
12
|
end
|
10
13
|
|
11
14
|
if config.datadog_enabled
|
data/lib/delivery_boy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delivery_boy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schierbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-kafka
|