mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-30 18:41:49 -07:00
## What changed? Add singleton registrable task option ## Why? Add task registration option to specify as singleton. For singleton tasks, there are two conflict resolution options if task already exists: Replace or Ignore. Replace is used for cases where the task info has updated fields such as something like scheduled_time, or for use cases like visibility, where only the last task is required, since all information for execution is in the visibility component. This can replace any validation logic that checks the "stamp" of the task to check if it's stale. ## How did you test it? - [X] built - [X] run locally and tested manually - [X] covered by existing tests - [X] added new unit test(s) - [ ] added new functional test(s)
54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
// TODO: move this to chasm_test package
|
|
package chasm
|
|
|
|
import (
|
|
commonpb "go.temporal.io/api/common/v1"
|
|
"google.golang.org/protobuf/proto"
|
|
"google.golang.org/protobuf/reflect/protoreflect"
|
|
)
|
|
|
|
type (
|
|
TestSideEffectTask = commonpb.Payload
|
|
|
|
TestDiscardableSideEffectTask struct{}
|
|
|
|
TestOutboundSideEffectTask struct{}
|
|
|
|
TestPureTask commonpb.Payload
|
|
|
|
// Singleton task types — distinct Go types so the registry can tell them apart.
|
|
TestSingletonReplaceSideEffectTask commonpb.Payload
|
|
TestSingletonIgnoreSideEffectTask commonpb.Payload
|
|
TestSingletonReplacePureTask commonpb.Payload
|
|
TestSingletonIgnorePureTask commonpb.Payload
|
|
)
|
|
|
|
// ProtoReflect implements [protoreflect.ProtoMessage].
|
|
func (t *TestPureTask) ProtoReflect() protoreflect.Message {
|
|
return (*commonpb.Payload)(t).ProtoReflect()
|
|
}
|
|
|
|
func (t *TestSingletonReplaceSideEffectTask) ProtoReflect() protoreflect.Message {
|
|
return (*commonpb.Payload)(t).ProtoReflect()
|
|
}
|
|
|
|
func (t *TestSingletonIgnoreSideEffectTask) ProtoReflect() protoreflect.Message {
|
|
return (*commonpb.Payload)(t).ProtoReflect()
|
|
}
|
|
|
|
func (t *TestSingletonReplacePureTask) ProtoReflect() protoreflect.Message {
|
|
return (*commonpb.Payload)(t).ProtoReflect()
|
|
}
|
|
|
|
func (t *TestSingletonIgnorePureTask) ProtoReflect() protoreflect.Message {
|
|
return (*commonpb.Payload)(t).ProtoReflect()
|
|
}
|
|
|
|
var (
|
|
_ proto.Message = (*TestPureTask)(nil)
|
|
_ proto.Message = (*TestSingletonReplaceSideEffectTask)(nil)
|
|
_ proto.Message = (*TestSingletonIgnoreSideEffectTask)(nil)
|
|
_ proto.Message = (*TestSingletonReplacePureTask)(nil)
|
|
_ proto.Message = (*TestSingletonIgnorePureTask)(nil)
|
|
)
|