Files
tasks/chasm/lib/callback/library.go
b701b9bae2 Add CHASM callback into mutable state (#8582)
## What changed?
Integrated chasm/lib/callback into MutableState and updated
callback-related APIs to use CHASM implementation. Added integration
tests following the scheduler pattern.

## Why?
Porting callback functionality from HSM to CHASM as part of the ongoing
HSM-to-CHASM migration effort.

## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [ ] added new unit test(s)
- [X] added new functional test(s)

## Potential risks
This will need to be tested more, but is not being turned on with this
PR

---

> [!NOTE]
> Integrates CHASM-based callbacks into mutable state and history APIs,
adds configs and error types, updates routing/state transitions, and
includes migration tests.
> 
> - **CHASM Callback Integration**:
> - Add CHASM callback module (FX wiring, HTTP caller provider, request
routing) and metrics shared with HSM implementation.
> - Implement `ToAPICallback`, invocation flow changes, and refined
error wrapping.
> - **History/MutableState**:
> - Expose `ChasmEnabled`, `ChasmWorkflowComponent{,ReadOnly}`; use
CHASM for adding/processing completion callbacks when enabled.
> - Describe API now builds callback info from both CHASM and HSM trees.
> - Continue-as-new/retry path aggregates callbacks from both
implementations.
> - **State Machine/Executors**:
> - Switch to `queues/errors` types; move `NamespaceIDAndDestination` to
`queues/common`.
> - Adjust transitions: generate `BackoffTask` with scheduled time;
include destination on reschedule; no tasks on success/fail.
> - Simplify retry result (policy passed separately) and validation
signatures.
> - **Config**:
> - Add `EnableCHASMCallbacks` and `MaxCHASMCallbacksPerWorkflow`; wire
through history configs.
> - **Tests**:
> - Add migration and CHASM-enabled functional tests; update unit tests
to new error/types and behaviors.
> 
> <sup>Written by [Cursor
Bugbot]() for commit
e3b51a931d3ea2dd7f18fb2f9c55fc880ba828d8. This will update automatically
on new commits. Configure
[here]().</sup>

---------

Co-authored-by: Roey Berman <[email protected]>
2025-11-24 12:31:44 -07:00

54 lines
1.1 KiB
Go

package callback
import (
"go.temporal.io/server/chasm"
"google.golang.org/grpc"
)
type (
Library struct {
chasm.UnimplementedLibrary
InvocationTaskExecutor *InvocationTaskExecutor
BackoffTaskExecutor *BackoffTaskExecutor
}
)
func newLibrary(
InvocationTaskExecutor *InvocationTaskExecutor,
BackoffTaskExecutor *BackoffTaskExecutor,
) *Library {
return &Library{
InvocationTaskExecutor: InvocationTaskExecutor,
BackoffTaskExecutor: BackoffTaskExecutor,
}
}
func (l *Library) Name() string {
return "callback"
}
func (l *Library) Components() []*chasm.RegistrableComponent {
return []*chasm.RegistrableComponent{
chasm.NewRegistrableComponent[*Callback]("callback"),
}
}
func (l *Library) Tasks() []*chasm.RegistrableTask {
return []*chasm.RegistrableTask{
chasm.NewRegistrableSideEffectTask(
"invoke",
l.InvocationTaskExecutor,
l.InvocationTaskExecutor,
),
chasm.NewRegistrablePureTask(
"backoff",
l.BackoffTaskExecutor,
l.BackoffTaskExecutor,
),
}
}
func (l *Library) RegisterServices(server *grpc.Server) {
}