plugins

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: MPL-2.0 Imports: 24 Imported by: 7

Documentation

Overview

Package plugins defines APIs for source and destination plugins

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestinationPluginTestSuiteRunner added in v1.1.0

func DestinationPluginTestSuiteRunner(t *testing.T, p *DestinationPlugin, spec interface{}, tests DestinationTestSuiteTests)

func SetDestinationManagedCqColumns added in v0.13.0

func SetDestinationManagedCqColumns(tables []*schema.Table)

Overwrites or adds the CQ columns that are managed by the destination plugins (_cq_sync_time, _cq_source_name).

func TestSourcePluginSync added in v0.0.4

func TestSourcePluginSync(t *testing.T, plugin *SourcePlugin, spec specs.Source, opts ...TestSourcePluginOption)

Types

type ClientResource added in v1.1.0

type ClientResource struct {
	TableName string
	Data      []interface{}
}

type DefaultReverseTransformer added in v0.13.23

type DefaultReverseTransformer struct {
}

func (*DefaultReverseTransformer) ReverseTransformValues added in v0.13.23

func (*DefaultReverseTransformer) ReverseTransformValues(table *schema.Table, values []interface{}) (schema.CQTypes, error)

DefaultReverseTransformer tries best effort to convert a slice of values to CQTypes based on the provided table columns.

type DestinationClient added in v0.2.3

type DestinationClient interface {
	schema.CQTypeTransformer
	ReverseTransformValues(table *schema.Table, values []interface{}) (schema.CQTypes, error)
	Migrate(ctx context.Context, tables schema.Tables) error
	Read(ctx context.Context, table *schema.Table, sourceName string, res chan<- []interface{}) error
	Write(ctx context.Context, tables schema.Tables, res <-chan *ClientResource) error
	Metrics() DestinationMetrics
	DeleteStale(ctx context.Context, tables schema.Tables, sourceName string, syncTime time.Time) error
	Close(ctx context.Context) error
}

func NewTestDestinationMemDBClient added in v1.1.0

func NewTestDestinationMemDBClient(context.Context, zerolog.Logger, specs.Destination) (DestinationClient, error)

type DestinationMetrics added in v0.13.15

type DestinationMetrics struct {
	// Errors number of errors / failed writes
	Errors uint64
	// Writes number of successful writes
	Writes uint64
}

type DestinationPlugin

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

func NewDestinationPlugin added in v0.2.3

func NewDestinationPlugin(name string, version string, newDestinationClient NewDestinationClientFunc) *DestinationPlugin

func (*DestinationPlugin) Close added in v0.11.4

func (p *DestinationPlugin) Close(ctx context.Context) error

func (*DestinationPlugin) DeleteStale added in v0.12.0

func (p *DestinationPlugin) DeleteStale(ctx context.Context, tables schema.Tables, sourceName string, syncTime time.Time) error

func (*DestinationPlugin) Init added in v0.12.0

we need lazy loading because we want to be able to initialize after

func (*DestinationPlugin) Metrics added in v0.13.15

func (*DestinationPlugin) Migrate added in v0.0.4

func (p *DestinationPlugin) Migrate(ctx context.Context, tables schema.Tables) error

we implement all DestinationClient functions so we can hook into pre-post behavior

func (*DestinationPlugin) Name added in v0.0.4

func (p *DestinationPlugin) Name() string

func (*DestinationPlugin) Read added in v0.13.16

func (p *DestinationPlugin) Read(ctx context.Context, table *schema.Table, sourceName string, res chan<- schema.CQTypes) error

func (*DestinationPlugin) Version added in v0.0.4

func (p *DestinationPlugin) Version() string

func (*DestinationPlugin) Write added in v0.0.4

func (p *DestinationPlugin) Write(ctx context.Context, tables schema.Tables, sourceName string, syncTime time.Time, res <-chan schema.DestinationResource) error

type DestinationTestSuiteTests added in v1.1.0

type DestinationTestSuiteTests struct {
	// SkipOverwrite skips testing for "overwrite" mode. Use if the destination
	//	// plugin doesn't support this feature.
	SkipOverwrite bool

	// SkipDeleteStale skips testing "delete-stale" mode. Use if the destination
	// plugin doesn't support this feature.
	SkipDeleteStale bool

	// SkipAppend skips testing for "append" mode. Use if the destination
	// plugin doesn't support this feature.
	SkipAppend bool

	// SkipSecondAppend skips the second append step in the test.
	// This is useful in cases like cloud storage where you can't append to an
	// existing object after the file has been closed.
	SkipSecondAppend bool
}

type NewDestinationClientFunc added in v0.12.0

type NewDestinationClientFunc func(context.Context, zerolog.Logger, specs.Destination) (DestinationClient, error)

type SourceMetrics added in v0.13.15

