jackhammer 0.1.1 → 0.2.0
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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +87 -17
- data/jackhammer.gemspec +1 -1
- data/lib/jackhammer.rb +0 -2
- data/lib/jackhammer/configuration.rb +1 -1
- data/lib/jackhammer/queue.rb +1 -1
- data/lib/jackhammer/version.rb +1 -1
- metadata +2 -4
- data/lib/jackhammer/null_exception_adapter.rb +0 -8
- data/lib/jackhammer/publish.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cee97f6076b1008ddb323c8c43c87680cb334482569107992ac683c869fea7f
|
4
|
+
data.tar.gz: ee0aa15bb52690dba58a1145878d9d81fd1c33e3a802ef1290ee1fb584466898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d2d839de4fc36c47958b86b2f9e8f7857535b640ea86852ced3d4c79b93eb7c5e550035be7364e9a7f7b4e78c094bca93190c19322cf585b8dc483d1cb7ea0a
|
7
|
+
data.tar.gz: 9eb24d185af0730c0f17cb2fd8094d06604e5cb7548a44e6a2e1d1d0710970bef920e14455b38eaee447df4265c21de4529ddc85c31049c14b5536050d8411cf
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
[](https://travis-ci.org/RenoFi/jackhammer)
|
2
|
+
[](https://github.com/renofi/jackhammer/issues)
|
3
|
+
[](https://github.com/RenoFi/jackhammer/blob/master/LICENSE.txt)
|
4
|
+
|
1
5
|
# Jackhammer
|
2
6
|
|
3
7
|
Jackhammer is an opinionated, configurable facade over the RabbitMQ Bunny
|
@@ -7,9 +11,7 @@ module.
|
|
7
11
|
|
8
12
|
Add this line to your application's Gemfile:
|
9
13
|
|
10
|
-
|
11
|
-
gem 'jackhammer'
|
12
|
-
```
|
14
|
+
gem 'jackhammer'
|
13
15
|
|
14
16
|
And then execute:
|
15
17
|
|
@@ -21,10 +23,12 @@ Or install it yourself as:
|
|
21
23
|
|
22
24
|
## Usage
|
23
25
|
|
26
|
+
### Quick Start
|
27
|
+
|
24
28
|
Create a YAML file to configure topics and queues your Jackhammer::Server instance
|
25
29
|
will subscribe to when using the executable.
|
26
30
|
|
27
|
-
```
|
31
|
+
```yaml
|
28
32
|
# config/jackhammer.yml
|
29
33
|
---
|
30
34
|
default: &default
|
@@ -42,7 +46,7 @@ default: &default
|
|
42
46
|
development:
|
43
47
|
<<: *default
|
44
48
|
|
45
|
-
|
49
|
+
test:
|
46
50
|
<<: *default
|
47
51
|
|
48
52
|
production:
|
@@ -51,20 +55,21 @@ production:
|
|
51
55
|
|
52
56
|
Configure your subscription server by sublcassing `Jackhammer::Server`.
|
53
57
|
|
54
|
-
```
|
58
|
+
```ruby
|
55
59
|
# config/application.rb
|
56
60
|
require 'jackhammer'
|
57
61
|
|
58
62
|
module MyApp
|
59
63
|
class Server < Jackhammer::Server
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
configure do |config|
|
65
|
+
# these are the default options
|
66
|
+
config.connection_options = {}
|
67
|
+
config.connection_url = nil
|
68
|
+
config.environment = ENV['RACK_ENV'] || :development
|
69
|
+
config.exception_adapter = proc { |e| raise e }
|
70
|
+
config.logger = Logger.new(IO::NULL)
|
71
|
+
config.publish_options = { mandatory: true, persistent: true }
|
72
|
+
config.yaml_config = "config/jackhammer.yml"
|
68
73
|
end
|
69
74
|
end
|
70
75
|
end
|
@@ -72,9 +77,74 @@ end
|
|
72
77
|
|
73
78
|
Start the subscription server to read the YAML and subscribe to topic queues.
|
74
79
|
|
80
|
+
$ bundle exec jackhammer
|
81
|
+
|
82
|
+
### Topic Exchange Configuration
|
83
|
+
|
84
|
+
The YAML file configures [RabbitMQ Topic Exchanges](https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchange-topic).
|
85
|
+
|
86
|
+
At the root are environment names used to load environment specific
|
87
|
+
configuration. Below that are the names of topic exchanges. Each topic exchange
|
88
|
+
can define `durable` and `auto_delete` options used when creating the exchange.
|
89
|
+
Additionally, each topic exchange defines a `queues` mapping. Each mapping
|
90
|
+
nested under the `queues` key represents options used by either Jackhammer or
|
91
|
+
Bunny.
|
92
|
+
|
93
|
+
Exchange topic queue options passed to Bunny during [queue initialization](http://reference.rubybunny.info/Bunny/Queue.html#initialize-instance_method):
|
94
|
+
|
95
|
+
- **durable** default: false — Should this queue be durable?
|
96
|
+
- **auto_delete** default: false — Should this queue be automatically deleted when the last consumer disconnects?
|
97
|
+
- **exclusive** default: false — Should this queue be exclusive (only can be used by this connection, removed when the connection is closed)?
|
98
|
+
|
99
|
+
The **routing_key** is used as an option when binding the Bunny::Queue and
|
100
|
+
Bunny::Exchange.
|
101
|
+
|
102
|
+
Exchange topic queue options used by Jackhammer:
|
103
|
+
|
104
|
+
- **handler** A string representing the name of a class that is intended to
|
105
|
+
receive messages delivered to the queue subscriber.
|
106
|
+
|
107
|
+
The handler class must implement at least a `.call` method. If the class
|
108
|
+
responds to `.perform_async` then that will be called instead of `.call`.
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
module MyApp
|
112
|
+
class SouthAmericaHandler
|
113
|
+
def self.call(message)
|
114
|
+
puts message
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
75
118
|
```
|
76
|
-
|
77
|
-
|
119
|
+
|
120
|
+
### Executable
|
121
|
+
|
122
|
+
By default the executable will load `config/application.rb`. If you define
|
123
|
+
and configure your Jackhammer server somewhere else, use the `-r path/file.rb`
|
124
|
+
option on the command line.
|
125
|
+
|
126
|
+
$ bundle exec jackhammer -r config/rabbitmq_application.rb
|
127
|
+
|
128
|
+
### Server Configuration
|
129
|
+
|
130
|
+
The `configure` block must be placed inside of your application class even if
|
131
|
+
you choose not to change any default configuration.
|
132
|
+
|
133
|
+
The intent of the options might not be obvious by looking at the name.
|
134
|
+
- **connection_options** passed into `Bunny.new`.
|
135
|
+
- **connection_url** passed into `Bunny.new`.
|
136
|
+
- **environment** specifies the section of YAML config to load.
|
137
|
+
- **exception_adapter** exceptions caught when handling received messages are
|
138
|
+
forwarded to the adapter object. The adapter must implement
|
139
|
+
`.call(exception)`.
|
140
|
+
- **logger** defines a logger the Jackhammer module should use.
|
141
|
+
- **publish_options** defines options passed to all messages published (can be
|
142
|
+
overridden by passing the same options as arguments in your code).
|
143
|
+
- **yaml_config** defines the file location of the Topic Exchange YAML
|
144
|
+
configuration file.
|
145
|
+
|
146
|
+
You can find defaults specified in the Jackhammer::Configuration class
|
147
|
+
constructor.
|
78
148
|
|
79
149
|
## Development
|
80
150
|
|
@@ -84,7 +154,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
84
154
|
|
85
155
|
## Contributing
|
86
156
|
|
87
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
157
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/renofi/jackhammer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
88
158
|
|
89
159
|
## License
|
90
160
|
|
data/jackhammer.gemspec
CHANGED
data/lib/jackhammer.rb
CHANGED
@@ -6,13 +6,11 @@ require 'yaml'
|
|
6
6
|
require 'bunny'
|
7
7
|
require 'jackhammer/version'
|
8
8
|
require 'jackhammer/log'
|
9
|
-
require 'jackhammer/null_exception_adapter'
|
10
9
|
require 'jackhammer/configuration'
|
11
10
|
require 'jackhammer/message_receiver'
|
12
11
|
require 'jackhammer/queue'
|
13
12
|
require 'jackhammer/topic'
|
14
13
|
require 'jackhammer/topic_manager'
|
15
|
-
require 'jackhammer/publish'
|
16
14
|
require 'jackhammer/server'
|
17
15
|
|
18
16
|
module Jackhammer
|
@@ -17,7 +17,7 @@ module Jackhammer
|
|
17
17
|
@connection_options = {}
|
18
18
|
@connection_url = ENV['RABBITMQ_URL']
|
19
19
|
@environment = ENV['RACK_ENV'] || :development
|
20
|
-
@exception_adapter =
|
20
|
+
@exception_adapter = proc { |e| raise e }
|
21
21
|
@logger = Logger.new IO::NULL
|
22
22
|
@publish_options = { mandatory: true, persistent: true }
|
23
23
|
@yaml_config = './config/jackhammer.yml'
|
data/lib/jackhammer/queue.rb
CHANGED
data/lib/jackhammer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackhammer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Serok
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -149,8 +149,6 @@ files:
|
|
149
149
|
- lib/jackhammer/configuration.rb
|
150
150
|
- lib/jackhammer/log.rb
|
151
151
|
- lib/jackhammer/message_receiver.rb
|
152
|
-
- lib/jackhammer/null_exception_adapter.rb
|
153
|
-
- lib/jackhammer/publish.rb
|
154
152
|
- lib/jackhammer/queue.rb
|
155
153
|
- lib/jackhammer/server.rb
|
156
154
|
- lib/jackhammer/topic.rb
|
data/lib/jackhammer/publish.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jackhammer
|
4
|
-
# The API to send messages to a topic with a given attribute
|
5
|
-
class Publish
|
6
|
-
class << self
|
7
|
-
def topics
|
8
|
-
@topics ||= {}
|
9
|
-
end
|
10
|
-
|
11
|
-
def publish(event, message, options)
|
12
|
-
publish_options = Jackhammer.configuration.publish_options # system defaults
|
13
|
-
publish_options[:routing_key] = event # routing_key
|
14
|
-
publish_options = publish_options.merge options # override any system defaults
|
15
|
-
Jackhammer.connection.publish message, publish_options
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|