common

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 32 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// FirstEventID is the id of the first event in the history
	FirstEventID int64 = 1
	// LastEventID is the id of the last possible event in the history
	LastEventID int64 = math.MaxInt64
	// EmptyEventID is the id of the empty event
	EmptyEventID int64 = 0
	// EmptyVersion is used as the default value for failover version when no value is provided
	EmptyVersion int64 = 0
	// EndEventID is the id of the end event, here we use the int64 max
	EndEventID int64 = 1<<63 - 1
	// BufferedEventID is the id of the buffered event
	BufferedEventID int64 = -123
	// EmptyEventTaskID is uninitialized id of the task id within event
	EmptyEventTaskID int64 = 0
	// TransientEventID is the id of the transient event
	TransientEventID int64 = -124
	// FirstBlobPageToken is the page token identifying the first blob for each history archival
	FirstBlobPageToken = 1
	// LastBlobNextPageToken is the next page token on the last blob for each history archival
	LastBlobNextPageToken = -1
	// EndMessageID is the id of the end message, here we use the int64 max
	EndMessageID int64 = 1<<63 - 1
)
View Source
const (
	// GetHistoryMaxPageSize is the max page size for get history
	GetHistoryMaxPageSize = 256
	// ReadDLQMessagesPageSize is the max page size for read DLQ messages
	ReadDLQMessagesPageSize = 1000
)
View Source
const (
	// MinLongPollTimeout is the minimum context timeout for long poll API, below which
	// the request won't be processed
	MinLongPollTimeout = time.Second * 2
	// CriticalLongPollTimeout is a threshold for the context timeout passed into long poll API,
	// below which a warning will be logged
	CriticalLongPollTimeout = time.Second * 20
)
View Source
const (
	// DefaultWorkflowTaskTimeout sets the Default Workflow Task timeout for a Workflow
	DefaultWorkflowTaskTimeout = 10 * time.Second * debug.TimeoutMultiplier

	// MaxWorkflowTaskStartToCloseTimeout sets the Max Workflow Task start to close timeout for a Workflow
	MaxWorkflowTaskStartToCloseTimeout = 120 * time.Second
)
View Source
const (

	// DaemonStatusInitialized coroutine pool initialized
	DaemonStatusInitialized int32 = 0
	// DaemonStatusStarted coroutine pool started
	DaemonStatusStarted int32 = 1
	// DaemonStatusStopped coroutine pool stopped
	DaemonStatusStopped int32 = 2
)
View Source
const (

	// FailureReasonCompleteResultExceedsLimit is failureReason for complete result exceeds limit
	FailureReasonCompleteResultExceedsLimit = "Complete result exceeds size limit."
	// FailureReasonFailureDetailsExceedsLimit is failureReason for failure details exceeds limit
	FailureReasonFailureExceedsLimit = "Failure exceeds size limit."
	// FailureReasonCancelDetailsExceedsLimit is failureReason for cancel details exceeds limit
	FailureReasonCancelDetailsExceedsLimit = "Cancel details exceed size limit."
	// FailureReasonHeartbeatExceedsLimit is failureReason for heartbeat exceeds limit
	FailureReasonHeartbeatExceedsLimit = "Heartbeat details exceed size limit."
	// FailureReasonSizeExceedsLimit is reason to fail workflow when history size or count exceed limit
	FailureReasonSizeExceedsLimit = "Workflow history size / count exceeds limit."
	// FailureReasonTransactionSizeExceedsLimit is the failureReason for when transaction cannot be committed because it exceeds size limit
	FailureReasonTransactionSizeExceedsLimit = "Transaction size exceeds limit."
)
View Source
const (
	// DefaultTransactionSizeLimit is the largest allowed transaction size to persistence
	DefaultTransactionSizeLimit = 4 * 1024 * 1024
)
View Source
const (
	// Limit for schedule notes field
	ScheduleNotesSizeLimit = 1000
)
View Source
const (
	// TimeoutFailureTypePrefix is the prefix for timeout failure types
	// used in retry policy
	// the actual failure type will be prefix + enums.TimeoutType.String()
	// e.g. "TemporalTimeout:StartToClose" or "TemporalTimeout:Heartbeat"
	TimeoutFailureTypePrefix = "TemporalTimeout:"
)

