Typed protocols¶
Typed views of task endpoints and the option TypedDicts. See the
Type safety guide for usage.
fastapi_gcp_tasks.protocols ¶
TaskDefaultOptions ¶
Bases: TypedDict
Options accepted by the task_default_options decorator (shared by sync and async delayed routes).
client is the only delay option not accepted here, because its type differs
between the sync and async route builders.
DelayOptions ¶
AsyncDelayOptions ¶
Bases: TaskDefaultOptions
Per-call overrides accepted by .options() on an async delayed task endpoint.
SchedulerOptions ¶
Bases: TypedDict
Per-call overrides accepted by .scheduler() on a scheduled task endpoint.
AsyncSchedulerOptions ¶
Bases: TypedDict
Per-call overrides accepted by .scheduler() on an async scheduled task endpoint.
AsyncDelayerHandle ¶
Bases: Protocol[P]
A configured async delayer bound to an endpoint's signature.
delay
async
¶
Create the task on Cloud Tasks. Call with keyword arguments matching the endpoint.
SchedulerHandle ¶
Bases: Protocol[P]
A configured scheduler bound to an endpoint's signature.
schedule ¶
Create (or update) the job on Cloud Scheduler. Call with keyword arguments matching the endpoint.
AsyncSchedulerHandle ¶
Bases: Protocol[P]
A configured async scheduler bound to an endpoint's signature.
schedule
async
¶
Create (or update) the job on Cloud Scheduler. Call with keyword arguments matching the endpoint.
DelayedTask ¶
Bases: Protocol[P, R]
Typed view of an endpoint registered on a DelayedRouteBuilder route.
The .delay and .options attributes are attached at route registration
time, so plain function annotations can't see them. Apply as_delayed_task
as the innermost decorator to give the endpoint this type.
AsyncDelayedTask ¶
Bases: Protocol[P, R]
Typed view of an endpoint registered on an AsyncDelayedRouteBuilder route.
Apply as_async_delayed_task as the innermost decorator to give the
endpoint this type.
ScheduledTask ¶
Bases: Protocol[P, R]
Typed view of an endpoint registered on a ScheduledRouteBuilder route.
Apply as_scheduled_task as the innermost decorator to give the endpoint
this type.
AsyncScheduledTask ¶
Bases: Protocol[P, R]
Typed view of an endpoint registered on an AsyncScheduledRouteBuilder route.
Apply as_async_scheduled_task as the innermost decorator to give the
endpoint this type.
ensure_known_options ¶
Raise TypeError if options contains keys not declared on the allowed TypedDict.
Type checkers already reject unknown keys statically; this keeps unchecked callers failing fast at runtime instead of silently dropping options.
Source code in fastapi_gcp_tasks/protocols.py
as_delayed_task ¶
Identity cast that types an endpoint as a DelayedTask.
Apply as the innermost decorator (below the router decorator) so type
checkers see .delay and .options with the endpoint's own signature:
@delayed_router.post("/hello")
@as_delayed_task
def hello(p: Payload) -> None: ...
hello.delay(p=Payload(...)) # statically checked
Source code in fastapi_gcp_tasks/protocols.py
as_async_delayed_task ¶
Identity cast that types an endpoint as an AsyncDelayedTask. See as_delayed_task.
as_scheduled_task ¶
Identity cast that types an endpoint as a ScheduledTask. See as_delayed_task.
as_async_scheduled_task ¶
Identity cast that types an endpoint as an AsyncScheduledTask. See as_delayed_task.