plugin

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 30 Imported by: 20

Documentation

Index

Constants

View Source
const (
	UnrecognizedRemotePluginMessage       = "Unrecognized remote plugin message:"
	UnrecognizedRemotePluginMessageSuffix = "\nThis usually means"
	PluginStartupFailureMessage           = "Plugin startup failed: "
)

Variables

This section is empty.

Functions

func PrintMetadata added in v0.2.0

func PrintMetadata(pluginFunc PluginFunc) int

func Serve

func Serve(opts *ServeOpts) error

Serve creates and starts the GRPC server which serves the plugin,

It is called from the main function of the plugin.
ServeOpts.PluginFunc must be populated with the plugin constructor function

func TestDescribe

func TestDescribe(t *testing.T, p TailpipePlugin)

func TestIdentifier

func TestIdentifier(t *testing.T, p TailpipePlugin)

func TestSources

func TestSources(t *testing.T, p TailpipePlugin)

func TestTables

func TestTables(t *testing.T, p TailpipePlugin)

func Validate

func Validate(t *testing.T, ctor func() (TailpipePlugin, error))

Types

type ObserverWrapper

type ObserverWrapper struct {
	// contains filtered or unexported fields
}

ObserverWrapper mapd between proto Observer and the plugin Observer

func NewObserverWrapper

func NewObserverWrapper(protoObserver proto.TailpipePlugin_AddObserverServer) ObserverWrapper

func (ObserverWrapper) Notify

func (o ObserverWrapper) Notify(ctx context.Context, e events.Event) error

Notify implements the Observer interface but sends to a proto stream

type PluginFunc

type PluginFunc func() (TailpipePlugin, error)

type PluginImpl

type PluginImpl struct {
	observable.ObservableImpl
	// contains filtered or unexported fields
}

PluginImpl should be created via NewPluginImpl method.

func NewPluginImpl

func NewPluginImpl(identifier string) PluginImpl

NewPluginImpl creates a new PluginImpl instance with the given identifier.

func (*PluginImpl) CloseSource

func (p *PluginImpl) CloseSource(_ context.Context) error

func (*PluginImpl) Collect

Collect Implements plugin.TailpipePlugin

func (*PluginImpl) Describe

Describe implements TailpipePlugin

func (*PluginImpl) GetSupportedOperations added in v0.9.0

func (p *PluginImpl) GetSupportedOperations(_ context.Context) (*proto.GetSupportedOperationsResponse, error)

func (*PluginImpl) Identifier

func (p *PluginImpl) Identifier() string

Identifier returns the plugin name

func (*PluginImpl) Impl

func (p *PluginImpl) Impl() *PluginImpl

Impl returns the base instance - used for validation testing

func (*PluginImpl) InitSource

InitSource is called to initialise the source when this plugin is being used as a source It performs the same role as CollectorImpl.initSource for in-plugin sources the flow for using a plugin from an external plugin is as follows:

func (*PluginImpl) Notify

func (p *PluginImpl) Notify(ctx context.Context, event events.Event) error

Notify implements observable.Observer

func (*PluginImpl) OnCompleted

func (p *PluginImpl) OnCompleted(ctx context.Context, executionId string, rowCount int64, chunksWritten int32, err error) error

func (*PluginImpl) OnStarted

func (p *PluginImpl) OnStarted(ctx context.Context, executionId string) error

OnStarted is called by the plugin when it starts processing a collection request any observers are notified

func (*PluginImpl) SaveCollectionState

func (p *PluginImpl) SaveCollectionState(_ context.Context) error

func (*PluginImpl) Shutdown

func (p *PluginImpl) Shutdown(context.Context) error

Shutdown is called by Serve when the plugin exits

func (*PluginImpl) SourceCollect

func (p *PluginImpl) SourceCollect(ctx context.Context, req *proto.SourceCollectRequest) error

func (*PluginImpl) SourceCollectionComplete added in v0.7.0

func (p *PluginImpl) SourceCollectionComplete(_ context.Context) error

func (*PluginImpl) SourcePause added in v0.5.0

