Skip to content

Fix python syntax in README examples #34

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

Merged
merged 1 commit into from
Jul 9, 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
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ insert_res = client.insert(
insert_opts=riverqueue.InsertOpts(
max_attempts=17,
priority=3,
queue: "my_queue",
tags: ["custom"]
queue="my_queue",
tags=["custom"]
),
)
```
Expand All @@ -80,10 +80,10 @@ insert_res = client.insert(
SortArgs(strings=["whale", "tiger", "bear"]),
insert_opts=riverqueue.InsertOpts(
unique_opts=riverqueue.UniqueOpts(
by_args: True,
by_args=True,
by_period=15*60,
by_queue: True,
by_state: [riverqueue.JobState.AVAILABLE]
by_queue=True,
by_state=[riverqueue.JobState.AVAILABLE]
)
),
)
Expand All @@ -100,7 +100,7 @@ insert_res.unique_skipped_as_duplicated
Unique job insertion takes a Postgres advisory lock to make sure that its uniqueness check still works even if two conflicting insert operations are occurring in parallel. Postgres advisory locks share a global 64-bit namespace, which is a large enough space that it's unlikely for two advisory locks to ever conflict, but to _guarantee_ that River's advisory locks never interfere with an application's, River can be configured with a 32-bit advisory lock prefix which it will use for all its locks:

```python
client = riverqueue.Client(riversqlalchemy.Driver(engine), advisory_lock_prefix: 123456)
client = riverqueue.Client(riversqlalchemy.Driver(engine), advisory_lock_prefix=123456)
```

Doing so has the downside of leaving only 32 bits for River's locks (64 bits total - 32-bit prefix), making them somewhat more likely to conflict with each other.
Expand All @@ -111,17 +111,17 @@ Use `#insert_many` to bulk insert jobs as a single operation for improved effici

```python
num_inserted = client.insert_many([
SimpleArgs(job_num: 1),
SimpleArgs(job_num: 2)
SimpleArgs(job_num=1),
SimpleArgs(job_num=2)
])
```

Or with `InsertManyParams`, which may include insertion options:

```python
num_inserted = client.insert_many([
InsertManyParams(args=SimpleArgs.new(job_num: 1), insert_opts=riverqueue.InsertOpts.new(max_attempts=5)),
InsertManyParams(args=SimpleArgs.new(job_num: 2), insert_opts=riverqueue.InsertOpts.new(queue="high_priority"))
InsertManyParams(args=SimpleArgs(job_num=1), insert_opts=riverqueue.InsertOpts(max_attempts=5)),
InsertManyParams(args=SimpleArgs(job_num=2), insert_opts=riverqueue.InsertOpts(queue="high_priority"))
])
```

Expand Down
Loading