Documentation ¶
Index ¶
- Constants
- Variables
- func GetClientNameAndVersion(ctx context.Context) (string, string)
- func GetValues(ctx context.Context, headerNames ...string) []string
- func NewDefaultVersionChecker() *versionChecker
- func NewVersionChecker(supportedClients map[string]string, serverVersion string) *versionChecker
- func Propagate(ctx context.Context) context.Context
- func SetCallerInfo(ctx context.Context, info CallerInfo) context.Context
- func SetCallerName(ctx context.Context, callerName string) context.Context
- func SetCallerType(ctx context.Context, callerType string) context.Context
- func SetOrigin(ctx context.Context, callOrigin string) context.Context
- func SetVersions(ctx context.Context) context.Context
- func SetVersionsForTests(ctx context.Context, ...) context.Context
- type CallerInfo
- type GRPCHeaderGetter
- type HeaderGetter
- type VersionChecker
Constants ¶
const ( CallerTypeOperator = "operator" CallerTypeAPI = "api" CallerTypeBackground = "background" CallerTypePreemptable = "preemptable" CallerNameSystem = "system" )
const ( ClientNameHeaderName = "client-name" ClientVersionHeaderName = "client-version" SupportedServerVersionsHeaderName = "supported-server-versions" SupportedFeaturesHeaderName = "supported-features" SupportedFeaturesHeaderDelim = "," CallerTypeHeaderName = "caller-type" )
const ( ClientNameServer = "temporal-server" ClientNameServerHTTP = "temporal-server-http" ClientNameGoSDK = "temporal-go" ClientNameJavaSDK = "temporal-java" ClientNamePHPSDK = "temporal-php" ClientNameTypeScriptSDK = "temporal-typescript" ClientNamePythonSDK = "temporal-python" ClientNameCLI = "temporal-cli" ClientNameUI = "temporal-ui" // ServerVersion value can be changed by the create-tag Github workflow. // If you change the var name or move it, be sure to update the workflow. ServerVersion = "1.24.0-m3.4" // SupportedServerVersions is used by CLI and inter role communication. SupportedServerVersions = ">=1.0.0 <2.0.0" // FeatureFollowsNextRunID means that the client supports following next execution run id for // completed/failed/timedout completion events when getting the final result of a workflow. FeatureFollowsNextRunID = "follows-next-run-id" )
Variables ¶
var ( SystemBackgroundCallerInfo = CallerInfo{ CallerName: CallerNameSystem, CallerType: CallerTypeBackground, } SystemPreemptableCallerInfo = CallerInfo{ CallerName: CallerNameSystem, CallerType: CallerTypePreemptable, } )
var ( // AllFeatures contains all known features. This list is used as the value of the supported // features header for internal server requests. There is an assumption that if a feature is // defined, then the server itself supports it. AllFeatures = strings.Join([]string{ FeatureFollowsNextRunID, }, SupportedFeaturesHeaderDelim) SupportedClients = map[string]string{ ClientNameGoSDK: "<2.0.0", ClientNameJavaSDK: "<2.0.0", ClientNamePHPSDK: "<2.0.0", ClientNameTypeScriptSDK: "<2.0.0", ClientNameCLI: "<2.0.0", ClientNameServer: "<2.0.0", ClientNameUI: "<3.0.0", } )
Functions ¶
func GetClientNameAndVersion ¶ added in v1.15.0
GetClientNameAndVersion extracts SDK name and version from context headers
func GetValues ¶
GetValues returns header values for passed header names. It always returns slice of the same size as number of passed header names.
func NewDefaultVersionChecker ¶ added in v1.0.0
func NewDefaultVersionChecker() *versionChecker
NewDefaultVersionChecker constructs a new VersionChecker using default versions from const.
func NewVersionChecker ¶
NewVersionChecker constructs a new VersionChecker
func Propagate ¶ added in v1.13.0
Propagate propagates version headers from incoming context to outgoing context. It copies all headers to outgoing context only if they are exist in incoming context and doesn't exist in outgoing context already.
func SetCallerInfo ¶ added in v1.17.2
func SetCallerInfo( ctx context.Context, info CallerInfo, ) context.Context
SetCallerInfo sets callerName, callerType and CallOrigin in the context. Existing values will be overwritten if new value is not empty. TODO: consider only set the caller info to golang context instead of grpc metadata and propagate to grpc outgoing context upon making an rpc call
func SetCallerName ¶ added in v1.17.3
SetCallerName set caller name in the context. Existing caller name will be overwritten if exists and new caller name is not empty.
func SetCallerType ¶ added in v1.17.3
SetCallerType set caller type in the context. Existing caller type will be overwritten if exists and new caller type is not empty.
func SetOrigin ¶ added in v1.17.3
SetOrigin set call origin in the context. Existing call origin will be overwritten if exists and new call origin is not empty.
func SetVersions ¶
SetVersions sets headers for internal communications.
Types ¶
type CallerInfo ¶ added in v1.17.2
type CallerInfo struct { // CallerName is the name of the caller. // It can either user namespace name or // the predefined CallerNameSystem. CallerName string // CallerType indicates if the call originates from // user API calls or from system background operations. CallerType string // CallOrigin is the first API method name in the call chain. // Currently, it is only specified when CallerType is CallerTypeAPI CallOrigin string }
func GetCallerInfo ¶ added in v1.17.2
func GetCallerInfo( ctx context.Context, ) CallerInfo
GetCallerInfo retrieves caller information from the context if exists. Empty value is returned if any piece of caller information is not specified in the context.
func NewBackgroundCallerInfo ¶ added in v1.17.3
func NewBackgroundCallerInfo( callerName string, ) CallerInfo
NewBackgroundCallerInfo creates a new CallerInfo with Background callerType and empty callOrigin. This is equivalent to NewCallerInfo(callerName, CallerTypeBackground, "")
func NewCallerInfo ¶ added in v1.17.2
func NewCallerInfo( callerName string, callerType string, callOrigin string, ) CallerInfo
NewCallerInfo creates a new CallerInfo
func NewPreemptableCallerInfo ¶ added in v1.20.1
func NewPreemptableCallerInfo( callerName string, ) CallerInfo
NewPreemptableCallerInfo creates a new CallerInfo with Preemptable callerType and empty callOrigin. This is equivalent to NewCallerInfo(callerName, CallerTypePreemptable, "")
type GRPCHeaderGetter ¶ added in v1.24.0
Wrapper for gRPC metadata that exposes a helper to extract a single metadata value.
func (GRPCHeaderGetter) Get ¶ added in v1.24.0
func (h GRPCHeaderGetter) Get(key string) string
Get a single value from the underlying gRPC metadata. Returns an empty string if the metadata key is unset.
type HeaderGetter ¶ added in v1.24.0
HeaderGetter is an interface for getting a single header value from a case insensitive key.