CosmosDBSQLBackend
CosmosDB/SQL backend for Celery.
Attributes
| Attribute | Type | Description |
|---|---|---|
| _endpoint | string | The HTTPS or HTTP URL of the CosmosDB service endpoint used for API requests. |
| _key | string | The master key used for authenticating requests to the CosmosDB service. |
| _database_name | string | The name of the CosmosDB database where Celery task data is stored. |
| _collection_name | string | The name of the CosmosDB collection used to store key-value pairs. |
| _consistency_level | ConsistencyLevel | The consistency level for CosmosDB operations, which must be a valid member of the ConsistencyLevel enum. |
| _max_retry_attempts | integer | The maximum number of retry attempts for failed CosmosDB requests. |
| _max_retry_wait_time | integer | The maximum time in seconds to wait between retry attempts for CosmosDB operations. |
| _client | Return the CosmosDB/SQL client. If this is the first call to the property, the client is created and the database and collection are initialized if they don't yet exist. | |
| _database_link | string | The relative URI path for the database resource used in CosmosDB API calls. |
| _collection_link | string | The relative URI path for the collection resource used in CosmosDB API calls. |
Constructor
Signature
def CosmosDBSQLBackend(
url: string = None,
database_name: string = None,
collection_name: string = None,
consistency_level: string = None,
max_retry_attempts: int = None,
max_retry_wait_time: int = None,
*args: any,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| url | string = None | The connection URL containing the host and master key. |
| database_name | string = None | The name of the CosmosDB database to use. |
| collection_name | string = None | The name of the CosmosDB collection to use. |
| consistency_level | string = None | The consistency level for operations (e.g., 'Session', 'Strong'). |
| max_retry_attempts | int = None | Maximum number of retry attempts for failed requests. |
| max_retry_wait_time | int = None | Maximum wait time in seconds for retries. |
| *args | any | Variable length argument list passed to the parent class. |
| **kwargs | any | Arbitrary keyword arguments passed to the parent class. |
Methods
get()
@classmethod
def get(
key: string
) - > any
Read the value stored at the given key.
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | The key for which to read the value. |
Returns
| Type | Description |
|---|---|
any | The value stored within the document, or None if the document is not found |
set()
@classmethod
def set(
key: string,
value: any
) - > null
Store a value for a given key.
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | The key at which to store the value. |
| value | any | The value to store. |
Returns
| Type | Description |
|---|---|
null | null |
mget()
@classmethod
def mget(
keys: list
) - > list
Read all the values for the provided keys.
Parameters
| Name | Type | Description |
|---|---|---|
| keys | list | The list of keys to read. |
Returns
| Type | Description |
|---|---|
list | A list of values corresponding to the provided keys in the same order |
delete()
@classmethod
def delete(
key: string
) - > null
Delete the value at a given key.
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | The key of the value to delete. |
Returns
| Type | Description |
|---|---|
null | null |