resque-pubsub 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.md +13 -13
- data/examples/resque-pubsub.rb +1 -1
- data/lib/resque-pubsub.rb +2 -6
- data/lib/resque/plugins/pubsub/broker.rb +22 -19
- data/lib/resque/plugins/pubsub/exchange.rb +29 -32
- data/lib/resque/plugins/pubsub/publisher.rb +8 -9
- data/lib/resque/plugins/pubsub/subscriber.rb +10 -11
- data/test/fixtures/test_custom_subscriber.rb +19 -0
- data/test/fixtures/test_publisher.rb +3 -0
- data/test/fixtures/test_subscriber.rb +19 -0
- data/test/pubsub_test.rb +35 -42
- data/test/test_helper.rb +8 -7
- metadata +8 -9
- data/test/debug.log +0 -16
- data/test/test_publisher.rb +0 -4
- data/test/test_subscriber.rb +0 -17
- data/test/test_subscriber_custom.rb +0 -17
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -11,26 +11,26 @@ Usage / Examples
|
|
11
11
|
|
12
12
|
A simple class that can publish a message:
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
class TestPublisher
|
15
|
+
include Resque::Plugins::Pubsub::Publisher
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
def some_method
|
18
|
+
self.publish(topic, message)
|
19
|
+
end
|
19
20
|
end
|
20
|
-
end
|
21
21
|
|
22
22
|
|
23
23
|
A simple class that subscribes to messages on a particular topic:
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
class TestSubscriber
|
26
|
+
include Resque::Plugins::Pubsub::Subscriber
|
27
27
|
|
28
|
-
|
28
|
+
subscribe 'test_topic'
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
def self.read_test_topic_message(message)
|
31
|
+
# Do something with the message
|
32
|
+
end
|
32
33
|
end
|
33
|
-
end
|
34
34
|
|
35
35
|
|
36
36
|
Customize & Extend
|
@@ -63,13 +63,13 @@ Running Resque
|
|
63
63
|
A sample config file is provided in examples/resque-pubsub.rb. If you put this in config/initializers for a Rails app,
|
64
64
|
then Resque will default to the app namespace but will take an override on namespace from the environment variable RESQUE_NAMESPACE. Thus
|
65
65
|
|
66
|
-
|
66
|
+
QUEUE=* RESQUE_NAMESPACE="resque:pubsub" rake environment resque:work
|
67
67
|
|
68
68
|
will run resque jobs against the default pubsub namespace (i.e., will be the pubsub server)
|
69
69
|
|
70
70
|
while
|
71
71
|
|
72
|
-
|
72
|
+
QUEUE=* rake environment resque:work
|
73
73
|
|
74
74
|
will run resque in an app as normal.
|
75
75
|
|
data/examples/resque-pubsub.rb
CHANGED
@@ -4,7 +4,7 @@ rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../../../..'
|
|
4
4
|
rails_env = ENV['RAILS_ENV'] || 'development'
|
5
5
|
|
6
6
|
REDIS_CONFIG = YAML.load_file(rails_root + '/config/redis.yml')[rails_env]
|
7
|
-
Resque.redis = REDIS_CONFIG[
|
7
|
+
Resque.redis = REDIS_CONFIG['host'] + ':' + REDIS_CONFIG["port"].to_s
|
8
8
|
|
9
9
|
namespace = ENV['RESQUE_NAMESPACE'] || 'mynamespace' # Edit this to use a different namespace for Resque in the app
|
10
10
|
Resque.redis.namespace = namespace
|
data/lib/resque-pubsub.rb
CHANGED
@@ -1,6 +1,2 @@
|
|
1
|
-
require 'resque
|
2
|
-
|
3
|
-
require 'resque/plugins/pubsub/broker'
|
4
|
-
self.send(:include, Resque::Plugins::Pubsub::Subscriber)
|
5
|
-
self.send(:include, Resque::Plugins::Pubsub::Publisher)
|
6
|
-
|
1
|
+
require 'resque'
|
2
|
+
Dir.glob(File.expand_path('resque/plugins/pubsub/*', File.dirname(__FILE__))).each { |filename| require filename }
|
@@ -1,31 +1,34 @@
|
|
1
1
|
module Resque
|
2
2
|
module Plugins
|
3
|
-
#
|
4
|
-
# pubsub broker
|
5
|
-
#
|
6
3
|
module Pubsub
|
7
4
|
class Broker
|
5
|
+
|
8
6
|
@queue = :messages
|
9
7
|
# Returns a top-level Redis connection so that the broker can distribute messages
|
10
8
|
# across namespaces. If none has been created, will
|
11
9
|
# create a new one using information from the Resque connection.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
def redis
|
14
|
+
return @redis if @redis
|
15
|
+
client_to_copy = Resque.redis.client
|
16
|
+
@redis = Redis.new(:host => client_to_copy.host, :port => client_to_copy.port, :thread_safe => true, :db => client_to_copy.db)
|
17
|
+
end
|
18
|
+
|
19
|
+
def perform(topic, message)
|
20
|
+
subscribers = Exchange.redis.smembers("#{topic}_subscribers")
|
21
|
+
subscribers.each do |s|
|
22
|
+
sinfo = JSON.parse(s)
|
23
|
+
puts "[Broker] distributing to #{sinfo.inspect}"
|
24
|
+
Broker.redis.sadd("#{sinfo['namespace']}:queues", "fanout:#{topic}")
|
25
|
+
Broker.redis.rpush("#{sinfo['namespace']}:queue:fanout:#{topic}", { :class => sinfo['class'], :args => [message] }.to_json)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
27
29
|
end
|
30
|
+
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
31
|
-
end
|
34
|
+
end
|
@@ -1,42 +1,39 @@
|
|
1
|
-
require 'resque'
|
2
1
|
module Resque
|
3
2
|
module Plugins
|
4
|
-
#
|
5
|
-
# pubsub exchange manager
|
6
|
-
#
|
7
3
|
module Pubsub
|
8
4
|
class Exchange
|
9
|
-
@@pubsub_namespace = nil
|
10
|
-
# Returns the current Redis connection. If none has been created, will
|
11
|
-
# create a new one using information from the Resque connection and our config.
|
12
|
-
def self.redis
|
13
|
-
return @redis if @redis
|
14
|
-
client_to_copy = Resque.redis.client
|
15
|
-
redis_new = Redis.new(:host => client_to_copy.host, :port => client_to_copy.port,
|
16
|
-
:thread_safe => true, :db => client_to_copy.db)
|
17
|
-
puts "making a redis in exchange, namespace will be #{@@pubsub_namespace}"
|
18
|
-
@redis = Redis::Namespace.new(@@pubsub_namespace || "resque:pubsub", :redis => redis_new)
|
19
|
-
end
|
20
5
|
|
21
6
|
@queue = :subscription_requests
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def redis
|
11
|
+
return @redis if @redis
|
12
|
+
client_to_copy = Resque.redis.client
|
13
|
+
redis_new = Redis.new(:host => client_to_copy.host, :port => client_to_copy.port, :thread_safe => true, :db => client_to_copy.db)
|
14
|
+
puts "[Exchange] making a redis in exchange, namespace will be #{@pubsub_namespace}"
|
15
|
+
@redis = Redis::Namespace.new(@pubsub_namespace || 'resque:pubsub', :redis => redis_new)
|
16
|
+
end
|
17
|
+
|
18
|
+
def perform(subscription_info)
|
19
|
+
puts '[Exchange] handling a subscription on the exchange'
|
20
|
+
puts "[Exchange] requested subscription is #{subscription_info.inspect}"
|
21
|
+
puts "[Exchange] namespace is #{Exchange.redis.namespace}"
|
22
|
+
Exchange.redis.sadd("#{subscription_info["topic"]}_subscribers", { :class => subscription_info['class'], :namespace => subscription_info['namespace'] }.to_json)
|
23
|
+
end
|
24
|
+
|
25
|
+
def pubsub_namespace
|
26
|
+
@pubsub_namespace
|
27
|
+
end
|
28
|
+
|
29
|
+
def pubsub_namespace=(namespace)
|
30
|
+
@pubsub_namespace = namespace
|
31
|
+
@redis.client.disconnect if @redis
|
32
|
+
@redis = nil
|
33
|
+
end
|
34
|
+
|
39
35
|
end
|
36
|
+
|
40
37
|
end
|
41
38
|
end
|
42
39
|
end
|
@@ -1,23 +1,22 @@
|
|
1
|
-
require 'resque/plugins/pubsub/exchange'
|
2
1
|
module Resque
|
3
2
|
module Plugins
|
4
|
-
#
|
5
|
-
# pubsub publisher
|
6
|
-
#
|
7
3
|
module Pubsub
|
8
4
|
module Publisher
|
9
|
-
|
10
|
-
|
5
|
+
|
6
|
+
def self.included(base)
|
11
7
|
base.send(:include, InstanceMethods)
|
12
8
|
end
|
13
9
|
|
14
10
|
module InstanceMethods
|
11
|
+
|
15
12
|
def publish(topic, message)
|
16
|
-
puts "
|
17
|
-
Exchange.redis.sadd(:queues,
|
18
|
-
Exchange.redis.rpush(
|
13
|
+
puts "[#{self.class.to_s}] publishing #{message} in #{topic}"
|
14
|
+
Exchange.redis.sadd(:queues, 'messages')
|
15
|
+
Exchange.redis.rpush('queue:messages', { :class => 'Resque::Plugins::Pubsub::Broker', :args => [topic, message] }.to_json)
|
19
16
|
end
|
17
|
+
|
20
18
|
end
|
19
|
+
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -1,33 +1,32 @@
|
|
1
|
-
require 'resque/plugins/pubsub/exchange'
|
2
1
|
module Resque
|
3
2
|
module Plugins
|
4
|
-
#
|
5
|
-
# pubsub subscriber
|
6
|
-
#
|
7
3
|
module Pubsub
|
8
4
|
module Subscriber
|
9
|
-
|
10
|
-
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.send(:extend, ClassMethods)
|
11
8
|
end
|
12
|
-
|
9
|
+
|
13
10
|
module ClassMethods
|
11
|
+
|
14
12
|
def subscribe(topic, options={})
|
15
13
|
@queue = "fanout:#{topic}"
|
16
14
|
reader_method = options[:reader_method] || "read_#{topic}_message"
|
17
15
|
module_eval <<-"end_eval"
|
18
16
|
def self.perform(message)
|
19
|
-
self.send("#{reader_method}", message)
|
20
|
-
|
17
|
+
self.send("#{reader_method.to_s}", message)
|
18
|
+
end
|
21
19
|
end_eval
|
22
20
|
options[:namespace] = Resque.redis.namespace
|
23
21
|
options[:topic] = topic
|
24
22
|
options[:class] = self.to_s
|
25
|
-
puts "
|
23
|
+
puts "[#{self.to_s}] subscribing with #{options.inspect}"
|
26
24
|
Exchange.redis.sadd(:queues, :subscription_requests)
|
27
|
-
Exchange.redis.rpush("queue:subscription_requests", {:class=>'Resque::Plugins::Pubsub::Exchange', :args=>[options]}.to_json)
|
25
|
+
Exchange.redis.rpush("queue:subscription_requests", { :class => 'Resque::Plugins::Pubsub::Exchange', :args => [options] }.to_json)
|
28
26
|
end
|
29
27
|
|
30
28
|
end
|
29
|
+
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class TestCustomSubscriber
|
2
|
+
include Resque::Plugins::Pubsub::Subscriber
|
3
|
+
|
4
|
+
subscribe 'test_custom_topic', :reader_method => :simple
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def simple(message)
|
9
|
+
puts "[#{self.to_s}] got test custom topic message: #{message.inspect}"
|
10
|
+
@last_message = message
|
11
|
+
end
|
12
|
+
|
13
|
+
def last_message
|
14
|
+
@last_message
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class TestSubscriber
|
2
|
+
include Resque::Plugins::Pubsub::Subscriber
|
3
|
+
|
4
|
+
subscribe 'test_topic'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def read_test_topic_message(message)
|
9
|
+
puts "[#{self.to_s}] got test topic message: #{message.inspect}"
|
10
|
+
@last_message = message
|
11
|
+
end
|
12
|
+
|
13
|
+
def last_message
|
14
|
+
@last_message
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/test/pubsub_test.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
3
|
class PubsubTest < Test::Unit::TestCase
|
4
|
+
|
4
5
|
def setup
|
5
6
|
$success = $lock_failed = $lock_expired = 0
|
7
|
+
Resque.redis.namespace = nil
|
6
8
|
Resque.redis.flushall
|
7
9
|
Resque.redis.namespace = 'test_pubsub'
|
8
10
|
end
|
@@ -12,72 +14,63 @@ class PubsubTest < Test::Unit::TestCase
|
|
12
14
|
Resque::Plugin.lint(Resque::Plugins::Pubsub)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
|
17
|
+
|
16
18
|
def test_all
|
17
|
-
|
18
|
-
require 'test_publisher'
|
19
|
-
require 'test_subscriber'
|
19
|
+
TestSubscriber.subscribe('test_topic')
|
20
20
|
# Now process the subscription
|
21
21
|
Resque.redis.namespace = 'resque:pubsub'
|
22
|
-
|
23
|
-
@worker.process
|
22
|
+
Resque::Worker.new(:subscription_requests).process
|
24
23
|
# Check that the subscription is in the subscribers list
|
25
|
-
assert
|
24
|
+
assert subscription_exists(Resque.redis.smembers('test_topic_subscribers'), 'TestSubscriber', 'test_pubsub')
|
25
|
+
|
26
26
|
p = TestPublisher.new
|
27
|
-
p.publish(
|
27
|
+
p.publish('test_topic', 'Test message')
|
28
28
|
# Run Resque for the broker
|
29
29
|
Resque.redis.namespace = 'resque:pubsub'
|
30
|
-
|
31
|
-
@worker.process
|
30
|
+
Resque::Worker.new(:messages).process
|
32
31
|
# Check that the message queue has been populated
|
33
32
|
Resque.redis.namespace = 'test_pubsub'
|
34
33
|
assert Resque.redis.keys.include?('queue:fanout:test_topic')
|
35
|
-
|
34
|
+
assert_equal 1, Resque.redis.llen('queue:fanout:test_topic')
|
35
|
+
|
36
36
|
# Now run the subscriber Resque
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
assert TestSubscriber.last_message=='Test message'
|
37
|
+
Resque::Worker.new('fanout:test_topic').process
|
38
|
+
assert_equal 0, Resque.redis.llen('queue:fanout:test_topic')
|
39
|
+
assert_equal 'Test message', TestSubscriber.last_message
|
41
40
|
end
|
42
|
-
|
41
|
+
|
43
42
|
def test_configuration_options
|
44
|
-
# Configure the pubsub namespace
|
45
|
-
require 'resque-pubsub'
|
46
43
|
Resque::Plugins::Pubsub::Exchange.pubsub_namespace = 'resque:custom_space'
|
47
|
-
|
48
|
-
require 'test_publisher'
|
49
|
-
require 'test_subscriber'
|
50
|
-
require 'test_subscriber_custom'
|
44
|
+
TestCustomSubscriber.subscribe('test_custom_topic', :reader_method => :simple)
|
51
45
|
# Now process the subscription
|
52
46
|
Resque.redis.namespace = 'resque:custom_space'
|
53
|
-
|
54
|
-
@worker.process
|
47
|
+
Resque::Worker.new(:subscription_requests).process
|
55
48
|
# Check that the subscription is in the subscribers list
|
56
|
-
assert
|
57
|
-
|
58
|
-
|
49
|
+
assert subscription_exists(Resque.redis.smembers('test_custom_topic_subscribers'), 'TestCustomSubscriber', 'test_pubsub')
|
50
|
+
|
51
|
+
TestPublisher.new.publish('test_custom_topic', 'Test custom message')
|
59
52
|
# Run Resque for the broker
|
60
53
|
Resque.redis.namespace = 'resque:custom_space'
|
61
|
-
|
62
|
-
@worker.process
|
54
|
+
Resque::Worker.new(:messages).process
|
63
55
|
# Check that the message queue has been populated
|
64
56
|
Resque.redis.namespace = 'test_pubsub'
|
65
57
|
assert Resque.redis.keys.include?('queue:fanout:test_custom_topic')
|
66
|
-
|
58
|
+
assert_equal 1, Resque.redis.llen('queue:fanout:test_custom_topic')
|
59
|
+
|
67
60
|
# Now run the subscriber Resque
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
# Also make sure TestSubscriber DIDN'T get the message
|
73
|
-
assert TestSubscriber.last_message!='Test custom message'
|
61
|
+
Resque::Worker.new('fanout:test_custom_topic').process
|
62
|
+
assert_equal 0, Resque.redis.llen('queue:fanout:test_custom_topic')
|
63
|
+
assert_equal 'Test custom message', TestCustomSubscriber.last_message
|
64
|
+
assert_not_equal 'Test custom message', TestSubscriber.last_message
|
74
65
|
end
|
66
|
+
|
67
|
+
private
|
75
68
|
|
76
|
-
def
|
77
|
-
subscribers.inject(false)
|
69
|
+
def subscription_exists(subscribers, klass, namespace)
|
70
|
+
subscribers.inject(false) do |result, s|
|
78
71
|
sinfo = JSON.parse(s)
|
79
|
-
result = result || (sinfo[
|
80
|
-
|
72
|
+
result = result || (sinfo['class'] == klass && sinfo['namespace'] == namespace)
|
73
|
+
end
|
81
74
|
end
|
82
75
|
|
83
|
-
end
|
76
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -10,15 +10,13 @@ require 'active_support/test_case'
|
|
10
10
|
|
11
11
|
require 'resque-pubsub'
|
12
12
|
|
13
|
-
##
|
14
13
|
# make sure we can run redis
|
15
|
-
if !system(
|
14
|
+
if !system('which redis-server')
|
16
15
|
puts '', "** can't find `redis-server` in your path"
|
17
16
|
puts "** try running `sudo rake install`"
|
18
17
|
abort ''
|
19
18
|
end
|
20
19
|
|
21
|
-
##
|
22
20
|
# start our own redis when the tests start,
|
23
21
|
# kill it when they end
|
24
22
|
at_exit do
|
@@ -31,12 +29,15 @@ at_exit do
|
|
31
29
|
end
|
32
30
|
|
33
31
|
pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
|
34
|
-
puts
|
32
|
+
puts 'Killing test redis server...'
|
35
33
|
`rm -f #{dir}/dump.rdb`
|
36
|
-
Process.kill(
|
34
|
+
Process.kill('KILL', pid.to_i)
|
37
35
|
exit exit_code
|
38
36
|
end
|
39
37
|
|
40
|
-
puts
|
38
|
+
puts 'Starting redis for testing at localhost:9736...'
|
41
39
|
`redis-server #{dir}/redis-test.conf`
|
42
|
-
Resque.redis = '127.0.0.1:9736'
|
40
|
+
Resque.redis = '127.0.0.1:9736'
|
41
|
+
Resque.redis.namespace = 'test_pubsub'
|
42
|
+
|
43
|
+
Dir.glob(File.expand_path(dir + '/fixtures/*')).each { |filename| require filename }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Monica McArthur
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-12 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 1.9.10
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
|
-
description: "
|
37
|
+
description: " A Resque plugin. Provides a lightweight publish/subscribe messaging system, with message persistence when clients are down.\n"
|
38
38
|
email: mechaferret@gmail.com
|
39
39
|
executables: []
|
40
40
|
|
@@ -53,13 +53,12 @@ files:
|
|
53
53
|
- lib/resque/plugins/pubsub/publisher.rb
|
54
54
|
- lib/resque/plugins/pubsub/subscriber.rb
|
55
55
|
- lib/resque-pubsub.rb
|
56
|
-
- test/
|
56
|
+
- test/fixtures/test_custom_subscriber.rb
|
57
|
+
- test/fixtures/test_publisher.rb
|
58
|
+
- test/fixtures/test_subscriber.rb
|
57
59
|
- test/pubsub_test.rb
|
58
60
|
- test/redis-test.conf
|
59
61
|
- test/test_helper.rb
|
60
|
-
- test/test_publisher.rb
|
61
|
-
- test/test_subscriber.rb
|
62
|
-
- test/test_subscriber_custom.rb
|
63
62
|
has_rdoc: true
|
64
63
|
homepage: http://github.com/mechaferret/resque-pubsub
|
65
64
|
licenses: []
|
data/test/debug.log
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Logfile created on Thu Jan 20 18:20:02 -0800 2011 by logger.rb/22285
|
2
|
-
[4;36;1mSQL (0.2ms)[0m [0;1mSET SQL_AUTO_IS_NULL=0[0m
|
3
|
-
[4;35;1mSQL (0.3ms)[0m [0mSHOW TABLES[0m
|
4
|
-
[4;36;1mSQL (430.6ms)[0m [0;1mCREATE TABLE `transactionals` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `description` varchar(255), `other_id` int(11)) ENGINE=InnoDB[0m
|
5
|
-
[4;35;1mSQL (0.4ms)[0m [0mSHOW TABLES[0m
|
6
|
-
[4;36;1mSQL (114.4ms)[0m [0;1mCREATE TABLE `transactional_facts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `description` varchar(255), `other_id` int(11)) ENGINE=InnoDB[0m
|
7
|
-
[4;35;1mSQL (0.4ms)[0m [0mSHOW TABLES[0m
|
8
|
-
[4;36;1mSQL (102.1ms)[0m [0;1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB[0m
|
9
|
-
[4;35;1mSQL (172.5ms)[0m [0mCREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)[0m
|
10
|
-
[4;36;1mSQL (0.4ms)[0m [0;1mSHOW TABLES[0m
|
11
|
-
[4;35;1mSQL (0.1ms)[0m [0mSELECT version FROM `schema_migrations`[0m
|
12
|
-
[4;36;1mSQL (0.4ms)[0m [0;1mINSERT INTO `schema_migrations` (version) VALUES ('3')[0m
|
13
|
-
[4;35;1mTransactional Columns (38.0ms)[0m [0mSHOW FIELDS FROM `transactionals`[0m
|
14
|
-
[4;36;1mSQL (0.3ms)[0m [0;1mBEGIN[0m
|
15
|
-
[4;35;1mTransactional Create (0.3ms)[0m [0mINSERT INTO `transactionals` (`name`, `other_id`, `description`) VALUES(NULL, NULL, NULL)[0m
|
16
|
-
[4;36;1mSQL (0.7ms)[0m [0;1mCOMMIT[0m
|
data/test/test_publisher.rb
DELETED
data/test/test_subscriber.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class TestSubscriber
|
2
|
-
require 'resque-pubsub'
|
3
|
-
|
4
|
-
subscribe 'test_topic'
|
5
|
-
|
6
|
-
@@last_message = nil
|
7
|
-
|
8
|
-
def self.read_test_topic_message(message)
|
9
|
-
puts "got test topic message: #{message.inspect}"
|
10
|
-
@@last_message = message
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.last_message
|
14
|
-
@@last_message
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class TestSubscriberCustom
|
2
|
-
require 'resque-pubsub'
|
3
|
-
|
4
|
-
subscribe 'test_custom_topic', :reader_method => 'simple'
|
5
|
-
|
6
|
-
@@last_message = nil
|
7
|
-
|
8
|
-
def self.simple(message)
|
9
|
-
puts "in simple, got test custom topic message: #{message.inspect}"
|
10
|
-
@@last_message = message
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.last_message
|
14
|
-
@@last_message
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|