Skip to content

Commit 5fddc1e

Browse files
committed
release v0.3
1 parent 07d7e0c commit 5fddc1e

4 files changed

Lines changed: 75 additions & 32 deletions

File tree

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -147,33 +147,33 @@ Here's how to package, test, and ship a new release.
147147
Test code to paste into the interpreter:
148148

149149
```py
150-
from lexrpc import Server
151-
152-
server = Server([{
153-
'lexicon': 1,
154-
'id': 'io.example.ping',
155-
'defs': {
156-
'main': {
157-
'type': 'query',
158-
'description': 'Ping the server',
159-
'parameters': {'message': { 'type': 'string' }},
160-
'output': {
161-
'encoding': 'application/json',
162-
'schema': {
163-
'type': 'object',
164-
'required': ['message'],
165-
'properties': {'message': { 'type': 'string' }},
166-
},
150+
from lexrpc import Server
151+
152+
server = Server([{
153+
'lexicon': 1,
154+
'id': 'io.example.ping',
155+
'defs': {
156+
'main': {
157+
'type': 'query',
158+
'description': 'Ping the server',
159+
'parameters': {'message': { 'type': 'string' }},
160+
'output': {
161+
'encoding': 'application/json',
162+
'schema': {
163+
'type': 'object',
164+
'required': ['message'],
165+
'properties': {'message': { 'type': 'string' }},
167166
},
168167
},
169168
},
170-
}])
169+
},
170+
}])
171171
172-
@server.method('io.example.ping')
173-
def ping(input, message=''):
174-
return {'message': message}
172+
@server.method('io.example.ping')
173+
def ping(input, message=''):
174+
return {'message': message}
175175
176-
print(server.call('io.example.ping', {}, message='hello world'))
176+
print(server.call('io.example.ping', {}, message='hello world'))
177177
```
178178
1. Tag the release in git. In the tag message editor, delete the generated comments at bottom, leave the first line blank (to omit the release "title" in github), put `### Notable changes` on the second line, then copy and paste this version's changelog contents below it.
179179
@@ -193,7 +193,7 @@ Here's how to package, test, and ship a new release.
193193
194194
## Changelog
195195
196-
### 0.3 - unreleased
196+
### 0.3 - 2023-08-29
197197
198198
* Add array type support.
199199
* Add support for non-JSON input and output encodings.

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
# built documents.
8888
#
8989
# The short X.Y version.
90-
version = '0.2'
90+
version = '0.3'
9191
# The full version, including alpha/beta/rc tags.
92-
release = '0.2'
92+
release = '0.3'
9393

9494
# The language for content autogenerated by Sphinx. Refer to documentation
9595
# for a list of supported languages.

docs/index.rst

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
4646
the 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+
4859
Server
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+
79112
Flask server
80113
------------
81114

@@ -126,8 +159,6 @@ TODO
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.
251282
Changelog
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+
254297
0.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

271314
0.1 - 2022-12-13
272315
~~~~~~~~~~~~~~~~

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packages = ['lexrpc']
99

1010
[project]
1111
name = 'lexrpc'
12-
version = '0.2'
12+
version = '0.3'
1313
authors = [
1414
{ name='Ryan Barrett', email='lexrpc@ryanb.org' },
1515
]
@@ -18,6 +18,7 @@ readme = 'README.md'
1818
requires-python = '>=3.7'
1919
keywords = ['XRPC', 'Lexicon', 'AT Protocol', 'ATP']
2020
dependencies = [
21+
'dag-cbor',
2122
'jsonschema>=4.0',
2223
'requests>=2.0',
2324
'simple-websocket',
@@ -37,7 +38,6 @@ classifiers = [
3738

3839
[project.optional-dependencies]
3940
flask = [
40-
'dag-cbor',
4141
'Flask>=2.0',
4242
'flask-sock',
4343
]

0 commit comments

Comments
 (0)