Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions airflow-core/docs/authoring-and-scheduling/language-sdks/go.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ Dag, and the ``task_id`` must match a ``@task.stub`` function in that Dag. Neith
function name, so a handler can be named whatever reads best in Go.

``TaskHandler`` also checks the signature of the function it is given and panics if the check fails -- for
instance when the function does not take an ``airflow.Context`` first, or does not return an ``error``.
Because ``main`` registers every handler before ``Serve``, a mistake stops the executable as soon as it
starts rather than when the task first runs.
instance when the function does not take an ``airflow.Context`` first, does not return an ``error``, or
declares a variadic ``...`` parameter, which no stub argument can fill. Because ``main`` registers every
handler before ``Serve``, a mistake stops the executable as soon as it starts rather than when the task
first runs.

``Serve`` closes registration: a ``Register`` left below it in ``main`` panics rather than adding a handler
to the map the runtime is already answering from, so what a bundle can run never depends on how far
``main`` has got.

A package that defines task handlers of its own can export them as a ``[]airflow.Registerable`` for ``main``
to pass on with ``bundle.Register(reports.Handlers()...)``.
Expand Down
6 changes: 5 additions & 1 deletion go-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ func main() {

`TaskHandler` names the `dag_id` and the `task_id` explicitly; neither is derived from the Go function
name, so a handler can be called whatever reads best in Go. It checks the signature of the function and
panics if the check fails, which stops the executable as it starts rather than when the task first runs.
panics if the check fails -- a variadic `...` parameter, which no stub argument can fill, is one such
failure -- so the executable stops as it starts rather than when the task first runs. `Serve` then closes
registration, so a `Register` left below it in `main` panics instead of changing what the running bundle
answers for.

A package that defines handlers of its own can export them as a `[]airflow.Registerable` for `main` to
pass on with `bundle.Register(reports.Handlers()...)`.

Expand Down