shard

package
v1.2.8-prerelease8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package shard is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrShardClosed is returned when shard is closed and a req cannot be processed
	ErrShardClosed = errors.New("shard closed")
)

Functions

func CreateShardOwnershipLostError

func CreateShardOwnershipLostError(
	currentHost membership.HostInfo,
	ownerHost membership.HostInfo,
) *types.ShardOwnershipLostError

CreateShardOwnershipLostError creates a new shard ownership lost error

func IsShardOwnershiptLostError

func IsShardOwnershiptLostError(err error) bool

IsShardOwnershiptLostError checks if a given error is shard ownership lost error

Types

type Context

type Context interface {
	GetShardID() int
	GetService() resource.Resource
	GetExecutionManager() persistence.ExecutionManager
	GetHistoryManager() persistence.HistoryManager
	GetDomainCache() cache.DomainCache
	GetClusterMetadata() cluster.Metadata
	GetConfig() *config.Config
	GetEventsCache() events.Cache
	GetLogger() log.Logger
	GetThrottledLogger() log.Logger
	GetMetricsClient() metrics.Client
	GetTimeSource() clock.TimeSource
	PreviousShardOwnerWasDifferent() bool

	GetEngine() engine.Engine
	SetEngine(engine.Engine)

	GenerateTransferTaskID() (int64, error)
	GenerateTransferTaskIDs(number int) ([]int64, error)

	GetTransferMaxReadLevel() int64
	UpdateTimerMaxReadLevel(cluster string) time.Time

	SetCurrentTime(cluster string, currentTime time.Time)
	GetCurrentTime(cluster string) time.Time
	GetLastUpdatedTime() time.Time
	GetTimerMaxReadLevel(cluster string) time.Time

	GetTransferAckLevel() int64
	UpdateTransferAckLevel(ackLevel int64) error
	GetTransferClusterAckLevel(cluster string) int64
	UpdateTransferClusterAckLevel(cluster string, ackLevel int64) error
	GetTransferProcessingQueueStates(cluster string) []*types.ProcessingQueueState
	UpdateTransferProcessingQueueStates(cluster string, states []*types.ProcessingQueueState) error

	GetCrossClusterProcessingQueueStates(cluster string) []*types.ProcessingQueueState
	UpdateCrossClusterProcessingQueueStates(cluster string, states []*types.ProcessingQueueState) error

	GetClusterReplicationLevel(cluster string) int64
	UpdateClusterReplicationLevel(cluster string, lastTaskID int64) error

	GetTimerAckLevel() time.Time
	UpdateTimerAckLevel(ackLevel time.Time) error
	GetTimerClusterAckLevel(cluster string) time.Time
	UpdateTimerClusterAckLevel(cluster string, ackLevel time.Time) error
	GetTimerProcessingQueueStates(cluster string) []*types.ProcessingQueueState
	UpdateTimerProcessingQueueStates(cluster string, states []*types.ProcessingQueueState) error

	UpdateTransferFailoverLevel(failoverID string, level TransferFailoverLevel) error
	DeleteTransferFailoverLevel(failoverID string) error
	GetAllTransferFailoverLevels() map[string]TransferFailoverLevel

	UpdateTimerFailoverLevel(failoverID string, level TimerFailoverLevel) error
	DeleteTimerFailoverLevel(failoverID string) error
	GetAllTimerFailoverLevels() map[string]TimerFailoverLevel

	GetDomainNotificationVersion() int64
	UpdateDomainNotificationVersion(domainNotificationVersion int64) error

	GetWorkflowExecution(ctx context.Context, request *persistence.GetWorkflowExecutionRequest) (*persistence.GetWorkflowExecutionResponse, error)
	CreateWorkflowExecution(ctx context.Context, request *persistence.CreateWorkflowExecutionRequest) (*persistence.CreateWorkflowExecutionResponse, error)
	UpdateWorkflowExecution(ctx context.Context, request *persistence.UpdateWorkflowExecutionRequest) (*persistence.UpdateWorkflowExecutionResponse, error)
	ConflictResolveWorkflowExecution(ctx context.Context, request *persistence.ConflictResolveWorkflowExecutionRequest) (*persistence.ConflictResolveWorkflowExecutionResponse, error)
	AppendHistoryV2Events(ctx context.Context, request *persistence.AppendHistoryNodesRequest, domainID string, execution types.WorkflowExecution) (*persistence.AppendHistoryNodesResponse, error)

	ReplicateFailoverMarkers(ctx context.Context, markers []*persistence.FailoverMarkerTask) error
	AddingPendingFailoverMarker(*types.FailoverMarkerAttributes) error
	ValidateAndUpdateFailoverMarkers() ([]*types.FailoverMarkerAttributes, error)
}

