mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? <!-- Describe what has changed in this PR --> Use [gowrap](https://github.com/hexdigest/gowrap) for generating fault injection code. Similar to https://github.com/temporalio/temporal/pull/7050. ## Why? <!-- Tell your future self why have you made these changes --> Less code to maintain. Before: 238 LOC. After: 34 line Go Template. ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> Existing tests + eyeballing the output. ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) -->
282 lines
12 KiB
Go
282 lines
12 KiB
Go
// The MIT License
|
|
//
|
|
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
|
|
//
|
|
// Copyright (c) 2020 Uber Technologies, Inc.
|
|
//
|
|
// 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.
|
|
|
|
// Code generated by gowrap. DO NOT EDIT.
|
|
// template: gowrap_template
|
|
// gowrap: http://github.com/hexdigest/gowrap
|
|
|
|
package faultinjection
|
|
|
|
//go:generate gowrap gen -p go.temporal.io/server/common/persistence -i ExecutionStore -t gowrap_template -o execution_store_gen.go -l ""
|
|
|
|
import (
|
|
"context"
|
|
|
|
_sourcePersistence "go.temporal.io/server/common/persistence"
|
|
)
|
|
|
|
type (
|
|
// faultInjectionExecutionStore implements ExecutionStore interface with fault injection.
|
|
faultInjectionExecutionStore struct {
|
|
_sourcePersistence.ExecutionStore
|
|
generator faultGenerator
|
|
}
|
|
)
|
|
|
|
// newFaultInjectionExecutionStore returns faultInjectionExecutionStore.
|
|
func newFaultInjectionExecutionStore(
|
|
baseStore _sourcePersistence.ExecutionStore,
|
|
generator faultGenerator,
|
|
) *faultInjectionExecutionStore {
|
|
return &faultInjectionExecutionStore{
|
|
ExecutionStore: baseStore,
|
|
generator: generator,
|
|
}
|
|
}
|
|
|
|
// AddHistoryTasks wraps ExecutionStore.AddHistoryTasks.
|
|
func (d faultInjectionExecutionStore) AddHistoryTasks(ctx context.Context, request *_sourcePersistence.InternalAddHistoryTasksRequest) (err error) {
|
|
err = d.generator.generate("AddHistoryTasks").inject(func() error {
|
|
err = d.ExecutionStore.AddHistoryTasks(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// AppendHistoryNodes wraps ExecutionStore.AppendHistoryNodes.
|
|
func (d faultInjectionExecutionStore) AppendHistoryNodes(ctx context.Context, request *_sourcePersistence.InternalAppendHistoryNodesRequest) (err error) {
|
|
err = d.generator.generate("AppendHistoryNodes").inject(func() error {
|
|
err = d.ExecutionStore.AppendHistoryNodes(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// CompleteHistoryTask wraps ExecutionStore.CompleteHistoryTask.
|
|
func (d faultInjectionExecutionStore) CompleteHistoryTask(ctx context.Context, request *_sourcePersistence.CompleteHistoryTaskRequest) (err error) {
|
|
err = d.generator.generate("CompleteHistoryTask").inject(func() error {
|
|
err = d.ExecutionStore.CompleteHistoryTask(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// ConflictResolveWorkflowExecution wraps ExecutionStore.ConflictResolveWorkflowExecution.
|
|
func (d faultInjectionExecutionStore) ConflictResolveWorkflowExecution(ctx context.Context, request *_sourcePersistence.InternalConflictResolveWorkflowExecutionRequest) (err error) {
|
|
err = d.generator.generate("ConflictResolveWorkflowExecution").inject(func() error {
|
|
err = d.ExecutionStore.ConflictResolveWorkflowExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// CreateWorkflowExecution wraps ExecutionStore.CreateWorkflowExecution.
|
|
func (d faultInjectionExecutionStore) CreateWorkflowExecution(ctx context.Context, request *_sourcePersistence.InternalCreateWorkflowExecutionRequest) (ip1 *_sourcePersistence.InternalCreateWorkflowExecutionResponse, err error) {
|
|
err = d.generator.generate("CreateWorkflowExecution").inject(func() error {
|
|
ip1, err = d.ExecutionStore.CreateWorkflowExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// DeleteCurrentWorkflowExecution wraps ExecutionStore.DeleteCurrentWorkflowExecution.
|
|
func (d faultInjectionExecutionStore) DeleteCurrentWorkflowExecution(ctx context.Context, request *_sourcePersistence.DeleteCurrentWorkflowExecutionRequest) (err error) {
|
|
err = d.generator.generate("DeleteCurrentWorkflowExecution").inject(func() error {
|
|
err = d.ExecutionStore.DeleteCurrentWorkflowExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// DeleteHistoryBranch wraps ExecutionStore.DeleteHistoryBranch.
|
|
func (d faultInjectionExecutionStore) DeleteHistoryBranch(ctx context.Context, request *_sourcePersistence.InternalDeleteHistoryBranchRequest) (err error) {
|
|
err = d.generator.generate("DeleteHistoryBranch").inject(func() error {
|
|
err = d.ExecutionStore.DeleteHistoryBranch(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// DeleteHistoryNodes wraps ExecutionStore.DeleteHistoryNodes.
|
|
func (d faultInjectionExecutionStore) DeleteHistoryNodes(ctx context.Context, request *_sourcePersistence.InternalDeleteHistoryNodesRequest) (err error) {
|
|
err = d.generator.generate("DeleteHistoryNodes").inject(func() error {
|
|
err = d.ExecutionStore.DeleteHistoryNodes(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// DeleteReplicationTaskFromDLQ wraps ExecutionStore.DeleteReplicationTaskFromDLQ.
|
|
func (d faultInjectionExecutionStore) DeleteReplicationTaskFromDLQ(ctx context.Context, request *_sourcePersistence.DeleteReplicationTaskFromDLQRequest) (err error) {
|
|
err = d.generator.generate("DeleteReplicationTaskFromDLQ").inject(func() error {
|
|
err = d.ExecutionStore.DeleteReplicationTaskFromDLQ(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// DeleteWorkflowExecution wraps ExecutionStore.DeleteWorkflowExecution.
|
|
func (d faultInjectionExecutionStore) DeleteWorkflowExecution(ctx context.Context, request *_sourcePersistence.DeleteWorkflowExecutionRequest) (err error) {
|
|
err = d.generator.generate("DeleteWorkflowExecution").inject(func() error {
|
|
err = d.ExecutionStore.DeleteWorkflowExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// ForkHistoryBranch wraps ExecutionStore.ForkHistoryBranch.
|
|
func (d faultInjectionExecutionStore) ForkHistoryBranch(ctx context.Context, request *_sourcePersistence.InternalForkHistoryBranchRequest) (err error) {
|
|
err = d.generator.generate("ForkHistoryBranch").inject(func() error {
|
|
err = d.ExecutionStore.ForkHistoryBranch(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// GetAllHistoryTreeBranches wraps ExecutionStore.GetAllHistoryTreeBranches.
|
|
func (d faultInjectionExecutionStore) GetAllHistoryTreeBranches(ctx context.Context, request *_sourcePersistence.GetAllHistoryTreeBranchesRequest) (ip1 *_sourcePersistence.InternalGetAllHistoryTreeBranchesResponse, err error) {
|
|
err = d.generator.generate("GetAllHistoryTreeBranches").inject(func() error {
|
|
ip1, err = d.ExecutionStore.GetAllHistoryTreeBranches(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// GetCurrentExecution wraps ExecutionStore.GetCurrentExecution.
|
|
func (d faultInjectionExecutionStore) GetCurrentExecution(ctx context.Context, request *_sourcePersistence.GetCurrentExecutionRequest) (ip1 *_sourcePersistence.InternalGetCurrentExecutionResponse, err error) {
|
|
err = d.generator.generate("GetCurrentExecution").inject(func() error {
|
|
ip1, err = d.ExecutionStore.GetCurrentExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// GetHistoryTasks wraps ExecutionStore.GetHistoryTasks.
|
|
func (d faultInjectionExecutionStore) GetHistoryTasks(ctx context.Context, request *_sourcePersistence.GetHistoryTasksRequest) (ip1 *_sourcePersistence.InternalGetHistoryTasksResponse, err error) {
|
|
err = d.generator.generate("GetHistoryTasks").inject(func() error {
|
|
ip1, err = d.ExecutionStore.GetHistoryTasks(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// GetHistoryTreeContainingBranch wraps ExecutionStore.GetHistoryTreeContainingBranch.
|
|
func (d faultInjectionExecutionStore) GetHistoryTreeContainingBranch(ctx context.Context, request *_sourcePersistence.InternalGetHistoryTreeContainingBranchRequest) (ip1 *_sourcePersistence.InternalGetHistoryTreeContainingBranchResponse, err error) {
|
|
err = d.generator.generate("GetHistoryTreeContainingBranch").inject(func() error {
|
|
ip1, err = d.ExecutionStore.GetHistoryTreeContainingBranch(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// GetReplicationTasksFromDLQ wraps ExecutionStore.GetReplicationTasksFromDLQ.
|
|
func (d faultInjectionExecutionStore) GetReplicationTasksFromDLQ(ctx context.Context, request *_sourcePersistence.GetReplicationTasksFromDLQRequest) (ip1 *_sourcePersistence.InternalGetReplicationTasksFromDLQResponse, err error) {
|
|
err = d.generator.generate("GetReplicationTasksFromDLQ").inject(func() error {
|
|
ip1, err = d.ExecutionStore.GetReplicationTasksFromDLQ(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// GetWorkflowExecution wraps ExecutionStore.GetWorkflowExecution.
|
|
func (d faultInjectionExecutionStore) GetWorkflowExecution(ctx context.Context, request *_sourcePersistence.GetWorkflowExecutionRequest) (ip1 *_sourcePersistence.InternalGetWorkflowExecutionResponse, err error) {
|
|
err = d.generator.generate("GetWorkflowExecution").inject(func() error {
|
|
ip1, err = d.ExecutionStore.GetWorkflowExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// IsReplicationDLQEmpty wraps ExecutionStore.IsReplicationDLQEmpty.
|
|
func (d faultInjectionExecutionStore) IsReplicationDLQEmpty(ctx context.Context, request *_sourcePersistence.GetReplicationTasksFromDLQRequest) (b1 bool, err error) {
|
|
err = d.generator.generate("IsReplicationDLQEmpty").inject(func() error {
|
|
b1, err = d.ExecutionStore.IsReplicationDLQEmpty(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// ListConcreteExecutions wraps ExecutionStore.ListConcreteExecutions.
|
|
func (d faultInjectionExecutionStore) ListConcreteExecutions(ctx context.Context, request *_sourcePersistence.ListConcreteExecutionsRequest) (ip1 *_sourcePersistence.InternalListConcreteExecutionsResponse, err error) {
|
|
err = d.generator.generate("ListConcreteExecutions").inject(func() error {
|
|
ip1, err = d.ExecutionStore.ListConcreteExecutions(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// PutReplicationTaskToDLQ wraps ExecutionStore.PutReplicationTaskToDLQ.
|
|
func (d faultInjectionExecutionStore) PutReplicationTaskToDLQ(ctx context.Context, request *_sourcePersistence.PutReplicationTaskToDLQRequest) (err error) {
|
|
err = d.generator.generate("PutReplicationTaskToDLQ").inject(func() error {
|
|
err = d.ExecutionStore.PutReplicationTaskToDLQ(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// RangeCompleteHistoryTasks wraps ExecutionStore.RangeCompleteHistoryTasks.
|
|
func (d faultInjectionExecutionStore) RangeCompleteHistoryTasks(ctx context.Context, request *_sourcePersistence.RangeCompleteHistoryTasksRequest) (err error) {
|
|
err = d.generator.generate("RangeCompleteHistoryTasks").inject(func() error {
|
|
err = d.ExecutionStore.RangeCompleteHistoryTasks(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// RangeDeleteReplicationTaskFromDLQ wraps ExecutionStore.RangeDeleteReplicationTaskFromDLQ.
|
|
func (d faultInjectionExecutionStore) RangeDeleteReplicationTaskFromDLQ(ctx context.Context, request *_sourcePersistence.RangeDeleteReplicationTaskFromDLQRequest) (err error) {
|
|
err = d.generator.generate("RangeDeleteReplicationTaskFromDLQ").inject(func() error {
|
|
err = d.ExecutionStore.RangeDeleteReplicationTaskFromDLQ(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// ReadHistoryBranch wraps ExecutionStore.ReadHistoryBranch.
|
|
func (d faultInjectionExecutionStore) ReadHistoryBranch(ctx context.Context, request *_sourcePersistence.InternalReadHistoryBranchRequest) (ip1 *_sourcePersistence.InternalReadHistoryBranchResponse, err error) {
|
|
err = d.generator.generate("ReadHistoryBranch").inject(func() error {
|
|
ip1, err = d.ExecutionStore.ReadHistoryBranch(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// SetWorkflowExecution wraps ExecutionStore.SetWorkflowExecution.
|
|
func (d faultInjectionExecutionStore) SetWorkflowExecution(ctx context.Context, request *_sourcePersistence.InternalSetWorkflowExecutionRequest) (err error) {
|
|
err = d.generator.generate("SetWorkflowExecution").inject(func() error {
|
|
err = d.ExecutionStore.SetWorkflowExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|
|
|
|
// UpdateWorkflowExecution wraps ExecutionStore.UpdateWorkflowExecution.
|
|
func (d faultInjectionExecutionStore) UpdateWorkflowExecution(ctx context.Context, request *_sourcePersistence.InternalUpdateWorkflowExecutionRequest) (err error) {
|
|
err = d.generator.generate("UpdateWorkflowExecution").inject(func() error {
|
|
err = d.ExecutionStore.UpdateWorkflowExecution(ctx, request)
|
|
return err
|
|
})
|
|
return
|
|
}
|