Explore a generic Go workflow step runner with hooks
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Tranquilo
- Stack tecnológico
- go
Línea de trabajo
No se nombran archivos ni tests. Empieza validando la Step API propuesta y el modelo de ejecución de los hooks Before/After frente a un workflow real de Go Temporal, incluido el checkpointing y el comportamiento de Continue-As-New. Se considerará terminado cuando haya una API pequeña acordada, un orden de ejecución y decisiones de los hooks definidos, y tests deterministas que cubran resume, skip, fault injection y Continue-As-New.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Explore a small Go helper for Temporal workflows that wraps logical workflow steps and applies reusable checks/hooks before and after executing them.
The initial motivation is making Continue-As-New easier to adopt for workflows that are approaching Temporal's recommended history limits, without forcing developers to manually thread CAN checks and resume logic throughout their workflow code.
This is similar to behaviour Zigflow already gets naturally because workflows are represented as an ordered sequence of tasks with state carried explicitly between them.
Rough shape
Something along these lines:
err := Step(
ctx,
"fetch-account",
func() error {
return workflow.ExecuteActivity(
ctx,
FetchAccount,
accountID,
).Get(ctx, &account)
},
Checkpoint(&state),
ContinueAsNewWhenSuggested(),
ObserveSteps(),
)
The public API should remain small and idiomatic Go:
func Step(
ctx workflow.Context,
id string,
fn func() error,
hooks ...Hook,
) error
Avoid separate pre and post hook arguments. A hook should be able to participate before, after or both.
For example:
type Hook interface {
Before(ctx workflow.Context, step Step) Decision
After(ctx workflow.Context, step Step, result Result) Decision
}
A no-op adapter could make hooks that only implement one side easy to write.
Execution model
Conceptually:
run Before hooks
-> proceed
-> skip step
-> Continue-As-New
-> error
execute Temporal operation
run After hooks
-> proceed
-> request Continue-As-New
-> error
return
Post-hook semantics need some thought. In particular, hook ordering should ideally not become part of correctness. For example, a CAN request from one post hook probably should not prevent another hook from recording state or updating visibility.
Initial built-in hooks
Checkpoint / resume
Carry explicit workflow state containing the current logical position.
For example:
type State struct {
ContinueAsNewStep StepID
// business state...
}
Each logical step needs a stable identifier.
A checkpoint hook can:
- skip steps that were completed in a previous Run
- mark a step as completed after successful execution
- allow a new Run created via Continue-As-New to resume from the correct logical position
Prefer explicit stable IDs such as:
"fetch-account"
"charge-account"
rather than randomly generated UUIDs. Step identifiers become part of durable workflow state and should remain deterministic and stable across replay and Continue-As-New.
The internal mechanism may be better thought of as a cursor, while the overall pattern is checkpointing.
Continue-As-New when suggested
Before starting a new logical step, check Temporal's Continue-As-New recommendation.
If CAN is recommended, return a Continue-As-New result carrying the workflow state and current checkpoint.
This allows CAN to happen automatically at safe logical boundaries rather than requiring checks to be scattered throughout workflow code.
Observability
Potentially provide hooks for things such as:
- logging logical step transitions
- recording the current step
- upserting visibility/search attributes
- measuring logical step duration
These should remain optional and should not introduce surprising workflow behaviour.
Testing hooks
One particularly useful extension is deterministic fault/control injection in workflow tests.
Examples:
FailBefore("charge-account")
ContinueAsNewBefore("charge-account")
RecordExecution(...)
This should make it straightforward to test behaviour such as:
fetch-account -> execute
Continue-As-New
fetch-account -> skip
charge-account -> execute
This provides a useful way to prove that checkpoint/resume behaviour actually works rather than only testing CAN in the happy path.
Extensibility
The library should deliberately expose the same hook API used by built-in behaviour so users can provide their own policies:
Step(
ctx,
"charge-account",
fn,
Checkpoint(&state),
ContinueAsNewWhenSuggested(),
MyCompanyPolicy(),
)
The goal is not to build a large framework. The useful abstraction is simply:
Apply reusable policy at logical workflow-step boundaries.
Possible customer-specific uses might include validation, observability, testing controls or other deterministic workflow-local checks.
Non-goals
Avoid turning this into generic Temporal magic.
Initially do not:
- automatically heartbeat Activities
- silently mutate retry policies
- silently mutate timeouts
- silently change Task Queues
- try to restore arbitrary Go call stacks across Continue-As-New
- hide non-deterministic behaviour behind hooks
Validation of configuration may be useful. Silently rewriting workflow behaviour is probably not.
The runner should operate at explicit resumable step boundaries.
Pattern name
Possible Temporal Design Patterns name:
Checkpointed Continue-As-New
Intent:
Transparently Continue-As-New at safe execution boundaries while preserving progress through a multi-step Workflow.
The reusable Go primitive underneath it is broader and could be described as a Workflow Step Runner or Workflow Step Middleware.
A possible package/API name is Resumable Steps.
Why explore this
There is a real customer use case behind this.
A Go customer has workflows whose histories are already large enough for Temporal to recommend Continue-As-New, but they have been reluctant to implement CAN because of the additional workflow bookkeeping and complexity.
A small helper could provide something concrete to put in front of them:
How are you getting on with Continue-As-New, and would this make it easier?
That makes this a good opportunity to validate the abstraction against a real workflow rather than designing it entirely in isolation.
- Lenguaje dominante
- Go
- Estrellas
- 1
- Forks
- 0
- Merge medio
- 10 min
- PR fusionados (30 d)
- 4
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Issues similares
-
agentic-workflows
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
agentic-workflows
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
microsoft/agent-framework-go#1179 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
[Bug]: OLLAMA_KEEP_ALIVE="5m" / "24h" crashes Ollama embedding and vision models with ValueError Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
infiniflow/ragflow#20223 · 1 reacción ·
-
bug needs triage pkg/translator/faro
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
open-telemetry/opentelemetry-collector-contrib#51484 · 1 comentario ·