Context represents a history engine shard

type Controller

type Controller interface {
	common.Daemon

	// PrepareToStop starts the graceful shutdown process for controller
	PrepareToStop()

	GetEngine(workflowID string) (engine.Engine, error)
	GetEngineForShard(shardID int) (engine.Engine, error)
	RemoveEngineForShard(shardID int)

	// Following methods describes the current status of the controller
	// TODO: consider converting to a unified describe method
	Status() int32
	NumShards() int
	ShardIDs() []int32
}

Controller controls history service shards

func NewShardController

func NewShardController(
	resource resource.Resource,
	factory EngineFactory,
	config *config.Config,
) Controller

NewShardController creates a new shard controller

type EngineFactory

type EngineFactory interface {
	CreateEngine(Context) engine.Engine
}

EngineFactory is used to create an instance of sharded history engine

type MockController

type MockController struct {
	// contains filtered or unexported fields
}

MockController is a mock of Controller interface.

func NewMockController

func NewMockController(ctrl *gomock.Controller) *MockController

NewMockController creates a new mock instance.

func (*MockController) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockController) GetEngine

func (m *MockController) GetEngine(workflowID string) (engine.Engine, error)

GetEngine mocks base method.

func (*MockController) GetEngineForShard

func (m *MockController) GetEngineForShard(shardID int) (engine.Engine, error)

GetEngineForShard mocks base method.

func (*MockController) NumShards

func (m *MockController) NumShards() int

NumShards mocks base method.

func (*MockController) PrepareToStop

func (m *MockController) PrepareToStop()

PrepareToStop mocks base method.

func (*MockController) RemoveEngineForShard

func (m *MockController) RemoveEngineForShard(shardID int)

RemoveEngineForShard mocks base method.

func (*MockController) ShardIDs

func (m *MockController) ShardIDs() []int32

ShardIDs mocks base method.

func (*MockController) Start

func (m *MockController) Start()

Start mocks base method.

func (*MockController) Status

func (m *MockController) Status() int32

Status mocks base method.

func (*MockController) Stop

func (m *MockController) Stop()

Stop mocks base method.

type MockControllerMockRecorder

type MockControllerMockRecorder struct {
	// contains filtered or unexported fields
}

MockControllerMockRecorder is the mock recorder for MockController.

func (*MockControllerMockRecorder) GetEngine

func (mr *MockControllerMockRecorder) GetEngine(workflowID interface{}) *gomock.Call

GetEngine indicates an expected call of GetEngine.

func (*MockControllerMockRecorder) GetEngineForShard

func (mr *MockControllerMockRecorder) GetEngineForShard(shardID interface{}) *gomock.Call

GetEngineForShard indicates an expected call of GetEngineForShard.

func (*MockControllerMockRecorder) NumShards

func (mr *MockControllerMockRecorder) NumShards() *gomock.Call

NumShards indicates an expected call of NumShards.

func (*MockControllerMockRecorder) PrepareToStop

func (mr *MockControllerMockRecorder) PrepareToStop() *gomock.Call

PrepareToStop indicates an expected call of PrepareToStop.

func (*MockControllerMockRecorder) RemoveEngineForShard

func (mr *MockControllerMockRecorder) RemoveEngineForShard(shardID interface{}) *gomock.Call

RemoveEngineForShard indicates an expected call of RemoveEngineForShard.

func (*MockControllerMockRecorder) ShardIDs

func (mr *MockControllerMockRecorder) ShardIDs() *gomock.Call

ShardIDs indicates an expected call of ShardIDs.

func (*MockControllerMockRecorder) Start

