mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## 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]>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package callbacks
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"go.temporal.io/server/common"
|
|
"go.temporal.io/server/common/cluster"
|
|
"go.temporal.io/server/common/collection"
|
|
"go.temporal.io/server/common/log"
|
|
queuescommon "go.temporal.io/server/service/history/queues/common"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
var Module = fx.Module(
|
|
"component.callbacks",
|
|
fx.Provide(ConfigProvider),
|
|
fx.Provide(HTTPCallerProviderProvider),
|
|
fx.Invoke(RegisterTaskSerializers),
|
|
fx.Invoke(RegisterStateMachine),
|
|
fx.Invoke(RegisterExecutor),
|
|
)
|
|
|
|
func HTTPCallerProviderProvider(
|
|
clusterMetadata cluster.Metadata,
|
|
rpcFactory common.RPCFactory,
|
|
httpClientCache *cluster.FrontendHTTPClientCache,
|
|
logger log.Logger,
|
|
) (HTTPCallerProvider, error) {
|
|
localClient, err := rpcFactory.CreateLocalFrontendHTTPClient()
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot create local frontend HTTP client: %w", err)
|
|
}
|
|
defaultClient := &http.Client{}
|
|
|
|
m := collection.NewOnceMap(func(queuescommon.NamespaceIDAndDestination) HTTPCaller {
|
|
return func(r *http.Request) (*http.Response, error) {
|
|
return routeRequest(r,
|
|
clusterMetadata,
|
|
httpClientCache,
|
|
defaultClient,
|
|
localClient,
|
|
logger,
|
|
)
|
|
|
|
}
|
|
})
|
|
return m.Get, nil
|
|
}
|