Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS-2789] Fix malformed links in Python README #183

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Supported Environment Variables:
* ``FAUNA_ENDPOINT``: The Fauna endpoint to use. For example, ``http://localhost:8443``
* ``FAUNA_SECRET``: The Fauna secret to use.

```python
```python
from fauna import fql
from fauna.client import Client
from fauna.encoding import QuerySuccess
Expand Down Expand Up @@ -280,13 +280,12 @@ for products in pages:

## Event Streaming

The driver supports `Event Streaming <https://docs.fauna.com/fauna/current/learn/streaming>`_.
The driver supports [Event Streaming](https://docs.fauna.com/fauna/current/learn/streaming).

_Start a stream_
### Start a stream

To get a stream token, append ``toStream()`` or ``changesOn()`` to a set from a
`supported source
<https://docs.fauna.com/fauna/current/reference/streaming_reference/#supported-sources>`_.
[supported source](https://docs.fauna.com/fauna/current/reference/streaming_reference/#supported-sources).


To start and subscribe to the stream, pass the stream token to
Expand All @@ -295,20 +294,20 @@ To start and subscribe to the stream, pass the stream token to
```python
from fauna import fql
from fauna.client import Client

client = Client()

response = client.query(fql('''
let set = Product.all()
{
initialPage: set.pageSize(10),
streamToken: set.toStream()
}
'''))

initialPage = response.data['initialPage']
streamToken = response.data['streamToken']

client.stream(streamToken)
```

Expand All @@ -321,7 +320,7 @@ You can also pass a query that produces a stream token directly to
client.stream(query)
```

_Iterate on a stream_
### Iterate on a stream

``Client.stream()`` returns an iterator that emits events as they occur. You can
use a generator expression to iterate through the events:
Expand All @@ -343,7 +342,7 @@ with client.stream(query) as stream:
## ...
```

_Close a stream_
### Close a stream

Use ``<stream>.close()`` to close a stream:

Expand All @@ -356,12 +355,12 @@ with client.stream(query) as stream:
print('Stream event', event)
# ...
count+=1

if (count == 2):
stream.close()
```

_Error handling_
### Error handling

If a non-retryable error occurs when opening or processing a stream, Fauna
raises a ``FaunaException``:
Expand All @@ -383,7 +382,7 @@ try:
except FaunaException as e:
print('error ocurred with stream: ', e)
```
_Stream options_
### Stream options

The client configuration sets default options for the ``Client.stream()``
method.
Expand Down
Loading