Skip to main content

CosmosDBSQLBackend

CosmosDB/SQL backend for Celery.

Attributes​

AttributeTypeDescription
_endpointstringThe HTTPS or HTTP URL of the CosmosDB service endpoint used for API requests.
_keystringThe master key used for authenticating requests to the CosmosDB service.
_database_namestringThe name of the CosmosDB database where Celery task data is stored.
_collection_namestringThe name of the CosmosDB collection used to store key-value pairs.
_consistency_levelConsistencyLevelThe consistency level for CosmosDB operations, which must be a valid member of the ConsistencyLevel enum.
_max_retry_attemptsintegerThe maximum number of retry attempts for failed CosmosDB requests.
_max_retry_wait_timeintegerThe maximum time in seconds to wait between retry attempts for CosmosDB operations.
_clientReturn 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_linkstringThe relative URI path for the database resource used in CosmosDB API calls.
_collection_linkstringThe 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​

NameTypeDescription
urlstring = NoneThe connection URL containing the host and master key.
database_namestring = NoneThe name of the CosmosDB database to use.
collection_namestring = NoneThe name of the CosmosDB collection to use.
consistency_levelstring = NoneThe consistency level for operations (e.g., 'Session', 'Strong').
max_retry_attemptsint = NoneMaximum number of retry attempts for failed requests.
max_retry_wait_timeint = NoneMaximum wait time in seconds for retries.
*argsanyVariable length argument list passed to the parent class.
**kwargsanyArbitrary keyword arguments passed to the parent class.

Methods​


get()​

@classmethod
def get(
key: string
) - > any

Read the value stored at the given key.

Parameters​

NameTypeDescription
keystringThe key for which to read the value.

Returns​

TypeDescription
anyThe 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​

NameTypeDescription
keystringThe key at which to store the value.
valueanyThe value to store.

Returns​

TypeDescription
nullnull

mget()​

@classmethod
def mget(
keys: list
) - > list

Read all the values for the provided keys.

Parameters​

NameTypeDescription
keyslistThe list of keys to read.

Returns​

TypeDescription
listA 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​

NameTypeDescription
keystringThe key of the value to delete.

Returns​

TypeDescription
nullnull