context

package
v0.0.0-...-a345a4b Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ZapFieldCapture

func ZapFieldCapture(ctx Context) zap.Field

ZapFieldCapture returns a zap field containing capture address

func ZapFieldChangefeed

func ZapFieldChangefeed(ctx Context) zap.Field

ZapFieldChangefeed returns a zap field containing changefeed id

Types

type ChangefeedVars

type ChangefeedVars struct {
	ID   model.ChangeFeedID
	Info *model.ChangeFeedInfo
}

ChangefeedVars contains some vars which can be used anywhere in a pipeline the lifecycle of vars in the ChangefeedVars should be aligned with the changefeed. All field in Vars should be READ-ONLY and THREAD-SAFE

type Context

type Context interface {
	context.Context

	// GlobalVars return the `GlobalVars` store by the root context created by `NewContext`
	// Note that the `GlobalVars` should be READ-ONLY and THREAD-SAFE
	// The root node and all its children node share one pointer of `GlobalVars`
	// So any modification of `GlobalVars` will cause all other family nodes to change.
	GlobalVars() *GlobalVars

	// ChangefeedVars return the `ChangefeedVars` store by the context created by `WithChangefeedVars`
	// Note that the `ChangefeedVars` should be READ-ONLY and THREAD-SAFE
	// The root node and all its children node share one pointer of `ChangefeedVars`
	// So any modification of `ChangefeedVars` will cause all other family nodes to change.
	// ChangefeedVars could be return nil when the `ChangefeedVars` is not set by `WithChangefeedVars`
	ChangefeedVars() *ChangefeedVars

	// Throw an error to parents nodes
	// we can using `WatchThrow` to listen the errors thrown by children nodes
	Throw(error)
}

Context contains Vars(), Done(), Throw(error) and StdContext() context.Context Context is used to instead of standard context

func NewBackendContext4Test

func NewBackendContext4Test(withChangefeedVars bool) Context

NewBackendContext4Test returns a new pipeline context for test, and us context.Background() as ethe parent context

func NewContext

func NewContext(stdCtx context.Context, globalVars *GlobalVars) Context

NewContext returns a new pipeline context

func NewContext4Test

func NewContext4Test(baseCtx context.Context, withChangefeedVars bool) Context

NewBackendContext4Test returns a new pipeline context for test, and use the given context as parent context

func WithCancel

func WithCancel(ctx Context) (Context, context.CancelFunc)

WithCancel returns a Context with the cancel function

func WithChangefeedVars

func WithChangefeedVars(ctx Context, changefeedVars *ChangefeedVars) Context

WithChangefeedVars return a Context with the `ChangefeedVars`

func WithErrorHandler

func WithErrorHandler(ctx Context, f func(error) error) Context

WithErrorHandler creates a new context that can watch the Throw function if the function `f` specified in WithErrorHandler returns an error, the error will be thrown to the parent context.

func WithStd

func WithStd(ctx Context, stdCtx context.Context) Context

WithStd returns a Context with the standard Context

type GlobalVars

type GlobalVars struct {
	PDClient     pd.Client
	KVStorage    tikv.Storage
	CaptureInfo  *model.CaptureInfo
	EtcdClient   *etcd.CDCEtcdClient
	GrpcPool     kv.GrpcPool
	RegionCache  *tikv.RegionCache
	TimeAcquirer pdtime.TimeAcquirer

	// OwnerRevision is the Etcd revision when the owner got elected.
	OwnerRevision int64
}

GlobalVars contains some vars which can be used anywhere in a pipeline the lifecycle of vars in the GlobalVars should be aligned with the ticdc server process. All field in Vars should be READ-ONLY and THREAD-SAFE

Jump to

Keyboard shortcuts

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