philotic 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -0
- data/examples/publishing/publish.rb +1 -6
- data/examples/simple_combined_example.rb +28 -0
- data/lib/philotic/config.rb +1 -1
- data/lib/philotic/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c207f88ac1a40745e0fb7146a97850669bbac39
|
4
|
+
data.tar.gz: 843d000c8695ae044d997def648714de1c42f4cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f7f6b66ea62000a0711a5c7d468afa43eb7309fb252650e9265c62942caa1d4fe9144954842c421ad20057cc2151a2328f64a7f510dfdb4ef320452c410ddc
|
7
|
+
data.tar.gz: 61b6203f1ef2cdf747cc9e7eb49a6998ae0b4068d0f81c3eeee59a29846fe8a4adfd5a36690346d0b4b5c5ad0a2b56c92c18b44e34354924c1feb464284c9607
|
data/README.md
CHANGED
@@ -7,3 +7,39 @@ Lightweight, opinionated wrapper for using RabbitMQ headers exchanges
|
|
7
7
|
[![Test Coverage](https://codeclimate.com/github/nkeyes/philotic/badges/coverage.svg)](https://codeclimate.com/github/nkeyes/philotic)
|
8
8
|
|
9
9
|
Check out the [examples](https://github.com/nkeyes/philotic/tree/master/examples).
|
10
|
+
|
11
|
+
## Simple Example
|
12
|
+
```Ruby
|
13
|
+
require 'philotic'
|
14
|
+
require 'awesome_print'
|
15
|
+
|
16
|
+
# override the message return handler
|
17
|
+
Philotic::Config.message_return_handler = lambda do |basic_return, metadata, message|
|
18
|
+
Philotic.logger.warn "Message returned. reply_text: #{basic_return.reply_text}"
|
19
|
+
end
|
20
|
+
|
21
|
+
Philotic::Subscriber.subscribe(header_key: 'header_1') do |metadata, message|
|
22
|
+
ap message[:attributes]
|
23
|
+
end
|
24
|
+
|
25
|
+
# normally we'd do:
|
26
|
+
#
|
27
|
+
# Philotic::Subscriber.endure
|
28
|
+
#
|
29
|
+
# to keep the parent thread alive while the subscribers do their thing
|
30
|
+
# but this infinite publish loop takes care of that
|
31
|
+
loop do
|
32
|
+
Philotic::Event.publish({header_key: "header_#{[1, 2].sample}"}, {payload_key: 'payload_value'})
|
33
|
+
|
34
|
+
# only send a message every two seconds so we can see whats going on
|
35
|
+
sleep 2
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
### Tested with the following Rubies
|
40
|
+
* 1.9.3
|
41
|
+
* 2.0.0
|
42
|
+
* 2.1.0
|
43
|
+
* jruby-19mode
|
44
|
+
* ruby-head
|
45
|
+
* jruby-head
|
@@ -5,12 +5,7 @@ $stdout.sync = true
|
|
5
5
|
require 'philotic'
|
6
6
|
require 'philotic/dummy_event'
|
7
7
|
|
8
|
-
Philotic.logger= Logger.new('/dev/null')
|
9
|
-
|
10
|
-
Philotic::Config.load_file(File.join(File.dirname(__FILE__), "../../", "philotic.yml.example"))
|
11
|
-
|
12
|
-
#Philotic::Config.threaded_publish = true
|
13
|
-
#Philotic::Config.threaded_publish_pool_size = 3
|
8
|
+
Philotic.logger = Logger.new('/dev/null')
|
14
9
|
|
15
10
|
Philotic::Connection.connect!
|
16
11
|
@event = Philotic::DummyEvent.new
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
$stdout.sync = true
|
4
|
+
|
5
|
+
require 'philotic'
|
6
|
+
require 'awesome_print'
|
7
|
+
|
8
|
+
# override the message return handler
|
9
|
+
Philotic::Config.message_return_handler = lambda do |basic_return, metadata, message|
|
10
|
+
Philotic.logger.warn "Message returned. reply_text: #{basic_return.reply_text}"
|
11
|
+
end
|
12
|
+
|
13
|
+
Philotic::Subscriber.subscribe(header_key: 'header_1') do |metadata, message|
|
14
|
+
ap message[:attributes]
|
15
|
+
end
|
16
|
+
|
17
|
+
# normally we'd do:
|
18
|
+
#
|
19
|
+
# Philotic::Subscriber.endure
|
20
|
+
#
|
21
|
+
# to keep the parent thread alive while the subscribers do their thing
|
22
|
+
# but this infinite publish loop takes care of that
|
23
|
+
loop do
|
24
|
+
Philotic::Event.publish({header_key: "header_#{[1, 2].sample}"}, {payload_key: 'payload_value'})
|
25
|
+
|
26
|
+
# only send a message every two seconds so we can see whats going on
|
27
|
+
sleep 2
|
28
|
+
end
|
data/lib/philotic/config.rb
CHANGED
@@ -60,7 +60,7 @@ module Philotic
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
attr_writer :connection_failed_handler, :connection_loss_handler, :message_return_handler
|
64
64
|
|
65
65
|
def connection_failed_handler
|
66
66
|
@connection_failed_handler ||= lambda do |settings|
|
data/lib/philotic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: philotic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Keyes
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- examples/creating_named_queues/philotic_named_queues.yml
|
226
226
|
- examples/creating_named_queues/with_rake.rb
|
227
227
|
- examples/publishing/publish.rb
|
228
|
+
- examples/simple_combined_example.rb
|
228
229
|
- examples/subscribing/acks.rb
|
229
230
|
- examples/subscribing/anonymous_queue.rb
|
230
231
|
- examples/subscribing/multiple_named_queues.rb
|