context

package
v0.0.0-...-e2b6bb1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 the 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

NewContext4Test 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 {
	CaptureInfo *model.CaptureInfo
	EtcdClient  etcd.CDCEtcdClient

	// SortEngineManager is introduced for pull-based sinks.
	SortEngineFactory *factory.SortEngineFactory

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

	// MessageServer and MessageRouter are for peer-messaging
	MessageServer *p2p.MessageServer
	MessageRouter p2p.MessageRouter

	// ChangefeedThreadPool is the thread pool for changefeed initialization
	ChangefeedThreadPool workerpool.AsyncPool
}

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

type NonAsyncPool

type NonAsyncPool struct{}

NonAsyncPool is a dummy implementation of workerpool.AsyncPool, which runs tasks synchronously. It is used in tests to avoid the overhead of asynchronous task scheduling.

func (*NonAsyncPool) Go

func (f *NonAsyncPool) Go(_ context.Context, fn func()) error

Go runs the task synchronously.

func (*NonAsyncPool) Run

func (f *NonAsyncPool) Run(_ context.Context) error

Run does nothing.

Jump to

Keyboard shortcuts

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