modules

package
v2.5.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROTOBUF = "protobuf"
	CUSTOM   = "custom"
)

Variables

View Source
var (
	Sources       = map[string]NewSourceFunc{}
	Sinks         = map[string]NewSinkFunc{}
	LookupSources = map[string]NewLookupSourceFunc{}
)
View Source
var (
	ConnectionRegister map[string]ConnectionProvider
)
View Source
var ConvertWriters = map[string]ConvertWriterProvider{}

ConvertWriters are sink converter to use together with batch

View Source
var ConverterSchemas = map[string]string{}
View Source
var Converters = map[string]ConverterProvider{}
View Source
var Functions = map[string]NewFuncFunc{}
View Source
var Mergers = map[string]MergerProvider{}

Mergers list, the key is format + payload format such as "jsoncan"

View Source
var SchemaTypeDefs = map[string]SchemaTypeInfo{}

SchemaTypeDefs is the registry of all schema type.

Functions

func IsFormatSupported

func IsFormatSupported(format string) bool

func IsLookupSource

func IsLookupSource(s api.Source) bool

func IsPullStreamSource

func IsPullStreamSource(s api.Source) bool

func IsPushStreamSource

func IsPushStreamSource(s api.Source) bool

func IsStreamSource

func IsStreamSource(s api.Source) bool

func RegisterConfHook added in v2.2.0

func RegisterConfHook(h CHook)

RegisterConfHook use this to change default conf. This will be the highest priority, higher than env

func RegisterConnection

func RegisterConnection(name string, cp ConnectionProvider)

func RegisterConverter

func RegisterConverter(name string, provider ConverterProvider)

RegisterConverter registers a converter with the given name.

func RegisterConverterSchemas added in v2.3.0

func RegisterConverterSchemas(name string, schemaType string)

func RegisterFileRollHook

func RegisterFileRollHook(name string, provider RollHookProvider)

func RegisterFileStreamDecorator

func RegisterFileStreamDecorator(name string, provider FileStreamDecoratorProvider)

func RegisterFileStreamReader

func RegisterFileStreamReader(name string, provider FileStreamReaderProvider)

func RegisterFileStreamReaderAlias

func RegisterFileStreamReaderAlias(alias string, ref string)

func RegisterFunc

func RegisterFunc(name string, f NewFuncFunc)

func RegisterLookupSource

func RegisterLookupSource(name string, f NewLookupSourceFunc)

func RegisterMerger

func RegisterMerger(name string, provider MergerProvider)

RegisterMerger registers a merger with the format name and payload format name such as "jsoncan"

func RegisterSchemaType added in v2.3.0

func RegisterSchemaType(name string, t SchemaTypeDef, ext string)

func RegisterSink

func RegisterSink(name string, f NewSinkFunc)

func RegisterSource

func RegisterSource(name string, f NewSourceFunc)

func RegisterWriterConverter added in v2.2.0

func RegisterWriterConverter(name string, provider ConvertWriterProvider)

Types

type CHook added in v2.2.0

type CHook func(c *model.KuiperConf)
var ConfHook CHook

type Connection

type Connection interface {
	// Provision validates/configures and constructs the candidate. It
	// must return without blocking for remote readiness, and it may
	// start provider-internal background activity.
	//
	// Ownership: a nil return transfers full ownership to the Pool. The
	// Pool may Close the candidate at any time afterwards — including
	// when a later creation step (e.g. persist) fails before any Dial,
	// or when the lifecycle stops before Dial completes. Close must
	// safely release all candidate resources and background activity,
	// even if Dial was never called or never succeeded.
	// A non-nil return means Provision itself failed: the provider
	// owns cleanup of any partial state, the Pool closes nothing.
	Provision(ctx api.StreamContext, conId string, props map[string]any) error
	// Dial establishes or waits for initial usability. It must honor
	// ctx cancellation promptly or otherwise have a finite bound: the
	// Pool stops a lifecycle by canceling its scope and waiting for the
	// worker, so an uncancellable Dial hangs every stop path
	// (Detach/Drop/reset). Returning nil means the candidate is
	// initially usable.
	Dial(ctx api.StreamContext) error
	GetId(ctx api.StreamContext) string
	// Ping performs one on-demand bounded validation attempt.
	//
	// It may perform bounded remote I/O, including using an ephemeral
	// connection when the provider has no persistent transport. It must
	// not retry, reconnect/recover, or create/replace the provider's
	// long-lived runtime transport.
	//
	// It is an explicit-caller API (Test Connection, initial
	// validation) on a caller-bounded scope: providers must honor the
	// caller deadline rather than imposing their own unbounded block.
	// Self-recovering clients (StatefulDialer) may answer from their
	// local lifecycle flag instead of hitting the remote.
	//
	// Periodic monitoring is a separate opt-in capability provided by
	// PeriodicHealthChecker below; implementing Ping alone never
	// enrolls a provider in periodic checks.
	Ping(ctx api.StreamContext) error
	api.Closable
}

type ConnectionProvider

type ConnectionProvider func(ctx api.StreamContext) Connection

func GetConnectionProvider added in v2.4.0

func GetConnectionProvider(name string) (ConnectionProvider, bool)

GetConnectionProvider returns a connection provider by name in a thread-safe manner

type ConnectionStatus

type ConnectionStatus struct {
	Status string `json:"status"`
	ErrMsg string `json:"errMsg,omitempty"`
}

type ConvertWriterProvider added in v2.2.0

type ConvertWriterProvider func(ctx api.StreamContext, schemaId string, logicalSchema map[string]*ast.JsonStreamField, props map[string]any) (message.ConvertWriter, error)

type ConverterProvider