Variables

View Source
var (
	// ErrBlobSizeExceedsLimit is error for event blob size exceeds limit
	ErrBlobSizeExceedsLimit = serviceerror.NewInvalidArgument("Blob data size exceeds limit.")
	// ErrMemoSizeExceedsLimit is error for memo size exceeds limit
	ErrMemoSizeExceedsLimit = serviceerror.NewInvalidArgument("Memo size exceeds limit.")
	// ErrContextTimeoutTooShort is error for setting a very short context timeout when calling a long poll API
	ErrContextTimeoutTooShort = serviceerror.NewInvalidArgument("Context timeout is too short.")
	// ErrContextTimeoutNotSet is error for not setting a context timeout when calling a long poll API
	ErrContextTimeoutNotSet = serviceerror.NewInvalidArgument("Context timeout is not set.")
)

Functions

func AwaitWaitGroup

func AwaitWaitGroup(wg *sync.WaitGroup, timeout time.Duration) bool

AwaitWaitGroup calls Wait on the given wait Returns true if the Wait() call succeeded before the timeout Returns false if the Wait() did not return before the timeout

func CheckEventBlobSizeLimit added in v0.5.0

func CheckEventBlobSizeLimit(
	actualSize int,
	warnLimit int,
	errorLimit int,
	namespace string,
	workflowID string,
	runID string,
	metricsHandler metrics.MetricsHandler,
	logger log.Logger,
	blobSizeViolationOperationTag tag.ZapTag,
) error

CheckEventBlobSizeLimit checks if a blob data exceeds limits. It logs a warning if it exceeds warnLimit, and return ErrBlobSizeExceedsLimit if it exceeds errorLimit.

func CloneProto added in v1.17.3

func CloneProto[T proto.Message](v T) T

CloneProto is a generic typed version of proto.Clone from gogoproto.

func CreateCompleteTaskRetryPolicy added in v1.17.3

func CreateCompleteTaskRetryPolicy() backoff.RetryPolicy

CreateCompleteTaskRetryPolicy creates a retry policy for completing background tasks

func CreateDependencyTaskNotCompletedReschedulePolicy added in v1.19.0

func CreateDependencyTaskNotCompletedReschedulePolicy() backoff.RetryPolicy

CreateDependencyTaskNotCompletedReschedulePolicy creates a retry policy for rescheduling task with ErrDependencyTaskNotCompleted

func CreateFrontendClientRetryPolicy added in v1.17.3

func CreateFrontendClientRetryPolicy() backoff.RetryPolicy

CreateFrontendClientRetryPolicy creates a retry policy for calls to frontend service

func CreateFrontendHandlerRetryPolicy added in v1.17.3

func CreateFrontendHandlerRetryPolicy() backoff.RetryPolicy

CreateFrontendHandlerRetryPolicy creates a retry policy for calls to frontend service

func CreateHistoryClientRetryPolicy added in v1.17.3

func CreateHistoryClientRetryPolicy() backoff.RetryPolicy

CreateHistoryClientRetryPolicy creates a retry policy for calls to history service

func CreateHistoryHandlerRetryPolicy added in v1.17.3

func CreateHistoryHandlerRetryPolicy() backoff.RetryPolicy

CreateHistoryHandlerRetryPolicy creates a retry policy for calls to history service

func CreateHistoryStartWorkflowRequest added in v0.4.0

func CreateHistoryStartWorkflowRequest(
	namespaceID string,
	startRequest *workflowservice.StartWorkflowExecutionRequest,
	parentExecutionInfo *workflowspb.ParentExecutionInfo,
	now time.Time,
) *historyservice.StartWorkflowExecutionRequest

CreateHistoryStartWorkflowRequest create a start workflow request for history

func CreateMatchingClientRetryPolicy added in v1.17.3

func CreateMatchingClientRetryPolicy() backoff.RetryPolicy

CreateMatchingClientRetryPolicy creates a retry policy for calls to matching service

func CreateMatchingHandlerRetryPolicy added in v1.17.3

func CreateMatchingHandlerRetryPolicy() backoff.RetryPolicy

CreateMatchingHandlerRetryPolicy creates a retry policy for calls to matching service

func CreateMatchingPollWorkflowTaskQueueResponse added in v0.27.0

