Documentation
¶
Index ¶
- Constants
- Variables
- func IsFormatSupported(format string) bool
- func IsLookupSource(s api.Source) bool
- func IsPullStreamSource(s api.Source) bool
- func IsPushStreamSource(s api.Source) bool
- func IsStreamSource(s api.Source) bool
- func RegisterConfHook(h CHook)
- func RegisterConnection(name string, cp ConnectionProvider)
- func RegisterConverter(name string, provider ConverterProvider)
- func RegisterConverterSchemas(name string, schemaType string)
- func RegisterFileRollHook(name string, provider RollHookProvider)
- func RegisterFileStreamDecorator(name string, provider FileStreamDecoratorProvider)
- func RegisterFileStreamReader(name string, provider FileStreamReaderProvider)
- func RegisterFileStreamReaderAlias(alias string, ref string)
- func RegisterFunc(name string, f NewFuncFunc)
- func RegisterLookupSource(name string, f NewLookupSourceFunc)
- func RegisterMerger(name string, provider MergerProvider)
- func RegisterSchemaType(name string, t SchemaTypeDef, ext string)
- func RegisterSink(name string, f NewSinkFunc)
- func RegisterSource(name string, f NewSourceFunc)
- func RegisterWriterConverter(name string, provider ConvertWriterProvider)
- type CHook
- type Connection
- type ConnectionProvider
- type ConnectionStatus
- type ConvertWriterProvider
- type ConverterProvider
- type FileStreamDecorator
- type FileStreamDecoratorProvider
- type FileStreamReader
- type FileStreamReaderProvider
- type Files
- type Merger
- type MergerProvider
- type NewFuncFunc
- type NewLookupSourceFunc
- type NewSinkFunc
- type NewSourceFunc
- type PeriodicHealthChecker
- type PoolRecoverableConnection
- type RollHook
- type RollHookProvider
- type SchemaTypeDef
- type SchemaTypeInfo
- type StatefulDialer
Constants ¶
const ( PROTOBUF = "protobuf" CUSTOM = "custom" )
Variables ¶
var ( Sources = map[string]NewSourceFunc{} Sinks = map[string]NewSinkFunc{} LookupSources = map[string]NewLookupSourceFunc{} )
var (
ConnectionRegister map[string]ConnectionProvider
)
var ConvertWriters = map[string]ConvertWriterProvider{}
ConvertWriters are sink converter to use together with batch
var ConverterSchemas = map[string]string{}
var Converters = map[string]ConverterProvider{}
var Functions = map[string]NewFuncFunc{}
var Mergers = map[string]MergerProvider{}
Mergers list, the key is format + payload format such as "jsoncan"
var SchemaTypeDefs = map[string]SchemaTypeInfo{}
SchemaTypeDefs is the registry of all schema type.
Functions ¶
func IsFormatSupported ¶
func IsLookupSource ¶
func IsPullStreamSource ¶
func IsPushStreamSource ¶
func IsStreamSource ¶
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 RegisterFileRollHook ¶
func RegisterFileRollHook(name string, provider RollHookProvider)
func RegisterFileStreamDecorator ¶
func RegisterFileStreamDecorator(name string, provider FileStreamDecoratorProvider)
func RegisterFileStreamReader ¶
func RegisterFileStreamReader(name string, provider FileStreamReaderProvider)
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 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 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 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 NewLookupSourceFunc ¶
type NewSinkFunc ¶
type NewSourceFunc ¶
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 ¶
type RollHookProvider ¶
type RollHookProvider func() RollHook
type SchemaTypeDef ¶ added in v2.3.0
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
}