func (p *PluginImpl) SourcePause(_ context.Context) error

func (*PluginImpl) SourceResume added in v0.5.0

func (p *PluginImpl) SourceResume(_ context.Context) error

func (*PluginImpl) UpdateCollectionState

func (p *PluginImpl) UpdateCollectionState(ctx context.Context, req *proto.UpdateCollectionStateRequest) error

type PluginServer

type PluginServer struct {
	// contains filtered or unexported fields
}

PluginServer is a wrapper for the actual plugin - this allows us to map between the GRPC interface and the interface implemented by the plugin this is use in particular for AddObserver which has a different signature - this wrapping enables us to define plugin-scoped events which are supported by all plugin components which do not need to know about the GRPC interface and with no corresponding protobuff events

func NewPluginServer

func NewPluginServer(opts *ServeOpts) (*PluginServer, error)

func (PluginServer) AddObserver

func (PluginServer) CloseSource

func (s PluginServer) CloseSource(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

func (PluginServer) Collect

func (PluginServer) Describe

Describe returns the schema for the plugin

func (PluginServer) GetSupportedOperations added in v0.9.0

func (s PluginServer) GetSupportedOperations(ctx context.Context, _ *proto.Empty) (*proto.GetSupportedOperationsResponse, error)

func (PluginServer) InitSource

func (PluginServer) SaveCollectionState

func (s PluginServer) SaveCollectionState(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

func (PluginServer) Serve

func (s PluginServer) Serve() error

func (PluginServer) SourceCollect

func (s PluginServer) SourceCollect(ctx context.Context, req *proto.SourceCollectRequest) (*proto.Empty, error)

func (PluginServer) SourceCollectionComplete added in v0.7.0

func (s PluginServer) SourceCollectionComplete(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

func (PluginServer) SourcePause added in v0.5.0

func (s PluginServer) SourcePause(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

func (PluginServer) SourceResume added in v0.5.0

func (s PluginServer) SourceResume(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

func (PluginServer) UpdateCollectionState

func (s PluginServer) UpdateCollectionState(ctx context.Context, req *proto.UpdateCollectionStateRequest) (*proto.Empty, error)

type ServeOpts

type ServeOpts struct {
	PluginFunc PluginFunc
}

ServeOpts are the configurations to serve a plugin.

type TailpipePlugin

type TailpipePlugin interface {
	// Identifier returns the plugin name
	// this must be implemented by the plugin implementation
	Identifier() string

	// Describe returns the duck DB schema for all tables
	// this must be implemented by the plugin implementation
	Describe(ctx context.Context, req *proto.DescribeRequest) (*proto.DescribeResponse, error)

	// AddObserver adda an observer to the plugin to receive status events
	// this is implemented by plugin.PluginImpl and should not be overridden
	AddObserver(observable.Observer) error

	// Collect is called to start a collection run
	// this is implemented by plugin.PluginImpl
	Collect(context.Context, *proto.CollectRequest) (*row_source.ResolvedFromTime, *schema.TableSchema, error)

	// UpdateCollectionState is called to update the collection state
	UpdateCollectionState(ctx context.Context, req *proto.UpdateCollectionStateRequest) error

	InitSource(context.Context, *proto.InitSourceRequest) (row_source.RowSource, error)
	CloseSource(context.Context) error
	SaveCollectionState(context.Context) error
	SourceCollect(context.Context, *proto.SourceCollectRequest) error
	SourcePause(context.Context) error
	SourceResume(context.Context) error
	SourceCollectionComplete(context.Context) error
	GetSupportedOperations(context.Context) (*proto.GetSupportedOperationsResponse, error)

	// Shutdown is implemented by plugin.PluginImpl (empty implementation)
	// it may be overridden by the plugin
	Shutdown(context.Context) error

	// Impl returns the common plugin implementation - used for validation testing
	Impl() *PluginImpl
}

TailpipePlugin is the interface that all tailpipe plugins must implement It is in its own package to avoid circular dependencies as many people need to reference it

Jump to

Keyboard shortcuts

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