simplepubsub 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc78605a19c74df4fd6a16de9d339b13bcc2633a
4
- data.tar.gz: faf89565b9512de0b39453ca0fd988cead7661e6
3
+ metadata.gz: eb381f1a9193783cec4ec0e89707d8cf09ea4b59
4
+ data.tar.gz: f7073225dd5c8429af8cdc86fd107e494022f033
5
5
  SHA512:
6
- metadata.gz: 07b3ae6f73ae5882354e583030fbd3a1c14fc710eb940751f65dbc0c43df80207e2bf46f98624cb3d0d713d6fe23ab0cdddab193fc6ba89a3c8fa275ce1f9e4d
7
- data.tar.gz: f382b7a18d5cd514e8a26464fe0641942d2fb6d04f4c876c0afc5a1df9b660a9bfca427bdeb6328721cb4c1739778cb2c31e9225fea65d431ffa5f9b752896f2
6
+ metadata.gz: 3a80c6ee14fa0364868a3160570c103629d2ed2702f83cb5917b231bb07ad7114c54a5e08837afaabd128f4a04fdc14b1861d7fe6ac2103810de04ce5e260169
7
+ data.tar.gz: ad4f5f78400633816e44c4e2d8757f5805396342623a6629a6361225d03e3323f0528d88f294736c7caabd52b6184f8cc26ad6e6b1419ac37dd9a7143f61db25
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/simplepubsub.rb CHANGED
@@ -7,7 +7,7 @@ require 'drb'
7
7
  require 'dws-registry'
8
8
 
9
9
 
10
- USER_AGENT = 'SimplePubSub client 0.3.3'
10
+ USER_AGENT = 'SimplePubSub client 0.4.0'
11
11
 
12
12
  module SimplePubSub
13
13
 
@@ -25,29 +25,39 @@ module SimplePubSub
25
25
  end
26
26
  end
27
27
 
28
- def initialize(base_url)
29
- @base_url = base_url
28
+ def initialize(hostname)
29
+ @hostname = hostname
30
30
  end
31
31
 
32
32
  def get(topic, &get_proc)
33
33
 
34
34
  DRb.start_service nil, Echo.new(&get_proc)
35
- r = open("http://#{@base_url}/do/simplepubsub/" + \
36
- "subscribe?topic=#{URI.escape(topic)}&uri=" + \
37
- DRb.uri, 'UserAgent' => USER_AGENT){|x| x.read}
38
- DRb.thread.join
35
+
36
+ obj = DRbObject.new nil, "druby://#{@hostname}:59000"
37
+ obj.subscribe(topic, DRb.uri)
38
+ DRb.thread.join
39
39
 
40
40
  end
41
41
 
42
42
  def publish(topic, message)
43
43
 
44
- params = "/do/simplepubsub/publish?topic=%s&message=%s" % \
45
- [URI.escape(topic),URI.escape(message)]
46
- open('http://' + @base_url + params, 'UserAgent' => USER_AGENT)\
47
- {|x| x.read}
44
+ DRb.start_service
45
+ obj = DRbObject.new nil, "druby://#{@hostname}:59000"
46
+ obj.deliver topic, message
48
47
  end
49
48
  end
50
49
 
50
+ attr_reader :remote_obj
51
+
52
+ # generally used by the web server
53
+ #
54
+ def initialize(hostname)
55
+
56
+ DRb.start_service
57
+ # attach to the DRb server via a URI given on the command line
58
+ @remote_obj = DRbObject.new nil, "druby://#{hostname}:59000"
59
+ end
60
+
51
61
  def self.connect(base_url)
52
62
  yield(PubSub.new base_url)
53
63
  end
@@ -106,6 +116,17 @@ module SimplePubSub
106
116
  end
107
117
  'done'
108
118
  end
119
+
120
+ def start()
121
+
122
+ # start up the DRb service
123
+ DRb.start_service 'druby://:59000', self
124
+
125
+ # wait for the DRb service to finish before exiting
126
+ DRb.thread.join
127
+
128
+ 'done'
129
+ end
109
130
 
110
131
  def subscribe(topic, uri)
111
132
 
data.tar.gz.sig CHANGED
Binary file
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.3.3
4
+ version: 0.4.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-27 00:00:00.000000000 Z
34
+ date: 2013-07-18 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dws-registry
metadata.gz.sig CHANGED
Binary file