You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/use.rst
+19-25Lines changed: 19 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -271,14 +271,14 @@ Example:
271
271
272
272
Streaming API
273
273
-------------
274
-
Atlas supports getting results and other events through a stream to get them close to real time. The stream is implemented using WebSockets and the `Socket.IO`_ protocol.
274
+
Atlas supports getting results and other events through a WebSocket stream to get them close to real time. The AtlasStream class provides an interface to this stream, and supports
275
+
both callback-based and iterator-based access.
275
276
276
277
Measurement Results
277
278
^^^^^^^^^^^^^^^^^^^
278
-
Besides fetching results from main API it is possible to get results though streaming API. You have to use AtlasStream object and bind to "result" channel. You can start the a result stream by specifying at least the measurement ID in the stream parameters.
279
-
More details on the available parameters of the stream can be found on the `streaming documentation`_.
279
+
You have to create an AtlasStream object and subscribe to the "result" stream type. More details on the available parameters of the stream can be found on the `streaming documentation`_.
280
280
281
-
Example:
281
+
Example using the callback-interface:
282
282
283
283
.. code:: python
284
284
@@ -295,13 +295,13 @@ Example:
295
295
atlas_stream.connect()
296
296
297
297
# Bind function we want to run with every result message received
#Timeout all subscriptions after 5 secs. Leave seconds empty for no timeout.
304
+
#Process incoming events for 5 seconds, calling the callback defined above.
305
305
# Make sure you have this line after you start *all* your streams
306
306
atlas_stream.timeout(seconds=5)
307
307
@@ -311,33 +311,27 @@ Example:
311
311
312
312
Connection Events
313
313
^^^^^^^^^^^^^^^^^
314
-
Besides results, streaming API supports also probe's connect/disconnect events. Again you have to use AtlasStream object but this time you have to bind to "probe" channel.
315
-
More info about additional parameters can be found on the `streaming documentation`_.
314
+
Besides results, the streaming API also supports probe connect/disconnect events.
315
+
Again you have to create an AtlasStream object, but this time you subscribe to the
316
+
"probestatus" stream type. More info about additional parameters can be found on
317
+
the `streaming documentation`_.
316
318
317
-
Example:
319
+
Example using the iterator-interface:
318
320
319
321
.. code:: python
320
322
321
323
from ripe.atlas.cousteau import AtlasStream
322
324
323
-
defon_result_response(*args):
324
-
"""
325
-
Function that will be called every time we receive a new event.
326
-
Args is a tuple, so you should use args[0] to access the real event.
0 commit comments