elasticstream/interface.go

39 lines
1.7 KiB
Go
Raw Permalink Normal View History

2024-10-07 13:58:20 +05:30
package elasticstream
type Position struct {
ID string
Index string
Pos int
}
type Source interface {
Configure(context.Context, Config) error
Open(context.Context, []Position) error
Read(context.Context) (*Data, error)
Ack(context.Context, Position) error
Teardown(context.Context) error
// -- Lifecycle events -----------------------------------------------------
// LifecycleOnCreated is called after Configure and before Open when the
// connector is run for the first time. This call will be skipped if the
// connector was already started before. This method can be used to do some
// initialization that needs to happen only once in the lifetime of a
// connector (e.g. create a logical replication slot). Anything that the
// connector creates in this method is considered to be owned by this
// connector and should be cleaned up in LifecycleOnDeleted.
LifecycleOnCreated(ctx context.Context, config config.Config) error
// LifecycleOnUpdated is called after Configure and before Open when the
// connector configuration has changed since the last run. This call will be
// skipped if the connector configuration did not change. It can be used to
// update anything that was initialized in LifecycleOnCreated, in case the
// configuration change affects it.
LifecycleOnUpdated(ctx context.Context, configBefore, configAfter config.Config) error
// LifecycleOnDeleted is called when the connector was deleted. It will be
// the only method that is called in that case. This method can be used to
// clean up anything that was initialized in LifecycleOnCreated.
LifecycleOnDeleted(ctx context.Context, config config.Config) error
mustEmbedUnimplementedSource()
}