common

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 31 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 (
	// FrontendServiceName is the name of the frontend service
	FrontendServiceName = "frontend"
	// HistoryServiceName is the name of the history service
	HistoryServiceName = "history"
	// MatchingServiceName is the name of the matching service
	MatchingServiceName = "matching"
	// WorkerServiceName is the name of the worker service
	WorkerServiceName = "worker"
)
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 (
	// SystemGlobalNamespace is global namespace name for temporal system workflows running globally
	SystemGlobalNamespace = "temporal-system-global"
	// SystemLocalNamespace is namespace name for temporal system workflows running in local cluster
	SystemLocalNamespace = "temporal-system"
	// SystemNamespaceID is namespace id for all temporal system workflows
	SystemNamespaceID = "32049b68-7872-4094-8e63-d0dd59896a83"
	// SystemNamespaceRetention is retention config for all temporal system workflows
	SystemNamespaceRetention = time.Hour * 24 * 7
)

This was flagged by salus as potentially hardcoded credentials. This is a false positive by the scanner and should be disregarded. #nosec

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
	// MaxWorkflowRetentionPeriod is the maximum of workflow retention when registering namespace
	// !!! Do NOT simply decrease this number, because it is being used by history scavenger to avoid race condition against history archival.
	// Check more details in history scanner(scavenger)
	MaxWorkflowRetentionPeriod = 30 * time.Hour * 24
)
View Source
const (
	// DefaultWorkflowTaskTimeout sets the Default Workflow Task timeout for a Workflow
	DefaultWorkflowTaskTimeout = 10 * time.Second

	// MaxWorkflowTaskStartToCloseTimeout sets the Max Workflow Task start to close timeout for a Workflow
	MaxWorkflowTaskStartToCloseTimeout = 120 * time.Second
)
View Source
const (
	// AdvancedVisibilityWritingModeOff means do not write to advanced visibility store
	AdvancedVisibilityWritingModeOff = "off"
	// AdvancedVisibilityWritingModeOn means only write to advanced visibility store
	AdvancedVisibilityWritingModeOn = "on"
	// AdvancedVisibilityWritingModeDual means write to both normal visibility and advanced visibility store
	AdvancedVisibilityWritingModeDual = "dual"
)

enum for dynamic config AdvancedVisibilityWritingMode

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
)

Variables

View Source
var (
	// ErrBlobSizeExceedsLimit is error for event blob size exceeds limit
	ErrBlobSizeExceedsLimit = serviceerror.NewInvalidArgument("Blob data 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,
	namespaceID string,
	workflowID string,
	runID string,
	scope metrics.Scope,
	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 CreateAdminServiceRetryPolicy added in v0.5.0

func CreateAdminServiceRetryPolicy() backoff.RetryPolicy

CreateAdminServiceRetryPolicy creates a retry policy for calls to matching service

func CreateFrontendServiceRetryPolicy added in v0.3.11

func CreateFrontendServiceRetryPolicy() backoff.RetryPolicy

CreateFrontendServiceRetryPolicy creates a retry policy for calls to frontend service

func CreateHistoryServiceRetryPolicy

func CreateHistoryServiceRetryPolicy() backoff.RetryPolicy

CreateHistoryServiceRetryPolicy 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 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 CreateMatchingServiceRetryPolicy added in v0.5.0

func CreateMatchingServiceRetryPolicy() backoff.RetryPolicy

CreateMatchingServiceRetryPolicy creates a retry policy for calls to matching service

func CreatePersistanceRetryPolicy

func CreatePersistanceRetryPolicy() backoff.RetryPolicy

CreatePersistanceRetryPolicy creates a retry policy for persistence layer operations

func CreateReplicationServiceBusyRetryPolicy added in v1.1.0

func CreateReplicationServiceBusyRetryPolicy() backoff.RetryPolicy

CreateReplicationServiceBusyRetryPolicy creates a retry policy to handle replication service busy

func CreateTaskProcessingRetryPolicy added in v1.1.0

func CreateTaskProcessingRetryPolicy() backoff.RetryPolicy

CreateTaskProcessingRetryPolicy creates a retry policy for task processing

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 GetDefaultAdvancedVisibilityWritingMode added in v0.27.0

func GetDefaultAdvancedVisibilityWritingMode(isAdvancedVisConfigExist bool) string

GetDefaultAdvancedVisibilityWritingMode get default advancedVisibilityWritingMode based on whether related config exists in static config file.

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 IsJustOrderByClause added in v0.5.9

func IsJustOrderByClause(clause string) bool

IsJustOrderByClause return true is query start with order by

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 IsServiceTransientError added in v0.3.11

func IsServiceTransientError(err error) bool

IsServiceTransientError checks if the error is a retryable error.

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 IsWhitelistServiceTransientError added in v0.3.14

func IsWhitelistServiceTransientError(err error) bool

IsWhitelistServiceTransientError checks if the error is a transient error.

func MaxDuration added in v0.27.0

func MaxDuration(a, b time.Duration) time.Duration

MaxDuration returns the greater of two given time durations

func MaxInt added in v0.7.0

func MaxInt(a, b int) int

MaxInt returns the greater one of two given integers

func MaxInt64 added in v0.6.0

func MaxInt64(a, b int64) int64

MaxInt64 returns the greater of two given int64

func MaxTime added in v1.1.0

func MaxTime(a, b time.Time) time.Time

MinTime returns the smaller of two given time.Time

func MinDuration added in v0.27.0

func MinDuration(a, b time.Duration) time.Duration

MinDuration returns the smaller of two given time duration

func MinInt added in v0.5.7

func MinInt(a, b int) int

MinInt returns the smaller of two given integers

func MinInt32 added in v0.3.14

func MinInt32(a, b int32) int32

MinInt32 return smaller one of two inputs int32

func MinInt64 added in v0.5.8

func MinInt64(a, b int64) int64

MinInt64 returns the smaller of two given int64

func MinTime added in v1.1.0

func MinTime(a, b time.Time) time.Time

MinTime returns the smaller of two given time.Time

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 PrettyPrintHistory

func PrettyPrintHistory(history *historypb.History, logger log.Logger)

PrettyPrintHistory prints history in human readable format

func SortInt64Slice added in v0.27.0

func SortInt64Slice(slice []int64)

SortInt64Slice sorts the given int64 slice. Sort is not guaranteed to be stable.

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)
	GetHostNameForKey(key string) (string, 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 RPCFactory added in v0.3.2

type RPCFactory interface {
	GetFrontendGRPCServerOptions() ([]grpc.ServerOption, error)
	GetInternodeGRPCServerOptions() ([]grpc.ServerOption, error)
	GetGRPCListener() net.Listener
	GetRingpopChannel() *tchannel.Channel
	CreateFrontendGRPCConnection(hostName string) *grpc.ClientConn
	CreateInternodeGRPCConnection(hostName 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 cache is a generated GoMock package.
Package cache 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
Package visibility is a generated GoMock package.
Package visibility is a generated GoMock package.
visibility/elasticsearch
Package elasticsearch is a generated GoMock package.
Package elasticsearch is a generated GoMock package.
visibility/elasticsearch/client
Package client is a generated GoMock package.
Package client is a generated GoMock package.
visibility/elasticsearch/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 searchattribute is a generated GoMock package.
Package searchattribute is a generated GoMock package.
Package task is a generated GoMock package.
Package task is a generated GoMock package.
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