func (mr *MockControllerMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start.

func (*MockControllerMockRecorder) Status

func (mr *MockControllerMockRecorder) Status() *gomock.Call

Status indicates an expected call of Status.

func (*MockControllerMockRecorder) Stop

Stop indicates an expected call of Stop.

type MockEngineFactory

type MockEngineFactory struct {
	// contains filtered or unexported fields
}

MockEngineFactory is a mock of EngineFactory interface.

func NewMockEngineFactory

func NewMockEngineFactory(ctrl *gomock.Controller) *MockEngineFactory

NewMockEngineFactory creates a new mock instance.

func (*MockEngineFactory) CreateEngine

func (m *MockEngineFactory) CreateEngine(arg0 Context) engine.Engine

CreateEngine mocks base method.

func (*MockEngineFactory) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockEngineFactoryMockRecorder

type MockEngineFactoryMockRecorder struct {
	// contains filtered or unexported fields
}

MockEngineFactoryMockRecorder is the mock recorder for MockEngineFactory.

func (*MockEngineFactoryMockRecorder) CreateEngine

func (mr *MockEngineFactoryMockRecorder) CreateEngine(arg0 interface{}) *gomock.Call

CreateEngine indicates an expected call of CreateEngine.

type TestContext

type TestContext struct {
	Resource        *resource.Test
	MockEventsCache *events.MockCache
	// contains filtered or unexported fields
}

TestContext is a test implementation for shard Context interface

func NewTestContext

func NewTestContext(
	t *testing.T,
	ctrl *gomock.Controller,
	shardInfo *persistence.ShardInfo,
	config *config.Config,
) *TestContext

NewTestContext create a new shardContext for test

func (TestContext) AddingPendingFailoverMarker added in v0.14.0

func (s TestContext) AddingPendingFailoverMarker(
	marker *types.FailoverMarkerAttributes,
) error

func (TestContext) AppendHistoryV2Events

func (s TestContext) AppendHistoryV2Events(
	ctx context.Context,
	request *persistence.AppendHistoryNodesRequest,
	domainID string,
	execution types.WorkflowExecution,
) (*persistence.AppendHistoryNodesResponse, error)

func (TestContext) ConflictResolveWorkflowExecution

func (s TestContext) ConflictResolveWorkflowExecution(
	ctx context.Context,
	request *persistence.ConflictResolveWorkflowExecutionRequest,
) (*persistence.ConflictResolveWorkflowExecutionResponse, error)

func (TestContext) CreateWorkflowExecution

func (s TestContext) CreateWorkflowExecution(
	ctx context.Context,
	request *persistence.CreateWorkflowExecutionRequest,
) (*persistence.CreateWorkflowExecutionResponse, error)

func (TestContext) DeleteTimerFailoverLevel

func (s TestContext) DeleteTimerFailoverLevel(failoverID string) error

func (TestContext) DeleteTransferFailoverLevel

func (s TestContext) DeleteTransferFailoverLevel(failoverID string) error

func (*TestContext) Finish

func (s *TestContext) Finish(
	t mock.TestingT,
)

Finish checks whether expectations are met

func (TestContext) GenerateTransferTaskID

func (s TestContext) GenerateTransferTaskID() (int64, error)

func (TestContext) GenerateTransferTaskIDs

func (s TestContext) GenerateTransferTaskIDs(number int) ([]int64, error)

func (TestContext) GetAllTimerFailoverLevels

func (s TestContext) GetAllTimerFailoverLevels() map[string]TimerFailoverLevel

func (TestContext) GetAllTransferFailoverLevels

func (s TestContext) GetAllTransferFailoverLevels() map[string]TransferFailoverLevel

func (TestContext) GetClusterReplicationLevel

func (s TestContext) GetClusterReplicationLevel(cluster string) int64

func (TestContext) GetConfig

func (s TestContext) GetConfig() *config.Config

func (TestContext) GetCrossClusterProcessingQueueStates added in v0.22.0

func (s TestContext) GetCrossClusterProcessingQueueStates(cluster string) []*types.ProcessingQueueState

func (TestContext) GetCurrentTime

func (s TestContext) GetCurrentTime(cluster string) time.Time

func (TestContext) GetDomainNotificationVersion

func (s TestContext) GetDomainNotificationVersion() int64

func (TestContext) GetEngine

func (s TestContext) GetEngine() engine.Engine

func (TestContext) GetEventsCache

func (s TestContext) GetEventsCache() events.Cache

func (TestContext) GetExecutionManager

func (s TestContext) GetExecutionManager() persistence.ExecutionManager

func (TestContext) GetLastUpdatedTime

func (s TestContext) GetLastUpdatedTime() time.Time

func (TestContext) GetLogger

func (s TestContext) GetLogger() log.Logger

func (TestContext) GetService

func (s TestContext) GetService() resource.Resource

func (TestContext) GetShardID

func (s TestContext) GetShardID() int

func (TestContext) GetThrottledLogger

func (s TestContext) GetThrottledLogger() log.Logger

func (TestContext) GetTimerAckLevel

func (s TestContext) GetTimerAckLevel() time.Time

func (TestContext) GetTimerClusterAckLevel

func (s TestContext) GetTimerClusterAckLevel(cluster string) time.Time

func (TestContext) GetTimerMaxReadLevel

func (s TestContext) GetTimerMaxReadLevel(cluster string) time.Time

func (TestContext) GetTimerProcessingQueueStates added in v0.15.0

func (s TestContext) GetTimerProcessingQueueStates(cluster string) []*types.ProcessingQueueState

func (TestContext) GetTransferAckLevel

func (s TestContext) GetTransferAckLevel() int64

func (TestContext) GetTransferClusterAckLevel

func (s TestContext) GetTransferClusterAckLevel(cluster string) int64

func (TestContext) GetTransferMaxReadLevel

func (s TestContext) GetTransferMaxReadLevel() int64

func (TestContext) GetTransferProcessingQueueStates added in v0.15.0

func (s TestContext) GetTransferProcessingQueueStates(cluster string) []*types.ProcessingQueueState

func (TestContext) GetWorkflowExecution added in v1.2.8

func (s TestContext) GetWorkflowExecution(
	ctx context.Context,
	request *persistence.GetWorkflowExecutionRequest,
) (*persistence.GetWorkflowExecutionResponse, error)

func (TestContext) PreviousShardOwnerWasDifferent

func (s TestContext) PreviousShardOwnerWasDifferent() bool

func (TestContext) ReplicateFailoverMarkers added in v0.14.0

func (s TestContext) ReplicateFailoverMarkers(
	ctx context.Context,
	markers []*persistence.FailoverMarkerTask,
) error

func (TestContext) SetCurrentTime

func (s TestContext) SetCurrentTime(cluster string, currentTime time.Time)

func (TestContext) SetEngine

func (s TestContext) SetEngine(engine engine.Engine)

func (*TestContext) SetEventsCache

func (s *TestContext) SetEventsCache(
	eventsCache events.Cache,
)

SetEventsCache is a test hook for setting events cache

func (*TestContext) ShardInfo

func (s *TestContext) ShardInfo() *persistence.ShardInfo

ShardInfo is a test hook for getting shard info

func (TestContext) UpdateClusterReplicationLevel

func (s TestContext) UpdateClusterReplicationLevel(cluster string, lastTaskID int64) error

func (TestContext) UpdateCrossClusterProcessingQueueStates added in v0.22.0

func (s TestContext) UpdateCrossClusterProcessingQueueStates(cluster string, states []*types.ProcessingQueueState) error

func (TestContext) UpdateDomainNotificationVersion

func (s TestContext) UpdateDomainNotificationVersion(domainNotificationVersion int64) error

func (TestContext) UpdateTimerAckLevel

func (s TestContext) UpdateTimerAckLevel(ackLevel time.Time) error

func (TestContext) UpdateTimerClusterAckLevel

func (s TestContext) UpdateTimerClusterAckLevel(cluster string, ackLevel time.Time) error

func (TestContext) UpdateTimerFailoverLevel

func (s TestContext) UpdateTimerFailoverLevel(failoverID string, level TimerFailoverLevel) error

func (TestContext) UpdateTimerMaxReadLevel

func (s TestContext) UpdateTimerMaxReadLevel(cluster string) time.Time

func (TestContext) UpdateTimerProcessingQueueStates added in v0.15.0

func (s TestContext) UpdateTimerProcessingQueueStates(cluster string, states []*types.ProcessingQueueState) error

func (TestContext) UpdateTransferAckLevel

func (s TestContext) UpdateTransferAckLevel(ackLevel int64) error

func (TestContext) UpdateTransferClusterAckLevel

func (s TestContext) UpdateTransferClusterAckLevel(cluster string, ackLevel int64) error

func (TestContext) UpdateTransferFailoverLevel

func (s TestContext) UpdateTransferFailoverLevel(failoverID string, level TransferFailoverLevel) error

func (TestContext) UpdateTransferProcessingQueueStates added in v0.15.0

func (s TestContext) UpdateTransferProcessingQueueStates(cluster string, states []*types.ProcessingQueueState) error

func (TestContext) UpdateWorkflowExecution

func (s TestContext) UpdateWorkflowExecution(
	ctx context.Context,
	request *persistence.UpdateWorkflowExecutionRequest,
) (*persistence.UpdateWorkflowExecutionResponse, error)

func (TestContext) ValidateAndUpdateFailoverMarkers added in v0.14.0

func (s TestContext) ValidateAndUpdateFailoverMarkers() ([]*types.FailoverMarkerAttributes, error)

type TimerFailoverLevel added in v0.22.0

type TimerFailoverLevel struct {
	StartTime    time.Time
	MinLevel     time.Time
	CurrentLevel time.Time
	MaxLevel     time.Time
	DomainIDs    map[string]struct{}
}

TimerFailoverLevel contains domain IDs and corresponding start / end level

type TransferFailoverLevel added in v0.22.0

type TransferFailoverLevel struct {
	StartTime    time.Time
	MinLevel     int64
	CurrentLevel int64
	MaxLevel     int64
	DomainIDs    map[string]struct{}
}

TransferFailoverLevel contains corresponding start / end level

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL