mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-31 11:01:53 -07:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
140 lines
4.3 KiB
Go
140 lines
4.3 KiB
Go
package updateutils
|
|
|
|
import (
|
|
"github.com/stretchr/testify/require"
|
|
commandpb "go.temporal.io/api/command/v1"
|
|
enumspb "go.temporal.io/api/enums/v1"
|
|
failurepb "go.temporal.io/api/failure/v1"
|
|
protocolpb "go.temporal.io/api/protocol/v1"
|
|
updatepb "go.temporal.io/api/update/v1"
|
|
"go.temporal.io/server/common/payloads"
|
|
"go.temporal.io/server/common/testing/protoutils"
|
|
"go.temporal.io/server/common/testing/testvars"
|
|
)
|
|
|
|
type (
|
|
UpdateUtils struct {
|
|
t require.TestingT
|
|
}
|
|
|
|
helper interface {
|
|
Helper()
|
|
}
|
|
)
|
|
|
|
func New(t require.TestingT) UpdateUtils {
|
|
return UpdateUtils{
|
|
t: t,
|
|
}
|
|
}
|
|
|
|
func (u UpdateUtils) UpdateAcceptCommands(tv *testvars.TestVars) []*commandpb.Command {
|
|
if th, ok := u.t.(helper); ok {
|
|
th.Helper()
|
|
}
|
|
|
|
return []*commandpb.Command{{
|
|
CommandType: enumspb.COMMAND_TYPE_PROTOCOL_MESSAGE,
|
|
Attributes: &commandpb.Command_ProtocolMessageCommandAttributes{ProtocolMessageCommandAttributes: &commandpb.ProtocolMessageCommandAttributes{
|
|
MessageId: tv.MessageID() + "_update-accepted",
|
|
}},
|
|
}}
|
|
}
|
|
|
|
func (u UpdateUtils) UpdateCompleteCommands(tv *testvars.TestVars) []*commandpb.Command {
|
|
if th, ok := u.t.(helper); ok {
|
|
th.Helper()
|
|
}
|
|
return []*commandpb.Command{
|
|
{
|
|
CommandType: enumspb.COMMAND_TYPE_PROTOCOL_MESSAGE,
|
|
Attributes: &commandpb.Command_ProtocolMessageCommandAttributes{ProtocolMessageCommandAttributes: &commandpb.ProtocolMessageCommandAttributes{
|
|
MessageId: tv.MessageID() + "_update-completed",
|
|
}},
|
|
},
|
|
}
|
|
}
|
|
|
|
func (u UpdateUtils) UpdateAcceptCompleteCommands(tv *testvars.TestVars) []*commandpb.Command {
|
|
if th, ok := u.t.(helper); ok {
|
|
th.Helper()
|
|
}
|
|
return append(u.UpdateAcceptCommands(tv), u.UpdateCompleteCommands(tv)...)
|
|
}
|
|
|
|
func (u UpdateUtils) UpdateAcceptMessages(tv *testvars.TestVars, updRequestMsg *protocolpb.Message) []*protocolpb.Message {
|
|
if th, ok := u.t.(helper); ok {
|
|
th.Helper()
|
|
}
|
|
updRequest := protoutils.UnmarshalAny[*updatepb.Request](u.t, updRequestMsg.GetBody())
|
|
|
|
return []*protocolpb.Message{
|
|
{
|
|
Id: tv.MessageID() + "_update-accepted",
|
|
ProtocolInstanceId: updRequest.GetMeta().GetUpdateId(),
|
|
SequencingId: nil,
|
|
Body: protoutils.MarshalAny(u.t, &updatepb.Acceptance{
|
|
AcceptedRequestMessageId: updRequestMsg.GetId(),
|
|
AcceptedRequestSequencingEventId: updRequestMsg.GetEventId(),
|
|
AcceptedRequest: updRequest,
|
|
}),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (u UpdateUtils) UpdateCompleteMessages(tv *testvars.TestVars, updRequestMsg *protocolpb.Message) []*protocolpb.Message {
|
|
if th, ok := u.t.(helper); ok {
|
|
th.Helper()
|
|
}
|
|
updRequest := protoutils.UnmarshalAny[*updatepb.Request](u.t, updRequestMsg.GetBody())
|
|
|
|
return []*protocolpb.Message{
|
|
{
|
|
Id: tv.MessageID() + "_update-completed",
|
|
ProtocolInstanceId: updRequest.GetMeta().GetUpdateId(),
|
|
SequencingId: nil,
|
|
Body: protoutils.MarshalAny(u.t, &updatepb.Response{
|
|
Meta: updRequest.GetMeta(),
|
|
Outcome: &updatepb.Outcome{
|
|
Value: &updatepb.Outcome_Success{
|
|
Success: payloads.EncodeString("success-result-of-" + updRequest.GetMeta().GetUpdateId()),
|
|
},
|
|
},
|
|
}),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (u UpdateUtils) UpdateAcceptCompleteMessages(tv *testvars.TestVars, updRequestMsg *protocolpb.Message) []*protocolpb.Message {
|
|
if th, ok := u.t.(helper); ok {
|
|
th.Helper()
|
|
}
|
|
return append(
|
|
u.UpdateAcceptMessages(tv, updRequestMsg),
|
|
u.UpdateCompleteMessages(tv, updRequestMsg)...)
|
|
}
|
|
|
|
func (u UpdateUtils) UpdateRejectMessages(tv *testvars.TestVars, updRequestMsg *protocolpb.Message) []*protocolpb.Message {
|
|
if th, ok := u.t.(helper); ok {
|
|
th.Helper()
|
|
}
|
|
updRequest := protoutils.UnmarshalAny[*updatepb.Request](u.t, updRequestMsg.GetBody())
|
|
|
|
return []*protocolpb.Message{
|
|
{
|
|
Id: tv.MessageID() + "_update-rejected",
|
|
ProtocolInstanceId: updRequest.GetMeta().GetUpdateId(),
|
|
SequencingId: nil,
|
|
Body: protoutils.MarshalAny(u.t, &updatepb.Rejection{
|
|
RejectedRequestMessageId: updRequestMsg.GetId(),
|
|
RejectedRequestSequencingEventId: updRequestMsg.GetEventId(),
|
|
RejectedRequest: updRequest,
|
|
Failure: &failurepb.Failure{
|
|
Message: "rejection-of-" + updRequest.GetMeta().GetUpdateId(),
|
|
FailureInfo: &failurepb.Failure_ApplicationFailureInfo{ApplicationFailureInfo: &failurepb.ApplicationFailureInfo{}},
|
|
},
|
|
}),
|
|
},
|
|
}
|
|
}
|