interceptor

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 10 Imported by: 59

Documentation

Overview

Package interceptor contains interceptors for client and worker calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Header(ctx context.Context) map[string]*commonpb.Payload

Header provides Temporal header information from the context for reading or writing during specific interceptor calls.

This returns a non-nil map only for contexts inside ActivityInboundInterceptor.ExecuteActivity, ClientOutboundInterceptor.ExecuteWorkflow, and ClientOutboundInterceptor.SignalWithStartWorkflow.

func WorkflowHeader

func WorkflowHeader(ctx workflow.Context) map[string]*commonpb.Payload

WorkflowHeader provides Temporal header information from the workflow context for reading or writing during specific interceptor calls.

This returns a non-nil map only for contexts inside WorkflowInboundInterceptor.ExecuteWorkflow, WorkflowOutboundInterceptor.ExecuteActivity, WorkflowOutboundInterceptor.ExecuteLocalActivity, WorkflowOutboundInterceptor.ExecuteChildWorkflow, and WorkflowOutboundInterceptor.NewContinueAsNewError.

Types

type ActivityInboundInterceptor

type ActivityInboundInterceptor = internal.ActivityInboundInterceptor

ActivityInboundInterceptor is an interface for all activity calls originating from the server. Implementers wanting to intercept outbound (i.e. from SDK) activity calls, can change the outbound interceptor in Init before the next call in the chain.

All implementations must embed ActivityInboundInterceptorBase to safely handle future changes.

type ActivityInboundInterceptorBase

type ActivityInboundInterceptorBase = internal.ActivityInboundInterceptorBase

ActivityInboundInterceptorBase is a default implementation of ActivityInboundInterceptor that forwards calls to the next inbound interceptor and uses an ActivityOutboundInterceptorBase on Init.

This must be embedded into all ActivityInboundInterceptor implementations to safely handle future changes.

type ActivityOutboundInterceptor

type ActivityOutboundInterceptor = internal.ActivityOutboundInterceptor

ActivityOutboundInterceptor is an interface for all activity calls originating from the SDK.

All implementations must embed ActivityOutboundInterceptorBase to safely handle future changes.

type ActivityOutboundInterceptorBase

type ActivityOutboundInterceptorBase = internal.ActivityOutboundInterceptorBase

ActivityOutboundInterceptorBase is a default implementation of ActivityOutboundInterceptor that forwards calls to the next outbound interceptor.

This must be embedded into all ActivityOutboundInterceptor implementations to safely handle future changes.

type BaseTracer

type BaseTracer struct{}

BaseTracer is a default implementation of Tracer meant for embedding.

func (BaseTracer) GetLogger

func (BaseTracer) GetLogger(logger log.Logger, ref TracerSpanRef) log.Logger

type ClientCancelWorkflowInput

type ClientCancelWorkflowInput = internal.ClientCancelWorkflowInput

ClientCancelWorkflowInput is input for ClientOutboundInterceptor.CancelWorkflow.

type ClientExecuteWorkflowInput

type ClientExecuteWorkflowInput = internal.ClientExecuteWorkflowInput

ClientExecuteWorkflowInput is input for ClientOutboundInterceptor.ExecuteWorkflow.

type ClientInterceptor

type ClientInterceptor = internal.ClientInterceptor

ClientInterceptor for providing a ClientOutboundInterceptor to intercept certain workflow-specific client calls from the SDK. If an implementation of this is provided via client or worker options, certain client calls will be intercepted by it.

All implementations must embed ClientInterceptorBase to safely handle future changes.

type ClientInterceptorBase

type ClientInterceptorBase = internal.ClientInterceptorBase

ClientInterceptorBase is a default implementation of ClientInterceptor that simply instantiates ClientOutboundInterceptorBase when called to intercept the client.

This must be embedded into all ClientInterceptor implementations to safely handle future changes.

type ClientOutboundInterceptor

type ClientOutboundInterceptor = internal.ClientOutboundInterceptor

ClientOutboundInterceptor is an interface for certain workflow-specific calls originating from the SDK.

All implementations must embed ClientOutboundInterceptorBase to safely handle future changes.

type ClientOutboundInterceptorBase

type ClientOutboundInterceptorBase = internal.ClientOutboundInterceptorBase

ClientOutboundInterceptorBase is a default implementation of ClientOutboundInterceptor that forwards calls to the next outbound interceptor.

