@@ -45,6 +45,17 @@ NSIDs to make calls, passing input as a dict and parameters as kwargs:
4545 Note that ``- `` characters in method NSIDs are converted to ``_ ``\ s, eg
4646the call above is for the method ``com.example.my-query ``.
4747
48+ `Event stream methods with type
49+ ``subscription <https://atproto.com/specs/event-stream>`__ are
50+ generators that ``yield `` (header, payload) tuples sent by the server.
51+ They take parameters as kwargs, but no positional ``input ``.
52+
53+ ::
54+
55+ for header, msg in client.com.example.count(start=1, end=10):
56+ print(header['t'])
57+ print(msg['num'])
58+
4859Server
4960------
5061
@@ -64,8 +75,8 @@ to call them, whether from your web framework or anywhere else.
6475 server = Server(lexicons)
6576
6677 @server.method (' com.example.my-query' )
67- def my_query_hander (input , ** params ):
68- output = {' foo' : input [' foo' ], ' b' : params[ ' param_a ' ] + 1 }
78+ def my_query (input , num = None ):
79+ output = {' foo' : input [' foo' ], ' b' : num + 1 }
6980 return output
7081
7182 # Extract nsid and decode query parameters from an HTTP request,
@@ -76,6 +87,28 @@ to call them, whether from your web framework or anywhere else.
7687 output = server.call(nsid, input , ** params)
7788 response.write_json(output)
7889
90+ You can also register a method handler with
91+ `Server.register <https://lexrpc.readthedocs.io/en/latest/source/lexrpc.html#lexrpc.server.Server.register >`__:
92+
93+ ::
94+
95+ server.register('com.example.my-query', my_query_handler)
96+
97+ `Event stream methods with type
98+ ``subscription <https://atproto.com/specs/event-stream>`__ should be
99+ generators that ``yield `` frames to send to the client. `Each frame is a
100+ ``(header dict, payload dict)``
101+ tuple <https://atproto.com/specs/event-stream#framing>`__ that will be
102+ DAG-CBOR encoded and sent to the websocket client. Subscription methods
103+ take parameters as kwargs, but no positional ``input ``.
104+
105+ ::
106+
107+ @server.method('com.example.count')
108+ def count(start=None, end=None):
109+ for num in range(start, end):
110+ yield {'num': num}
111+
79112Flask server
80113------------
81114
126159- `extensions <https://atproto.com/guides/lexicon#extensibility >`__. is
127160 there anything to do? ah, `they’re currently TODO in the
128161 spec <https://atproto.com/specs/xrpc#todos> `__.
129- - `“binary blob” support. <https://atproto.com/specs/xrpc >`__ currently
130- undefined ish? is it based on the ``encoding `` field?
131162- `authentication, currently TODO in the
132163 spec <https://atproto.com/specs/xrpc#todos> `__
133164
@@ -251,6 +282,18 @@ Here’s how to package, test, and ship a new release.
251282Changelog
252283---------
253284
285+ 0.3 - 2023-08-29
286+ ~~~~~~~~~~~~~~~~
287+
288+ - Add array type support.
289+ - Add support for non-JSON input and output encodings.
290+ - Add ``subscription `` method type support over websockets.
291+ - Add ``headers `` kwarg to ``Client `` constructor.
292+ - Add new ``Server.register `` method for manually registering handlers.
293+ - Bug fix for server ``@method `` decorator.
294+
295+ .. _section-1 :
296+
2542970.2 - 2023-03-13
255298~~~~~~~~~~~~~~~~
256299
@@ -266,7 +309,7 @@ put more effort into matching and fully implementing them. Stay tuned!
266309 format <https://github.com/snarfed/atproto/commit/63b9873bb1699b6bce54e7a8d3db2fcbd2cfc5ab> `__.
267310 Original format is no longer supported.
268311
269- .. _section-1 :
312+ .. _section-2 :
270313
2713140.1 - 2022-12-13
272315~~~~~~~~~~~~~~~~
0 commit comments