fanout 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fanout.rb +11 -29
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 857315e0ee2081c96c072f6295f9ee58086e459a
|
4
|
+
data.tar.gz: 8adf56221d8a4f10a3d531476979e10ee68fe137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97faeda87ee4be778929ca6a26331ee2badb2c13e6fa88519422eaf67a8125a984c0362dc72305aa8c1ef7cc375450f7cb2ecedec5c0be53fd727a50f34504c4
|
7
|
+
data.tar.gz: 577ada5bd31f10ab24f1c75df2e6808d8dd65828422c04c404e6c61722061f38cc31e09a8efc38b8429e3231f6cda01d5460eb66da8e736e0467edc56c21c54e
|
data/lib/fanout.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# ~~~~~~~~~
|
3
3
|
# This module implements the Fanout class.
|
4
4
|
# :authors: Konstantin Bokarius.
|
5
|
-
# :copyright: (c) 2015 by Fanout, Inc.
|
5
|
+
# :copyright: (c) 2015-2016 by Fanout, Inc.
|
6
6
|
# :license: MIT, see LICENSE for more details.
|
7
7
|
|
8
8
|
require 'base64'
|
@@ -30,17 +30,21 @@ class Fanout
|
|
30
30
|
if key.nil?
|
31
31
|
key = ENV['FANOUT_KEY']
|
32
32
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
if ssl
|
34
|
+
scheme = 'https'
|
35
|
+
else
|
36
|
+
scheme = 'http'
|
37
|
+
end
|
38
|
+
uri = '%s://api.fanout.io/realm/%s' % [scheme, realm]
|
39
|
+
@pub = PubControl.new({'uri' => uri, 'iss' => realm,
|
40
|
+
'key' => Base64.decode64(key)})
|
36
41
|
end
|
37
42
|
|
38
43
|
# Synchronously publish the specified data to the specified channel for
|
39
44
|
# the configured Fanout.io realm. Optionally provide an ID and previous
|
40
45
|
# ID to send along with the message.
|
41
46
|
def publish(channel, data, id=nil, prev_id=nil)
|
42
|
-
pub
|
43
|
-
pub.publish(channel, Item.new(JsonObjectFormat.new(data), id, prev_id))
|
47
|
+
@pub.publish(channel, Item.new(JsonObjectFormat.new(data), id, prev_id))
|
44
48
|
end
|
45
49
|
|
46
50
|
# Asynchronously publish the specified data to the specified channel for
|
@@ -49,29 +53,7 @@ class Fanout
|
|
49
53
|
# called after publishing is complete and passed the result and error message
|
50
54
|
# if an error was encountered.
|
51
55
|
def publish_async(channel, data, id=nil, prev_id=nil, callback=nil)
|
52
|
-
pub
|
53
|
-
pub.publish_async(channel, Item.new(JsonObjectFormat.new(data), id,
|
56
|
+
@pub.publish_async(channel, Item.new(JsonObjectFormat.new(data), id,
|
54
57
|
prev_id), callback)
|
55
58
|
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
# An internal method used for retrieving the PubControl instance. The
|
60
|
-
# PubControl instance is saved as a thread variable and if an instance
|
61
|
-
# is not available when this method is called then one will be created.
|
62
|
-
def get_pubcontrol
|
63
|
-
if Thread.current['pubcontrol'].nil?
|
64
|
-
if @ssl
|
65
|
-
scheme = 'https'
|
66
|
-
else
|
67
|
-
scheme = 'http'
|
68
|
-
end
|
69
|
-
pub = PubControlClient.new(
|
70
|
-
'%s://api.fanout.io/realm/%s' % [scheme, @realm])
|
71
|
-
pub.set_auth_jwt({'iss' => @realm}, Base64.decode64(@key))
|
72
|
-
at_exit { pub.finish }
|
73
|
-
Thread.current['pubcontrol'] = pub
|
74
|
-
end
|
75
|
-
return Thread.current['pubcontrol']
|
76
|
-
end
|
77
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fanout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Bokarius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pubcontrol
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1'
|
19
|
+
version: '1.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1'
|
26
|
+
version: '1.2'
|
27
27
|
description: A Ruby convenience library for publishing messages to Fanout.io using
|
28
28
|
the EPCP protocol
|
29
29
|
email: bokarius@comcast.net
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.
|
56
|
+
rubygems_version: 2.4.5
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: Fanout.io library for Ruby
|