type SourceMetrics struct {
	TableClient map[string]map[string]*TableClientMetrics
}

func (*SourceMetrics) Equal added in v0.13.15

func (s *SourceMetrics) Equal(other *SourceMetrics) bool

Equal compares to stats. Mostly useful in testing

func (*SourceMetrics) TotalErrors added in v0.13.15

func (s *SourceMetrics) TotalErrors() uint64

func (*SourceMetrics) TotalPanics added in v0.13.15

func (s *SourceMetrics) TotalPanics() uint64

func (*SourceMetrics) TotalResources added in v0.13.15

func (s *SourceMetrics) TotalResources() uint64

type SourceNewExecutionClientFunc added in v0.0.4

type SourceNewExecutionClientFunc func(context.Context, zerolog.Logger, specs.Source) (schema.ClientMeta, error)

type SourcePlugin

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

SourcePlugin is the base structure required to pass to sdk.serve We take a declarative approach to API here similar to Cobra

func NewSourcePlugin added in v0.0.4

func NewSourcePlugin(name string, version string, tables []*schema.Table, newExecutionClient SourceNewExecutionClientFunc) *SourcePlugin

NewSourcePlugin returns a new plugin with a given name, version, tables, newExecutionClient and additional options.

func (*SourcePlugin) GenerateSourcePluginDocs added in v0.6.4

func (p *SourcePlugin) GenerateSourcePluginDocs(dir, format string) error

GenerateSourcePluginDocs creates table documentation for the source plugin based on its list of tables

func (*SourcePlugin) Metrics added in v0.13.15

func (p *SourcePlugin) Metrics() *SourceMetrics

func (*SourcePlugin) Name

func (p *SourcePlugin) Name() string

Name return the name of this plugin

func (*SourcePlugin) SetLogger added in v0.0.4

func (p *SourcePlugin) SetLogger(logger zerolog.Logger)

func (*SourcePlugin) Sync added in v0.0.4

func (p *SourcePlugin) Sync(ctx context.Context, spec specs.Source, res chan<- *schema.Resource) error

Sync is syncing data from the requested tables in spec to the given channel

func (*SourcePlugin) Tables

func (p *SourcePlugin) Tables() schema.Tables

Tables returns all tables supported by this source plugin

func (*SourcePlugin) TablesForSpec added in v1.10.0

func (p *SourcePlugin) TablesForSpec(spec specs.Source) (schema.Tables, error)

TablesForSpec returns all tables supported by this source plugin that match the given spec. It validates the tables part of the spec and will return an error if it is found to be invalid.

func (*SourcePlugin) Version

func (p *SourcePlugin) Version() string

Version returns the version of this plugin

type TableClientMetrics added in v0.13.15

type TableClientMetrics struct {
	Resources uint64
	Errors    uint64
	Panics    uint64
	StartTime time.Time
	EndTime   time.Time
}

func (*TableClientMetrics) Equal added in v0.13.15

func (s *TableClientMetrics) Equal(other *TableClientMetrics) bool

type TestDestinationMemDBClient added in v1.1.0

type TestDestinationMemDBClient struct {
	schema.DefaultTransformer
	// contains filtered or unexported fields
}

TestDestinationMemDBClient is mostly used for testing.

func (*TestDestinationMemDBClient) Close added in v1.1.0

func (*TestDestinationMemDBClient) DeleteStale added in v1.1.0

func (c *TestDestinationMemDBClient) DeleteStale(ctx context.Context, tables schema.Tables, source string, syncTime time.Time) error

func (*TestDestinationMemDBClient) Initialize added in v1.1.0

func (*TestDestinationMemDBClient) Metrics added in v1.1.0

func (*TestDestinationMemDBClient) Migrate added in v1.1.0

func (*TestDestinationMemDBClient) Read added in v1.1.0

func (c *TestDestinationMemDBClient) Read(_ context.Context, table *schema.Table, source string, res chan<- []interface{}) error

func (*TestDestinationMemDBClient) ReverseTransformValues added in v1.1.0

func (*TestDestinationMemDBClient) ReverseTransformValues(_ *schema.Table, values []interface{}) (schema.CQTypes, error)

func (*TestDestinationMemDBClient) Write added in v1.1.0

func (c *TestDestinationMemDBClient) Write(ctx context.Context, tables schema.Tables, resources <-chan *ClientResource) error

type TestDestinationOption added in v1.5.3

type TestDestinationOption func(*TestDestinationMemDBClient)

type TestSourcePluginOption added in v0.13.8

type TestSourcePluginOption func(*testSourcePluginOptions)

func WithTestSourcePluginNoParallel added in v0.13.8

func WithTestSourcePluginNoParallel() TestSourcePluginOption

Jump to

Keyboard shortcuts

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