interceptors

package
v0.0.0-...-34e0b2d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Append

type Append = func(ctx context.Context, msg message.MutableMessage) (message.MessageID, error)

Append is the common function to append a msg to the wal.

type AppendInterceptor

type AppendInterceptor interface {
	// Execute the append operation with interceptor.
	DoAppend(ctx context.Context, msg message.MutableMessage, append Append) (message.MessageID, error)
}

AppendInterceptor is the interceptor for Append functions. All wal extra operations should be done by these function, such as 1. time tick setup. 2. unique primary key filter and build. 3. index builder. 4. cache sync up. AppendInterceptor should be lazy initialized and fast execution.

type BasicInterceptor

type BasicInterceptor interface {
	// Close the interceptor release the resources.
	Close()
}

type Interceptor

type Interceptor interface {
	AppendInterceptor

	BasicInterceptor
}

type InterceptorBuildParam

type InterceptorBuildParam struct {
	WALImpls walimpls.WALImpls         // The underlying walimpls implementation, can be used anytime.
	WAL      *syncutil.Future[wal.WAL] // The wal final object, can be used after interceptor is ready.
}

type InterceptorBuilder

type InterceptorBuilder interface {
	// Build build a interceptor with wal that interceptor will work on.
	// the wal object will be sent to the interceptor builder when the wal is constructed with all interceptors.
	Build(param InterceptorBuildParam) BasicInterceptor
}

InterceptorBuilder is the interface to build a interceptor. 1. InterceptorBuilder is concurrent safe. 2. InterceptorBuilder can used to build a interceptor with cross-wal shared resources.

type InterceptorReady

type InterceptorReady interface {
	// Ready check if interceptor is ready.
	// Close of Interceptor would not notify the ready (closed interceptor is not ready).
	// So always apply timeout when waiting for ready.
	// Some append interceptor may be stateful, such as index builder and unique primary key filter,
	// so it need to implement the recovery logic from crash by itself before notifying ready.
	// Append operation will block until ready or canceled.
	// Consumer do not blocked by it.
	Ready() <-chan struct{}
}

type InterceptorWithReady

type InterceptorWithReady interface {
	Interceptor

	InterceptorReady
}

Some interceptor may need to wait for some resource to be ready or recovery process.

func NewChainedInterceptor

func NewChainedInterceptor(interceptors ...BasicInterceptor) InterceptorWithReady

NewChainedInterceptor creates a new chained interceptor.

Directories

Path Synopsis
ack

Jump to

Keyboard shortcuts

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