Files
tasks/components/scheduler/remote_methods.go
tli-temporalandGitHub 313fbee221 Integrate Callbacks into Scheduler HSM Implementation (#6361)
## What changed?
The Scheduler HSM prototype now receives updates about started workflows
using the callback mechanism

## Why?
The original long-polling based implementation is neither necessary nor
suitable for the HSM implementation.

## How did you test it?
functional tests

## Potential risks
None. This is experimental code.

## Documentation
Added comments

## Is hotfix candidate?
No
2024-08-09 17:30:18 +00:00

51 lines
2.0 KiB
Go

// The MIT License
//
// Copyright (c) 2024 Temporal Technologies Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package scheduler
import (
enumspb "go.temporal.io/api/enums/v1"
"google.golang.org/protobuf/proto"
persistencepb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/common/persistence/serialization"
)
type ProcessWorkflowCompletionEvent struct{}
func (p ProcessWorkflowCompletionEvent) Name() string {
return "scheduler.process_workflow_completion_event"
}
func (p ProcessWorkflowCompletionEvent) SerializeOutput(_ any) ([]byte, error) {
// ProcessWorkflowCompletionEvent outputs void and therefore does nothing for serialization.
return nil, nil
}
func (p ProcessWorkflowCompletionEvent) DeserializeInput(data []byte) (any, error) {
output := &persistencepb.HSMCompletionCallbackArg{}
if err := proto.Unmarshal(data, output); err != nil {
return nil, serialization.NewDeserializationError(enumspb.ENCODING_TYPE_PROTO3, err)
}
return output, nil
}