func CreateMatchingPollWorkflowTaskQueueResponse(historyResponse *historyservice.RecordWorkflowTaskStartedResponse, workflowExecution *commonpb.WorkflowExecution, token []byte) *matchingservice.PollWorkflowTaskQueueResponse

CreateMatchingPollWorkflowTaskQueueResponse create response for matching's PollWorkflowTaskQueue

func CreatePersistenceClientRetryPolicy added in v1.17.3

func CreatePersistenceClientRetryPolicy() backoff.RetryPolicy

CreatePersistenceClientRetryPolicy creates a retry policy for calls to persistence

func CreateReadTaskRetryPolicy added in v1.17.3

func CreateReadTaskRetryPolicy() backoff.RetryPolicy

CreateReadTaskRetryPolicy creates a retry policy for loading background tasks

func CreateSdkClientFactoryRetryPolicy added in v1.16.0

func CreateSdkClientFactoryRetryPolicy() backoff.RetryPolicy

CreateSdkClientFactoryRetryPolicy creates a retry policy to handle SdkClientFactory NewClient when frontend service is not ready

func CreateTaskNotReadyReschedulePolicy added in v1.17.3

func CreateTaskNotReadyReschedulePolicy() backoff.RetryPolicy

CreateTaskNotReadyReschedulePolicy creates a retry policy for rescheduling task with ErrTaskRetry

func CreateTaskProcessingRetryPolicy added in v1.1.0

func CreateTaskProcessingRetryPolicy() backoff.RetryPolicy

CreateTaskProcessingRetryPolicy creates a retry policy for task processing

func CreateTaskReschedulePolicy added in v1.17.0

func CreateTaskReschedulePolicy() backoff.RetryPolicy

CreateTaskReschedulePolicy creates a retry policy for rescheduling task with errors not equal to ErrTaskRetry

func CreateTaskResourceExhaustedReschedulePolicy added in v1.18.0

func CreateTaskResourceExhaustedReschedulePolicy() backoff.RetryPolicy

CreateTaskResourceExhaustedReschedulePolicy creates a retry policy for rescheduling task with resource exhausted error

func EnsureRetryPolicyDefaults added in v0.28.0

func EnsureRetryPolicyDefaults(originalPolicy *commonpb.RetryPolicy, defaultSettings DefaultRetrySettings)

EnsureRetryPolicyDefaults ensures the policy subfields, if not explicitly set, are set to the specified defaults

func GenerateRandomString added in v0.3.12

func GenerateRandomString(n int) string

GenerateRandomString is used for generate test string

func GetDefaultRetryPolicyConfigOptions added in v0.30.0

func GetDefaultRetryPolicyConfigOptions() map[string]interface{}

func GetPayloadsMapSize added in v0.27.0

func GetPayloadsMapSize(data map[string]*commonpb.Payloads) int

func IsContextCanceledErr added in v1.3.0

func IsContextCanceledErr(err error) bool

IsContextCanceledErr checks if the error is context.Canceled or serviceerror.Canceled error

func IsContextDeadlineExceededErr added in v1.3.0

func IsContextDeadlineExceededErr(err error) bool

IsContextDeadlineExceededErr checks if the error is context.DeadlineExceeded or serviceerror.DeadlineExceeded error

func IsInternalError added in v1.19.1

func IsInternalError(err error) bool

IsInternalError checks if the error is an internal error.

func IsPersistenceTransientError

func IsPersistenceTransientError(err error) bool

IsPersistenceTransientError checks if the error is a transient persistence error

func IsResourceExhausted added in v1.1.0

func IsResourceExhausted(err error) bool

IsResourceExhausted checks if the error is a service busy error.

func IsServiceClientTransientError added in v1.17.3

func IsServiceClientTransientError(err error) bool

IsServiceClientTransientError checks if the error is a transient error.

func IsServiceHandlerRetryableError added in v1.17.3

func IsServiceHandlerRetryableError(err error) bool

func IsServiceTransientError added in v0.3.11

func IsServiceTransientError(err error) bool

IsServiceTransientError checks if the error is a retryable error.

func IsStickyWorkerUnavailable added in v1.17.0

func IsStickyWorkerUnavailable(err error) bool

func IsValidContext