This must be embedded into all ActivityInboundInterceptor implementations to safely handle future changes.

type ClientQueryWorkflowInput

type ClientQueryWorkflowInput = internal.ClientQueryWorkflowInput

ClientQueryWorkflowInput is input for ClientOutboundInterceptor.QueryWorkflow.

type ClientSignalWithStartWorkflowInput

type ClientSignalWithStartWorkflowInput = internal.ClientSignalWithStartWorkflowInput

ClientSignalWithStartWorkflowInput is input for ClientOutboundInterceptor.SignalWithStartWorkflow.

type ClientSignalWorkflowInput

type ClientSignalWorkflowInput = internal.ClientSignalWorkflowInput

ClientSignalWorkflowInput is input for ClientOutboundInterceptor.SignalWorkflow.

type ClientTerminateWorkflowInput

type ClientTerminateWorkflowInput = internal.ClientTerminateWorkflowInput

ClientTerminateWorkflowInput is input for ClientOutboundInterceptor.TerminateWorkflow.

type ExecuteActivityInput

type ExecuteActivityInput = internal.ExecuteActivityInput

ExecuteActivityInput is input for ActivityInboundInterceptor.ExecuteActivity.

type ExecuteWorkflowInput

type ExecuteWorkflowInput = internal.ExecuteWorkflowInput

ExecuteWorkflowInput is input for WorkflowInboundInterceptor.ExecuteWorkflow.

type HandleQueryInput

type HandleQueryInput = internal.HandleQueryInput

HandleQueryInput is input for WorkflowInboundInterceptor.HandleQuery.

type HandleSignalInput

type HandleSignalInput = internal.HandleSignalInput

HandleSignalInput is input for WorkflowInboundInterceptor.HandleSignal.

type Interceptor

type Interceptor = internal.Interceptor

Interceptor is a common interface for all interceptors. It combines ClientInterceptor and WorkerInterceptor. If an implementation of this interceptor is provided via client options, some client calls and all worker calls will be intercepted by it. If an implementation of this interceptor is provided via worker options, all worker calls will be intercepted by it.

All implementations of this should embed InterceptorBase but are not required to.

func NewTracingInterceptor

func NewTracingInterceptor(tracer Tracer) Interceptor

NewTracingInterceptor creates a new interceptor using the given tracer. Most callers do not use this directly, but rather use the opentracing or opentelemetry packages. This panics if options are not set as expected.

type InterceptorBase

type InterceptorBase = internal.InterceptorBase

InterceptorBase is a default implementation of Interceptor meant for embedding. It simply embeds ClientInterceptorBase and WorkerInterceptorBase.

type Tracer

type Tracer interface {
	// Options returns the options for the tracer. This is only called once on
	// initialization.
	Options() TracerOptions

	// UnmarshalSpan unmarshals the given map into a span reference.
	UnmarshalSpan(map[string]string) (TracerSpanRef, error)

	// MarshalSpan marshals the given span into a map. If the map is empty with no
	// error, the span is simply not set.
	MarshalSpan(TracerSpan) (map[string]string, error)

	// SpanFromContext returns the span from the general Go context or nil if not
	// present.
	SpanFromContext(context.Context) TracerSpan

	// ContextWithSpan creates a general Go context with the given span set.
	ContextWithSpan(context.Context, TracerSpan) context.Context

	// StartSpan starts and returns a span with the given options.
	StartSpan(*TracerStartSpanOptions) (TracerSpan, error)

	// GetLogger returns a log.Logger which may include additional fields in its
	// output in order to support correlation of tracing and log data.
	GetLogger(log.Logger, TracerSpanRef) log.Logger
	// contains filtered or unexported methods
}

Tracer is an interface for tracing implementations as used by NewTracingInterceptor. Most callers do not use this directly, but rather use the opentracing or opentelemetry packages.

All implementations must embed BaseTracer to safely handle future changes.

type TracerFinishSpanOptions

type TracerFinishSpanOptions struct {
	// Error is present if there was an error in the code traced by this specific
	// span.
	Error error
}

TracerFinishSpanOptions are options for TracerSpan.Finish.

type TracerOptions