type ConverterProvider func(ctx api.StreamContext, schemaId string, logicalSchema map[string]*ast.JsonStreamField, props map[string]any) (message.Converter, error)

ConverterProvider - schemaId: the id for the schema - logicalSchema: the default schema - props: extended properties. Implementation can read and handle it.

type FileStreamDecorator

type FileStreamDecorator interface {
	// Provision Set up the static properties
	Provision(ctx api.StreamContext, props map[string]any) error
	// ReadMeta Read the metadata from the file source, and save in the decorator itself
	// It will receive lines, when receiving EOF, there will be no more lines.
	ReadMeta(ctx api.StreamContext, line []byte)
	// Decorate the file source
	Decorate(ctx api.StreamContext, data any) any
}

func GetFileStreamDecorator

func GetFileStreamDecorator(ctx api.StreamContext, name string) (FileStreamDecorator, bool)

type FileStreamDecoratorProvider

type FileStreamDecoratorProvider func(ctx api.StreamContext) FileStreamDecorator

type FileStreamReader

type FileStreamReader interface {
	// Provision Set up the static properties
	Provision(ctx api.StreamContext, props map[string]any) error
	// Bind set the file stream. Make sure the previous read has done
	Bind(ctx api.StreamContext, fileStream io.Reader, maxSize int) error
	// Read the next record. Returns EOF when the input has reached its end.
	Read(ctx api.StreamContext) (any, error)
	// IsBytesReader If is bytes reader, Read must return []byte, otherwise return map or []map
	IsBytesReader() bool
	api.Closable
}

FileStreamReader reads a type of file line by line. Avoid to load the full file If need to load full file, just extend converter to decode the full bytes

func GetFileStreamReader

func GetFileStreamReader(ctx api.StreamContext, name string) (FileStreamReader, bool)

type FileStreamReaderProvider

type FileStreamReaderProvider func(ctx api.StreamContext) FileStreamReader

type Files added in v2.3.0

type Files struct {
	SchemaFile string
	SoFile     string
	Version    string
}

type Merger

type Merger interface {
	Split(ctx api.StreamContext, b []byte) [][]byte
	// Merging is called when read in a new frame
	Merging(ctx api.StreamContext, b []byte) error
	// Trigger is called when rate limiter is trigger to send out a message
	Trigger(ctx api.StreamContext) ([]any, bool)
}

Merger is used to merge multiple frames. It is currently called by rate limiter only

type MergerProvider

type MergerProvider func(ctx api.StreamContext, payloadSchema string, logicalSchema map[string]*ast.JsonStreamField, props map[string]any) (Merger, error)

type NewFuncFunc

type NewFuncFunc func() api.Function

type NewLookupSourceFunc

type NewLookupSourceFunc func() api.Source

type NewSinkFunc

type NewSinkFunc func() api.Sink

type NewSourceFunc

type NewSourceFunc func() api.Source

type PeriodicHealthChecker

type PeriodicHealthChecker interface {
	HealthCheck(ctx api.StreamContext) error
}

PeriodicHealthChecker is an opt-in capability for the Pool periodic health probe. Only providers that hold a Pool-owned runtime resource representative of the real transport state, and need the Pool to actively verify it, implement this interface.

HealthCheck is failure discovery only: a single pure check that never dials, never reconnects, never mutates provider state, and honors the caller deadline (the Pool already bounds it per round). HealthCheck may race with connection teardown. Implementations must therefore be safe to call concurrently with Close, and Close must not release resources still in use by an in-flight HealthCheck. The Pool bounds the check through ctx but does not otherwise serialize HealthCheck with Close. Whether a connection is probed is decided solely by this capability: the probe never consults StatefulDialer and never falls back to Connection.Ping. Providers whose state is self-reported through transport callbacks (MQTT, NNG), or whose named connection is a logical reusable configuration without an owned transport (Kafka), simply do not implement it.

type PoolRecoverableConnection

type PoolRecoverableConnection interface {
	Connection
	Recover(ctx api.StreamContext) error
}

PoolRecoverableConnection is implemented by providers whose runtime recovery is owned by the Pool (e.g. SQL). It is mutually exclusive with StatefulDialer: a provider implementing both is treated as self-recovering, and the Pool never starts its recovery worker.

Recover performs a single bounded recovery attempt: build a candidate, verify it, and install it so subsequent operations use the new handle. It must not retry or back off internally (the Pool worker owns the rhythm), must honor ctx (per-attempt deadline on top of lifecycle cancellation), and must not invoke Pool status callbacks or mutate Pool-visible status: recovering/disconnected/ connected transitions belong to the Pool. A nil return means the new handle is installed and usable; an error return leaves prior state untouched, and the Pool worker keeps owning the episode (re-verify, then backoff and retry until success or lifecycle end).

type RollHook

type RollHook interface {
	Provision(ctx api.StreamContext, props map[string]any) error
	RollDone(ctx api.StreamContext, filePath string) error
	api.Closable
}

func GetFileRollHook

func GetFileRollHook(name string) (RollHook, bool)

type RollHookProvider

type RollHookProvider func() RollHook

type SchemaTypeDef added in v2.3.0

type SchemaTypeDef interface {
	Scan(logger api.Logger, path string) (map[string]*Files, error)
	Infer(logger api.Logger, filePath string, messageId string) (ast.StreamFields, error)
}

type SchemaTypeInfo added in v2.3.0

type SchemaTypeInfo struct {
	Def SchemaTypeDef
	Ext string
}

type StatefulDialer

type StatefulDialer interface {
	SetStatusChangeHandler(ctx api.StreamContext, handler api.StatusChangeHandler)
	Status(ctx api.StreamContext) ConnectionStatus
}

Jump to

Keyboard shortcuts

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