crate.operator.utils.kopf module¶
- class crate.operator.utils.kopf.Notification¶
Bases:
TypedDict
-
event:
WebhookEvent
¶
-
payload:
WebhookSubPayload
¶
-
status:
WebhookStatus
¶
-
event:
- class crate.operator.utils.kopf.StateBasedSubHandler(namespace, name, ref, context, depends_on=None, run_on_dep_failures=False)¶
Bases:
ABC
A handler capable of waiting for other handlers to finish.
This can be expressed as a set of dependencies passed to the
depends_on
parameter of the constructor.Basically, we wrap an actual handler here. Before executing the actual one, we check if the dependencies have completed yet - we do this by checking the statuses of those dependent handlers, as stored in the
status
field of the CrateDB resource.- schedule_notification(event, payload, status)¶
- Parameters
event (
WebhookEvent
) –payload (
WebhookSubPayload
) –status (
WebhookStatus
) –
- async send_notification_now(logger, event, payload, status)¶
- Parameters
logger (
Logger
) –event (
WebhookEvent
) –payload (
WebhookSubPayload
) –status (
WebhookStatus
) –
- async crate.operator.utils.kopf.send_webhook_notification(namespace, name, logger, event, payload, status)¶
- Parameters
namespace (
str
) –name (
str
) –logger (
Logger
) –event (
WebhookEvent
) –payload (
WebhookSubPayload
) –status (
WebhookStatus
) –
- crate.operator.utils.kopf.subhandler_partial(awaitable, *args, **kwargs)¶
A utility function to create a partial coroutine suitable for
kopf.register
.When scheduling asynchronous sub-handlers in Kopf, one needs to be careful to not create coroutines when they’re not used in an execution cycle.
>>> async def some_coro(arg1, kwarg1=None): ... pass >>> kopf.register( ... fn=subhandler_partial( ... some_coro, ... 'abc', ... kwarg1='foo', ... ), ... id="some-id", ... )
- Parameters
awaitable (
Callable
) –