type TracerOptions struct {
	// SpanContextKey provides a key to put a span on a context unrelated to how a
	// span might otherwise be put on a context by ContextWithSpan. This should
	// never be nil.
	//
	// This is used internally to set the span on contexts not natively supported
	// by tracing systems such as workflow.Context.
	SpanContextKey interface{}

	// HeaderKey is the key name on the Temporal header to serialize the span to.
	// This should never be empty.
	HeaderKey string

	// DisableSignalTracing can be set to disable signal tracing.
	DisableSignalTracing bool

	// DisableQueryTracing can be set to disable query tracing.
	DisableQueryTracing bool
}

TracerOptions are options returned from Tracer.Options.

type TracerSpan

type TracerSpan interface {
	TracerSpanRef

	// Finish is called when the span is complete.
	Finish(*TracerFinishSpanOptions)
}

TracerSpan represents a span.

type TracerSpanRef

type TracerSpanRef interface{}

TracerSpanRef represents a span reference such as a parent.

type TracerStartSpanOptions

type TracerStartSpanOptions struct {
	// Parent is the optional parent reference of the span.
	Parent TracerSpanRef
	// Operation is the general operation name without the specific name.
	Operation string

	// Name is the specific activity, workflow, etc for the operation.
	Name string

	// Time indicates the start time of the span.
	//
	// For RunWorkflow and RunActivity operation types, this will match workflow.Info.WorkflowStartTime and
	// activity.Info.StartedTime respectively. All other operations use time.Now().
	Time time.Time

	// DependedOn is true if the parent depends on this span or false if it just
	// is related to the parent. In OpenTracing terms, this is true for "ChildOf"
	// reference types and false for "FollowsFrom" reference types.
	DependedOn bool

	// Tags are a set of span tags.
	Tags map[string]string

	// FromHeader is used internally, not by tracer implementations, to determine
	// whether the parent span can be retrieved from the Temporal header.
	FromHeader bool

	// ToHeader is used internally, not by tracer implementations, to determine
	// whether the span should be placed on the Temporal header.
	ToHeader bool
}

TracerStartSpanOptions are options for Tracer.StartSpan.

type WorkerInterceptor

type WorkerInterceptor = internal.WorkerInterceptor

WorkerInterceptor is an interface for all calls that can be intercepted during worker operation. This includes inbound (from server) and outbound (from SDK) workflow and activity calls. If an implementation of this is provided via client or worker options, all worker calls will be intercepted by it.

All implementations must embed WorkerInterceptorBase to safely handle future changes.

type WorkerInterceptorBase

type WorkerInterceptorBase = internal.WorkerInterceptorBase

WorkerInterceptorBase is a default implementation of WorkerInterceptor that simply instantiates ActivityInboundInterceptorBase or WorkflowInboundInterceptorBase when called to intercept activities or workflows respectively.

This must be embedded into all WorkerInterceptor implementations to safely handle future changes.

type WorkflowInboundInterceptor

type WorkflowInboundInterceptor = internal.WorkflowInboundInterceptor

WorkflowInboundInterceptor is an interface for all workflow calls originating from the server. Implementers wanting to intercept outbound (i.e. from SDK) workflow calls, can change the outbound interceptor in Init before the next call in the chain.

All implementations must embed WorkflowInboundInterceptorBase to safely handle future changes.

type WorkflowInboundInterceptorBase

type WorkflowInboundInterceptorBase = internal.WorkflowInboundInterceptorBase

WorkflowInboundInterceptorBase is a default implementation of WorkflowInboundInterceptor that forwards calls to the next inbound interceptor and uses an WorkflowOutboundInterceptorBase on Init.

This must be embedded into all WorkflowInboundInterceptor implementations to safely handle future changes.

type WorkflowOutboundInterceptor

type WorkflowOutboundInterceptor = internal.WorkflowOutboundInterceptor

WorkflowOutboundInterceptor is an interface for all workflow calls originating from the SDK.

All implementations must embed WorkflowOutboundInterceptorBase to safely handle future changes.

type WorkflowOutboundInterceptorBase

type WorkflowOutboundInterceptorBase = internal.WorkflowOutboundInterceptorBase

WorkflowOutboundInterceptorBase is a default implementation of WorkflowOutboundInterceptor that forwards calls to the next outbound interceptor.

This must be embedded into all WorkflowOutboundInterceptor implementations to safely handle future changes.

Jump to

Keyboard shortcuts

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