simplepubsub 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +6 -3
- data/lib/simplepubsub.rb +78 -1
- data.tar.gz.sig +1 -3
- metadata +2 -2
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c4513ee74222d8aa5deebdb2c14e81a9c909a5b
|
4
|
+
data.tar.gz: c7009e918084ad0d56fbc9684ab179bf81ecda10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16ae4e1c743711ebde933b5a28c83c78ae10de79b4dc97596dc8ee68698d8420dfeef86b883dfceb98dc22cfdd7e2bac674c84660ee6a5292750a8e1480e7172
|
7
|
+
data.tar.gz: 7ea66c7fd40680761b3f47800a1a3db27a917ed250ed247f2d4fe8d02117986a58e5cbd3bbcd19d9f07853fe320bcbc06548a8c8a9dabcc02850eeeb9ef9c82d
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
!���;`j�
|
2
|
+
��'Y��hݚ�"�E�[|4o�6YG��ő���"`�
|
3
|
+
��O:"����sr��{դ*��cdl�
|
4
|
+
AZJE����+���s� ~e[��ׄ<f�̐�E��QQNp�u@�
|
5
|
+
��P����x�[<���J3t埂���,R��xj��[i��+g3��Tk� �4pt�_��*��V��hP%k5�fFN���/����7/
|
6
|
+
����?n�}\D;
|
data/lib/simplepubsub.rb
CHANGED
@@ -6,7 +6,7 @@ require 'open-uri'
|
|
6
6
|
require 'drb'
|
7
7
|
|
8
8
|
|
9
|
-
USER_AGENT = 'SimplePubSub client 0.
|
9
|
+
USER_AGENT = 'SimplePubSub client 0.2'
|
10
10
|
|
11
11
|
module SimplePubSub
|
12
12
|
|
@@ -51,4 +51,81 @@ module SimplePubSub
|
|
51
51
|
yield(PubSub.new base_url)
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
class Server
|
56
|
+
|
57
|
+
attr_reader :subscribers
|
58
|
+
|
59
|
+
def initialize()
|
60
|
+
@subscribers = {'#' => []}
|
61
|
+
@bridges = {'#' => []}
|
62
|
+
end
|
63
|
+
|
64
|
+
def subscribe(topic, uri)
|
65
|
+
@subscribers[topic] ||= []
|
66
|
+
@subscribers[topic] << uri
|
67
|
+
end
|
68
|
+
|
69
|
+
def deliver(topic, msg)
|
70
|
+
|
71
|
+
if not @subscribers.include?(topic) and \
|
72
|
+
not @subscribers.include?('#') then
|
73
|
+
return 'no topic subscribers'
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
DRb.start_service
|
78
|
+
|
79
|
+
topic_subscribers = @subscribers[topic]
|
80
|
+
|
81
|
+
if topic_subscribers then
|
82
|
+
|
83
|
+
topic_subscribers.each do |uri|
|
84
|
+
|
85
|
+
next if @subscribers['#'].include? uri
|
86
|
+
echo = DRbObject.new nil, uri
|
87
|
+
|
88
|
+
begin
|
89
|
+
echo.message topic, msg
|
90
|
+
rescue DRb::DRbConnError => e
|
91
|
+
@subscribers[topic].delete uri
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
@subscribers['#'].each do |uri|
|
98
|
+
|
99
|
+
echo = DRbObject.new nil, uri
|
100
|
+
|
101
|
+
begin
|
102
|
+
echo.message topic, msg
|
103
|
+
rescue DRb::DRbConnError => e
|
104
|
+
@subscribers['#'].delete uri
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_bridge(topic, hostname, address)
|
111
|
+
@bridges[topic] ||= {}
|
112
|
+
@bridges[topic].merge!(hostname => address)
|
113
|
+
end
|
114
|
+
|
115
|
+
def bridge_deliver(topic, message, excluded_host=nil)
|
116
|
+
|
117
|
+
if excluded_host then
|
118
|
+
bridges = @bridges[topic].select{|x| x != excluded_host}
|
119
|
+
else
|
120
|
+
bridges = @bridges[topic]
|
121
|
+
end
|
122
|
+
|
123
|
+
bridges.each do |bridge|
|
124
|
+
url = "http://%s/do/simplepubsub/bridge_published?topic=%s&message=%s" % [address, topic, URI.escape(message)]
|
125
|
+
r = open(url, 'UserAgent' => USER_AGENT)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
54
131
|
end
|
data.tar.gz.sig
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplepubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
i0PBE6fLwlIMk8jNNUcX3J1csSMgLNTwE8CwrlSZE8sueHj0pQzICM7lF0gGREO6
|
32
32
|
hQHD0LljU3MusQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2013-06-
|
34
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
35
35
|
dependencies: []
|
36
36
|
description:
|
37
37
|
email:
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
IG���Pg3r|]�]���Пw�oE��߬I��q϶�{��D3>�A�<_Ri�2\�NU����Mn�O3x��+�M�+9\۩�=��y�=�O#�Oc��!�˛��7���?nz��3ՈL(u�{G$�
|