func IsValidContext(ctx context.Context) error

IsValidContext checks that the thrift context is not expired on cancelled. Returns nil if the context is still valid. Otherwise, returns the result of ctx.Err()

func OverrideWorkflowRunTimeout added in v1.4.0

func OverrideWorkflowRunTimeout(
	workflowRunTimeout time.Duration,
	workflowExecutionTimeout time.Duration,
) time.Duration

OverrideWorkflowRunTimeout override the run timeout according to execution timeout

func OverrideWorkflowTaskTimeout added in v1.4.0

func OverrideWorkflowTaskTimeout(
	namespace string,
	taskStartToCloseTimeout time.Duration,
	workflowRunTimeout time.Duration,
	getDefaultTimeoutFunc dynamicconfig.DurationPropertyFnWithNamespaceFilter,
) time.Duration

OverrideWorkflowTaskTimeout override the workflow task timeout according to default timeout or max timeout

func PrettyPrintCommands added in v1.19.0

func PrettyPrintCommands(commands []*commandpb.Command, header ...string)

PrettyPrintCommands prints commands in human-readable format

func PrettyPrintHistory

func PrettyPrintHistory(history *historypb.History, header ...string)

PrettyPrintHistory prints history in human-readable format

func ValidateLongPollContextTimeout added in v0.5.7

func ValidateLongPollContextTimeout(
	ctx context.Context,
	handlerName string,
	logger log.Logger,
) error

ValidateLongPollContextTimeout check if the context timeout for a long poll handler is too short or below a normal value. If the timeout is not set or too short, it logs an error, and return ErrContextTimeoutNotSet or ErrContextTimeoutTooShort accordingly. If the timeout is only below a normal value, it just logs an info and return nil.

func ValidateLongPollContextTimeoutIsSet added in v0.8.6

func ValidateLongPollContextTimeoutIsSet(
	ctx context.Context,
	handlerName string,
	logger log.Logger,
) (time.Time, error)

ValidateLongPollContextTimeoutIsSet checks if the context timeout is set for long poll requests.

func ValidateRetryPolicy added in v0.4.0

func ValidateRetryPolicy(policy *commonpb.RetryPolicy) error

ValidateRetryPolicy validates a retry policy

func WorkflowIDToHistoryShard

func WorkflowIDToHistoryShard(
	namespaceID string,
	workflowID string,
	numberOfShards int32,
) int32

WorkflowIDToHistoryShard is used to map namespaceID-workflowID pair to a shardID.

Types

type ClientCache added in v0.5.0

type ClientCache interface {
	GetClientForKey(key string) (interface{}, error)
	GetClientForClientKey(clientKey string) (interface{}, error)
	GetAllClients() ([]interface{}, error)
}

ClientCache store initialized clients

func NewClientCache added in v0.5.0

func NewClientCache(
	keyResolver keyResolver,
	clientProvider clientProvider,
) ClientCache

NewClientCache creates a new client cache based on membership

type Daemon

type Daemon interface {
	Start()
	Stop()
}

Daemon is the base interfaces implemented by background tasks within Temporal

type DefaultRetrySettings added in v0.30.0

type DefaultRetrySettings struct {
	InitialInterval            time.Duration
	MaximumIntervalCoefficient float64
	BackoffCoefficient         float64
	MaximumAttempts            int32
}

DefaultRetrySettings indicates what the "default" retry settings are if it is not specified on an Activity or for any unset fields if a policy is explicitly set on a workflow

func FromConfigToDefaultRetrySettings added in v0.30.0

func FromConfigToDefaultRetrySettings(options map[string]interface{}) DefaultRetrySettings

type PingCheck added in v1.19.0

type PingCheck struct {
	// Name of this component.
	Name string
	// The longest time that Ping can take. If it doesn't return in that much time, that's
	// considered a deadlock and the deadlock detector may take actions to recover, like
	// killing the process.
	Timeout time.Duration
	// Perform the check. The typical implementation will just be Lock() and then Unlock()
	// on a mutex, returning nil. Ping can also return more Pingables for sub-components
	// that will be checked independently. These should form a tree and not lead to cycles.
	Ping func() []Pingable

	// Metrics recording:
	// Timer id within DeadlockDetectorScope (or zero for no metrics)
	MetricsName string
}

