Skip to main content

GCSBackend

Google Cloud Storage task result backend.

Uses Firestore for chord ref count.

Attributes

AttributeTypeDescription
implements_incrboolean = TrueBoolean flag indicating that this backend supports atomic increment operations used for chord synchronization.
supports_native_joinboolean = TrueBoolean flag indicating that this backend can perform native join operations for task groups.

Constructor

Signature

def GCSBackend(
**kwargs: dict
) - > null

Parameters

NameTypeDescription
**kwargsdictArbitrary keyword arguments passed to the base class constructor.

Methods


firestore_client()

@classmethod
def firestore_client() - > google.cloud.firestore.Client

Returns a firestore client.

Returns

TypeDescription
google.cloud.firestore.ClientA thread-safe Firestore client instance associated with the configured project.

incr()

@classmethod
def incr(
key: bytes
) - > int

Increments the chord counter for a specific key in Firestore using an atomic operation with built-in retry logic for conflicts.

Parameters

NameTypeDescription
keybytesThe unique identifier for the chord tracking document in Firestore.

Returns

TypeDescription
intThe new integer value of the chord counter after the increment.

on_chord_part_return()

@classmethod
def on_chord_part_return(
request: object,
state: string,
result: any
) - > null

Chord part return callback. Called for each task in the chord. Increments the counter stored in Firestore. If the counter reaches the number of tasks in the chord, the callback is called. If the callback raises an exception, the chord is marked as errored. If the callback returns a value, the chord is marked as successful.

Parameters

NameTypeDescription
requestobjectThe request object for the individual task part, containing group and chord metadata.
statestringThe current execution state of the task part.
resultanyThe return value of the individual task part.

Returns

TypeDescription
nullnull