lightstreamer 0.11 → 0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +2 -2
- data/lib/lightstreamer.rb +1 -0
- data/lib/lightstreamer/session.rb +25 -3
- data/lib/lightstreamer/subscription.rb +8 -13
- data/lib/lightstreamer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 979c7fa279f1b55d71b9525b8a8f5b67aaf1c45e
|
4
|
+
data.tar.gz: 15a5a203a5012063ab4b795d60486bc7c9882cad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8af68aba835e410dd291393dc187a1ac2af83d9406dfb34278c0ec2d5ecbb24cbb41cea1cfbe198407a21e47e1229a9ded930ec3ed394539f7caa63caf2dbc64
|
7
|
+
data.tar.gz: 8246eea6cf6d897232791b5a225e5d75f97bf954ca5c0742c63f86ac75225c657ee119ea5c1ea0b6308b68ef801e4f1bfb517c172d5a85b5372ab479ef3d4021
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
# Lightstreamer Changelog
|
2
2
|
|
3
|
+
### 0.12 — August 20, 2016
|
4
|
+
|
5
|
+
- Added `Lightstreamer::Session#remove_subscriptions`
|
6
|
+
- Removed `Lightstreamer::Subscription#session`, subscriptions now hold a weak reference to their session in order to
|
7
|
+
prevent a circular reference
|
8
|
+
|
3
9
|
### 0.11 — August 20, 2016
|
4
10
|
|
5
11
|
- Added `Lightstreamer::Session#stop_subscriptions` for stopping multiple subscriptions in one request
|
6
12
|
- Renamed `Lightstreamer::Session#bulk_subscription_start` to `Lightstreamer::Session#start_subscriptions`
|
7
13
|
- Added support for combining all subscription actions via `Lightstreamer::Session#perform_subscription_actions`
|
8
14
|
which allows subscription start, unsilence and stop requests to be easily bundled together
|
9
|
-
- Fixed `Subscription#id` only being callable on the main thread
|
15
|
+
- Fixed `Lightstreamer::Subscription#id` only being callable on the main thread
|
10
16
|
|
11
17
|
### 0.10 — August 5, 2016
|
12
18
|
|
data/README.md
CHANGED
@@ -40,8 +40,8 @@ $ gem install lightstreamer
|
|
40
40
|
|
41
41
|
The two primary classes that make up the public API are:
|
42
42
|
|
43
|
-
- [`Lightstreamer::Session`](http://www.rubydoc.info/github/rviney/lightstreamer/Lightstreamer/Session)
|
44
|
-
- [`Lightstreamer::Subscription`](http://www.rubydoc.info/github/rviney/lightstreamer/Lightstreamer/Subscription)
|
43
|
+
- [`Lightstreamer::Session`](http://www.rubydoc.info/github/rviney/lightstreamer/master/Lightstreamer/Session)
|
44
|
+
- [`Lightstreamer::Subscription`](http://www.rubydoc.info/github/rviney/lightstreamer/master/Lightstreamer/Subscription)
|
45
45
|
|
46
46
|
The following code demonstrates how to create a Lightstreamer session, build a subscription, then use a thread-safe
|
47
47
|
queue to print streaming output as it arrives.
|
data/lib/lightstreamer.rb
CHANGED
@@ -92,7 +92,8 @@ module Lightstreamer
|
|
92
92
|
@stream_connection && @stream_connection.session_id
|
93
93
|
end
|
94
94
|
|
95
|
-
# Disconnects this Lightstreamer session and terminates the session on the server. All worker threads are exited
|
95
|
+
# Disconnects this Lightstreamer session and terminates the session on the server. All worker threads are exited,
|
96
|
+
# and all subscriptions created during the connected session can no longer be used.
|
96
97
|
def disconnect
|
97
98
|
control_request LS_op: :destroy if @stream_connection
|
98
99
|
|
@@ -102,6 +103,7 @@ module Lightstreamer
|
|
102
103
|
@processing_thread.exit if @processing_thread
|
103
104
|
|
104
105
|
@subscriptions.each { |subscription| subscription.after_control_request :stop }
|
106
|
+
@subscriptions = []
|
105
107
|
|
106
108
|
@processing_thread = @stream_connection = nil
|
107
109
|
end
|
@@ -147,9 +149,29 @@ module Lightstreamer
|
|
147
149
|
#
|
148
150
|
# @param [Subscription] subscription The subscription to stop and remove from this session.
|
149
151
|
def remove_subscription(subscription)
|
150
|
-
subscription
|
152
|
+
errors = remove_subscriptions [subscription]
|
153
|
+
|
154
|
+
raise errors.first if errors.first
|
155
|
+
end
|
156
|
+
|
157
|
+
# Stops the specified subscriptions and removes them from this session. To just stop subscriptions with the option
|
158
|
+
# of restarting them at a later date use {#stop_subscriptions} or {Subscription#stop}. The return value is an array
|
159
|
+
# with one entry per subscription and indicates the error state returned by the server for that subscription's stop
|
160
|
+
# request, or `nil` if no error occurred.
|
161
|
+
#
|
162
|
+
# @param [Array<Subscription>] subscriptions The subscriptions to stop and remove from this session.
|
163
|
+
#
|
164
|
+
# @return [Array<LightstreamerError, nil>]
|
165
|
+
def remove_subscriptions(subscriptions)
|
166
|
+
errors = stop_subscriptions subscriptions
|
167
|
+
|
168
|
+
@mutex.synchronize do
|
169
|
+
subscriptions.reject(&:active).each do |subscription|
|
170
|
+
@subscriptions.delete subscription
|
171
|
+
end
|
172
|
+
end
|
151
173
|
|
152
|
-
|
174
|
+
errors
|
153
175
|
end
|
154
176
|
|
155
177
|
# This method performs {Subscription#start} on all the passed subscriptions. Calling {Subscription#start} on each
|
@@ -4,11 +4,6 @@ module Lightstreamer
|
|
4
4
|
# streaming subscription data can be consumed by registering an asynchronous data callback using {#on_data}, or by
|
5
5
|
# polling using {#item_data}.
|
6
6
|
class Subscription
|
7
|
-
# The session that this subscription is associated with.
|
8
|
-
#
|
9
|
-
# @return [Session]
|
10
|
-
attr_reader :session
|
11
|
-
|
12
7
|
# The names of the items to subscribe to.
|
13
8
|
#
|
14
9
|
# @return [Array]
|
@@ -58,7 +53,7 @@ module Lightstreamer
|
|
58
53
|
def initialize(session, options)
|
59
54
|
@mutex = Mutex.new
|
60
55
|
|
61
|
-
@session = session
|
56
|
+
@session = WeakRef.new session
|
62
57
|
@items = options.fetch(:items)
|
63
58
|
@fields = options.fetch(:fields)
|
64
59
|
@mode = options.fetch(:mode).to_sym
|
@@ -97,7 +92,7 @@ module Lightstreamer
|
|
97
92
|
def start(options = {})
|
98
93
|
return if @active
|
99
94
|
|
100
|
-
session.control_request control_request_options(:start, options)
|
95
|
+
@session.control_request control_request_options(:start, options)
|
101
96
|
after_control_request :start
|
102
97
|
end
|
103
98
|
|
@@ -105,14 +100,14 @@ module Lightstreamer
|
|
105
100
|
# this subscription was not started in silent mode then this method has no effect. If an error occurs then a
|
106
101
|
# {LightstreamerError} subclass will be raised.
|
107
102
|
def unsilence
|
108
|
-
session.control_request control_request_options(:unsilence)
|
103
|
+
@session.control_request control_request_options(:unsilence)
|
109
104
|
after_control_request :unsilence
|
110
105
|
end
|
111
106
|
|
112
107
|
# Stops streaming data for this Lightstreamer subscription. If an error occurs then a {LightstreamerError} subclass
|
113
108
|
# will be raised.
|
114
109
|
def stop
|
115
|
-
session.control_request control_request_options(:stop) if @active
|
110
|
+
@session.control_request control_request_options(:stop) if @active
|
116
111
|
after_control_request :stop
|
117
112
|
end
|
118
113
|
|
@@ -125,7 +120,7 @@ module Lightstreamer
|
|
125
120
|
# details.
|
126
121
|
def maximum_update_frequency=(new_frequency)
|
127
122
|
new_frequency = sanitize_frequency new_frequency
|
128
|
-
session.control_request LS_op: :reconf, LS_table: id, LS_requested_max_frequency: new_frequency if @active
|
123
|
+
@session.control_request LS_op: :reconf, LS_table: id, LS_requested_max_frequency: new_frequency if @active
|
129
124
|
@maximum_update_frequency = new_frequency
|
130
125
|
end
|
131
126
|
|
@@ -224,9 +219,9 @@ module Lightstreamer
|
|
224
219
|
when :start
|
225
220
|
start_control_request_options options
|
226
221
|
when :unsilence
|
227
|
-
{ LS_session: session.session_id, LS_op: :start, LS_table: id }
|
222
|
+
{ LS_session: @session.session_id, LS_op: :start, LS_table: id }
|
228
223
|
when :stop
|
229
|
-
{ LS_session: session.session_id, LS_op: :delete, LS_table: id }
|
224
|
+
{ LS_session: @session.session_id, LS_op: :delete, LS_table: id }
|
230
225
|
end
|
231
226
|
end
|
232
227
|
|
@@ -286,7 +281,7 @@ module Lightstreamer
|
|
286
281
|
|
287
282
|
operation = options[:silent] ? :add_silent : :add
|
288
283
|
|
289
|
-
{ LS_session: session.session_id, LS_op: operation, LS_table: id, LS_mode: mode.to_s.upcase, LS_id: items,
|
284
|
+
{ LS_session: @session.session_id, LS_op: operation, LS_table: id, LS_mode: mode.to_s.upcase, LS_id: items,
|
290
285
|
LS_schema: fields, LS_selector: selector, LS_snapshot: options.fetch(:snapshot, false),
|
291
286
|
LS_requested_max_frequency: maximum_update_frequency, LS_data_adapter: data_adapter }
|
292
287
|
end
|