Skip to content

Commit

Permalink
simplify layout
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-emelin committed Feb 13, 2024
1 parent 53e2670 commit 0f417c2
Show file tree
Hide file tree
Showing 16 changed files with 424 additions and 475 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ from cent import Client

Required init arguments:

* `api_url` (str) - Centrifugo HTTP API URL address
* `api_key` (str) - Centrifugo HTTP API key
* `api_url` (`str`) - Centrifugo HTTP API URL address, for example, `http://localhost:8000/api`
* `api_key` (`str`) - Centrifugo HTTP API key

Optional arguments:

* `request_timeout` (float) - base timeout for all requests in seconds, default is 10 seconds.
* `session` (requests.Session) - custom `requests` session to use.
* `timeout` (`float`) - base timeout for all requests in seconds, default is 10 seconds.
* `session` (`requests.Session`) - custom `requests` session to use.

Example:

Expand All @@ -56,13 +56,13 @@ from cent import AsyncClient

Required init arguments:

* `api_url` (str) - Centrifugo HTTP API URL address
* `api_key` (str) - Centrifugo HTTP API key
* `api_url` (`str`) - Centrifugo HTTP API URL address, for example, `http://localhost:8000
* `api_key` (`str`) - Centrifugo HTTP API key

Optional arguments:

* `request_timeout` (float) - base timeout for all requests in seconds, default is 10 seconds.
* `session` (aiohttp.ClientSession) - custom `aiohttp` session to use.
* `timeout` (`float`) - base timeout for all requests in seconds, default is 10 seconds.
* `session` (`aiohttp.ClientSession`) - custom `aiohttp` session to use.

Example:

Expand Down Expand Up @@ -91,9 +91,9 @@ This library raises exceptions if sth goes wrong. All exceptions are subclasses
* `CentNetworkError` - raised in case of network related errors (connection refused)
* `CentTransportError` - raised in case of transport related errors (HTTP status code is not 2xx)
* `CentTimeoutError` - raised in case of timeout
* `CentUnauthorizedError` - raised in case of unauthorized access
* `CentUnauthorizedError` - raised in case of unauthorized access (signal of invalid API key)
* `CentDecodeError` - raised in case of server response decoding error
* `CentAPIError` - raised in case of API error (error returned by Centrifugo itself, you can inspect code and message in this case)
* `CentResponseError` - raised in case of API response error (i.e. error returned by Centrifugo itself, you can inspect code and message returned by Centrifugo in this case)

## For contributors

Expand Down Expand Up @@ -123,3 +123,11 @@ To run benchmarks, run:
```bash
make bench
```

## Migrate to Cent v5

Cent v5 contains the following notable changes compared to Cent v4:

* Constructor slightly changed, refer to the examples above.
* Base exception class is now `CentError` instead of `CentException`, exceptions SDK raises were refactored.
* To send multiple commands in one HTTP request SDK provides `batch` method.
10 changes: 3 additions & 7 deletions cent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Client,
AsyncClient,
)
from cent.requests import (
from cent.dto import (
BroadcastRequest,
PublishRequest,
SubscribeRequest,
Expand All @@ -16,8 +16,6 @@
DisconnectRequest,
InfoRequest,
BatchRequest,
)
from cent.results import (
PublishResult,
BroadcastResult,
SubscribeResult,
Expand All @@ -31,8 +29,6 @@
DisconnectResult,
InfoResult,
BatchResult,
)
from cent.types import (
StreamPosition,
ChannelOptionsOverride,
Disconnect,
Expand All @@ -48,7 +44,7 @@
CentTransportError,
CentUnauthorizedError,
CentDecodeError,
CentAPIError,
CentResponseError,
)

__all__ = (
Expand All @@ -58,10 +54,10 @@
"BoolValue",
"BroadcastRequest",
"BroadcastResult",
"CentAPIError",
"CentDecodeError",
"CentError",
"CentNetworkError",
"CentResponseError",
"CentTransportError",
"CentUnauthorizedError",
"ChannelOptionsOverride",
Expand Down
60 changes: 0 additions & 60 deletions cent/base.py

This file was deleted.

Loading

0 comments on commit 0f417c2

Please sign in to comment.