mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +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]>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package errors
|
|
|
|
var _ error = (*DestinationDownError)(nil)
|
|
|
|
// DestinationDownError indicates the destination is down and wraps another error.
|
|
// It is a useful specific error that can be used, for example, in a circuit breaker
|
|
// to distinguish when a destination service is down and an internal error.
|
|
type DestinationDownError struct {
|
|
Message string
|
|
err error
|
|
}
|
|
|
|
func NewDestinationDownError(msg string, err error) *DestinationDownError {
|
|
return &DestinationDownError{
|
|
Message: "destination down: " + msg,
|
|
err: err,
|
|
}
|
|
}
|
|
|
|
func (e *DestinationDownError) Error() string {
|
|
msg := e.Message
|
|
if e.err != nil {
|
|
msg += "\n" + e.err.Error()
|
|
}
|
|
return msg
|
|
}
|
|
|
|
func (e *DestinationDownError) Unwrap() error {
|
|
return e.err
|
|
}
|
|
|
|
var _ error = (*UnprocessableTaskError)(nil)
|
|
|
|
// UnprocessableTaskError is an error type that indicates a task cannot be processed
|
|
// and should be marked as failed without retrying.
|
|
type UnprocessableTaskError struct {
|
|
Message string
|
|
}
|
|
|
|
// NewUnprocessableTaskError returns a new UnprocessableTaskError from given message.
|
|
func NewUnprocessableTaskError(message string) *UnprocessableTaskError {
|
|
return &UnprocessableTaskError{Message: message}
|
|
}
|
|
|
|
func (e UnprocessableTaskError) Error() string {
|
|
return "unprocessable task: " + e.Message
|
|
}
|