type Pingable added in v1.19.0

type Pingable interface {
	GetPingChecks() []PingCheck
}

Pingable is interface to check for liveness of a component, to detect deadlocks. This call should not block.

type RPCFactory added in v0.3.2

type RPCFactory interface {
	GetFrontendGRPCServerOptions() ([]grpc.ServerOption, error)
	GetInternodeGRPCServerOptions() ([]grpc.ServerOption, error)
	GetGRPCListener() net.Listener
	CreateRemoteFrontendGRPCConnection(rpcAddress string) *grpc.ClientConn
	CreateLocalFrontendGRPCConnection() *grpc.ClientConn
	CreateInternodeGRPCConnection(rpcAddress string) *grpc.ClientConn
}

RPCFactory creates gRPC listener and connection.

type TaskTokenSerializer

type TaskTokenSerializer interface {
	Serialize(token *tokenspb.Task) ([]byte, error)
	Deserialize(data []byte) (*tokenspb.Task, error)
	SerializeQueryTaskToken(token *tokenspb.QueryTask) ([]byte, error)
	DeserializeQueryTaskToken(data []byte) (*tokenspb.QueryTask, error)
}

TaskTokenSerializer serializes task tokens

func NewProtoTaskTokenSerializer added in v0.27.0

func NewProtoTaskTokenSerializer() TaskTokenSerializer

NewProtoTaskTokenSerializer creates a new instance of TaskTokenSerializer

Directories

Path Synopsis
Package archiver is a generated GoMock package.
Package archiver is a generated GoMock package.
filestore
Package filestore is a generated GoMock package.
Package filestore is a generated GoMock package.
gcloud
Package gcloud is a generated GoMock package.
Package gcloud is a generated GoMock package.
gcloud/connector
Package connector is a generated GoMock package.
Package connector is a generated GoMock package.
provider
Package provider is a generated GoMock package.
Package provider is a generated GoMock package.
s3store
Package s3store is a generated GoMock package.
Package s3store is a generated GoMock package.
s3store/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package authorization is a generated GoMock package.
Package authorization is a generated GoMock package.
Package cluster is a generated GoMock package.
Package cluster is a generated GoMock package.
gob
Package dynamicconfig is a generated GoMock package.
Package dynamicconfig is a generated GoMock package.
log
Package log is a generated GoMock package.
Package log is a generated GoMock package.
tag
Package membership is a generated GoMock package.
Package membership is a generated GoMock package.
Package metrics is a generated GoMock package.
Package metrics is a generated GoMock package.
Package namespace is a generated GoMock package.
Package namespace is a generated GoMock package.
Package persistence is a generated GoMock package.
Package persistence is a generated GoMock package.
client
Package client is a generated GoMock package.
Package client is a generated GoMock package.
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
nosql/nosqlplugin/cassandra/gocql
Package gocql is a generated GoMock package.
Package gocql is a generated GoMock package.
sql
visibility/manager
Package manager is a generated GoMock package.
Package manager is a generated GoMock package.
visibility/store
Package store is a generated GoMock package.
Package store is a generated GoMock package.
visibility/store/elasticsearch
Package elasticsearch is a generated GoMock package.
Package elasticsearch is a generated GoMock package.
visibility/store/elasticsearch/client
Package client is a generated GoMock package.
Package client is a generated GoMock package.
visibility/store/query
Package query is inspired and partially copied from by github.com/cch123/elasticsql.
Package query is inspired and partially copied from by github.com/cch123/elasticsql.
Package quotas is a generated GoMock package.
Package quotas is a generated GoMock package.
Package resolver is a generated GoMock package.
Package resolver is a generated GoMock package.
rpc
Package sdk is a generated GoMock package.
Package sdk is a generated GoMock package.
Package searchattribute is a generated GoMock package.
Package searchattribute is a generated GoMock package.
Package tasks is a generated GoMock package.
Package tasks is a generated GoMock package.
mocksdk
Package mocksdk is a generated GoMock package.
Package mocksdk is a generated GoMock package.
util contains small standalone utility functions.
util contains small standalone utility functions.
Package xdc is a generated GoMock package.
Package xdc is a generated GoMock package.

Jump to

Keyboard shortcuts

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