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

make api more consistent with other clients #175

Merged
merged 1 commit into from
Sep 22, 2020

Conversation

brianshannan
Copy link
Collaborator

This is a lot of breaking changes, so let me know if you're opposed to any of them.

This commit is an attempt to make the api of this client more closely
match the api of nats clients in other languages. Below is a non
exhaustive list of the changes made.

  • Return subscriptions from subscribe() instead of a subscription id
  • Allow iterating over messages in subscription with async for. To use, don't specify a callback when subscribing
  • Move unsubscribe() and drain(sid=sid) to the subscription class
  • Remove publish_request(), publish() now has a reply kwarg
  • Remove auto_unsubscribe(), subscribe() already had a kwarg for this
  • Remove support for executing synchronous callbacks
    • Remove subscribe_async()
    • Remove is_async kwarg from subscribe()
  • Remove support for executing callbacks as tasks
  • Remove multiple response functionality from request()
  • Remove timed_request(), name is very misleading as all requests are timed. This was really old style requests, moved to a kwarg of request() called old_style
  • Made connection context manager async
  • Various internal code reoganizations
  • Various doc cleanups
  • Cleaned up example code

@wallyqs @charliestrawn

This commit is an attempt to make the api of this client more closely
match the api of nats clients in other languages. Below is a non
exhaustive list of the changes made.

- Return subscriptions from `subscribe()` instead of a subscription id
- Allow iterating over messages in subscription with `async for`. To use, don't specify a callback when subscribing
- Move `unsubscribe()` and `drain(sid=sid)` to the subscription class
- Remove `publish_request()`, `publish()` now has a `reply` kwarg
- Remove `auto_unsubscribe()`, `subscribe()` already had a kwarg for this
- Remove support for executing synchronous callbacks
  - Remove `subscribe_async()`
  - Remove `is_async` kwarg from `subscribe()`
- Remove support for executing callbacks as tasks
- Remove multiple response functionality from `request()`
- Remove `timed_request()`, name is very misleading as all requests are timed. This was really old style requests, moved to a kwarg of `request()` called `old_style`
- Made connection context manager async
- Various internal code reoganizations
- Various doc cleanups
- Cleaned up example code
Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think these are all very welcome changes for the v1 client.

@brianshannan brianshannan merged commit 688254c into nats-io:v1-dev Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants