mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed - Moved Nexus operation event definitions, command handlers, and library registration from `chasm/lib/nexusoperation/workflow` into `chasm/lib/workflow` as `nexus_events.go`, `nexus_commands.go`, `nexus_library.go`. - Extracted all Nexus-related Workflow methods from `workflow.go` into `nexus_methods.go`. - Converted all `AddAndApplyHistoryEventByEventType` calls to use the generic `addAndApplyHistoryEvent[D]` form and removed `AddAndApplyHistoryEventByEventType` entirely. - Unexported internal symbols: `addAndApplyHistoryEvent`, `eventDefinitionByGoType`, `addNexusOperation`, `removeNexusOperation`, `pendingNexusOperationCount`. - Absorbed the `chasmnexusworkflow.Module` fx registration into the workflow module's `fx.Invoke`, removing the separate fx module. - Deleted `chasm/lib/nexusoperation/workflow/` package. ## Why The `chasm/lib/workflow` package is a more natural home for this code. It allows all of the Nexus integration for workflows to be colocated alongside the workflow component, registry, and event application logic rather than spread across a separate package that existed solely to register handlers with the workflow registry. ## How was this tested? - `go build ./...` passes. - `go test ./chasm/lib/workflow/... -count 1` passes (all existing tests moved and adapted). - `make lint` passes with 0 issues.
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package workflow
|
|
|
|
import (
|
|
enumspb "go.temporal.io/api/enums/v1"
|
|
"go.temporal.io/server/chasm"
|
|
"go.temporal.io/server/chasm/lib/nexusoperation"
|
|
)
|
|
|
|
type nexusLibrary struct {
|
|
config *nexusoperation.Config
|
|
nexusProcessor *chasm.NexusEndpointProcessor
|
|
}
|
|
|
|
func newNexusLibrary(config *nexusoperation.Config, nexusProcessor *chasm.NexusEndpointProcessor) *nexusLibrary {
|
|
return &nexusLibrary{config: config, nexusProcessor: nexusProcessor}
|
|
}
|
|
|
|
func (l *nexusLibrary) CommandHandlers() map[enumspb.CommandType]CommandHandler {
|
|
h := &nexusCommandHandler{config: l.config, nexusProcessor: l.nexusProcessor}
|
|
return map[enumspb.CommandType]CommandHandler{
|
|
enumspb.COMMAND_TYPE_SCHEDULE_NEXUS_OPERATION: h.handleScheduleCommand,
|
|
enumspb.COMMAND_TYPE_REQUEST_CANCEL_NEXUS_OPERATION: h.handleCancelCommand,
|
|
}
|
|
}
|
|
|
|
func (l *nexusLibrary) EventDefinitions() []EventDefinition {
|
|
return []EventDefinition{
|
|
ScheduledEventDefinition{},
|
|
CancelRequestedEventDefinition{},
|
|
CancelRequestCompletedEventDefinition{},
|
|
CancelRequestFailedEventDefinition{},
|
|
StartedEventDefinition{},
|
|
CompletedEventDefinition{},
|
|
FailedEventDefinition{},
|
|
CanceledEventDefinition{},
|
|
TimedOutEventDefinition{},
|
|
}
|
|
}
|