igeist

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Stream() Stream
	StreamId() string
	Run(ctx context.Context, wg *sync.WaitGroup)

	// ProcessEvent returns the processed/persisted event's event/resource ID, together with error, retryable.
	// The implementation varies across different sink types, but the returned resource ID it will be the key
	// used for key lookups of the event (e.g. row-key for BigTable), and will be used as the resource ID when
	// using API as Source.
	ProcessEvent(ctx context.Context, events []model.Event) model.EventProcessingResult
	Shutdown()
}

Executor interface required for Stream ETL Executors

type Extractor

type Extractor interface {

	// StreamExtract continuously consumes events from its source (until ctx is canceled),
	// and report each consumed event back to Executor with reportEvent(), for further processing.
	StreamExtract(
		ctx context.Context,
		reportEvent model.ProcessEventFunc,
		err *error,
		retryable *bool)

	// Extract provides generic extraction from the source based on the provided query, and returns directly.
	// Optional functionality. Currently only supported by Firestore extractor (but not in use). Kept for future functionality.
	Extract(ctx context.Context, query model.ExtractorQuery, result any) (error, bool)

	// ExtractFromSink extracts data from the sink used in an ETL Stream, as specified in the Extractors GEIST spec.
	// Currently only supported by Firestore and BigTable extractors.
	ExtractFromSink(ctx context.Context, query model.ExtractorQuery, result *[]*model.Transformed) (error, bool)

	// SendToSource enables external clients to send events directly to the Extractor's Source.
	// Optional functionality. Currently only supported by "geistapi" (channel) extractor (for Publish() functionality)
	// and by Pubsub extractor (used in admin stream for posting registry change events to concurrent supervisors).
	SendToSource(ctx context.Context, event any) (string, error)
}

Extractor interface required for stream source extractor implementations and for sink queries. The Extractor implementation should be given its GEIST Spec in a constructor.

For source stream extractors the only function required to be fully functional is StreamExtract().

For sink extractors the only function required to be fully functional is ExtractFromSink().

The others are situational depending on extractor/source entity type, and could be empty, e.g. simply returning nil, false (or someerror, false).

type Loader

type Loader interface {

	// If successful the event/resource ID of the loaded event is returned.
	// If input 'data' is nil or empty, an error is to be returned.
	StreamLoad(ctx context.Context, data []*model.Transformed) (string, error, bool)

	// Called by Executor during shutdown of the stream
	Shutdown()
}

Loader interface required for stream sink Loader implementations. Only certain types of Loader implementations might support multiple input Transformed object. For example, while a BigTable implementation might only support a single (first) Transformed object, as input to which fields from a single event to insert to the table, a Kafka implementation might receive multiple Transformed object (as the result from a EventSplit transformation type), all of which should be sent as separate events to the specified Kafka topic.

type Registry

type Registry interface {
	Fetch(ctx context.Context) error
	Put(ctx context.Context, id string, spec Spec) error
	Get(ctx context.Context, id string) (Spec, error)
	GetAll(ctx context.Context) (map[string]Spec, error)
	Delete(ctx context.Context, id string) error
	Exists(id string) bool
	ExistsSameVersion(specData []byte) (bool, error)
	Validate(spec []byte) (Spec, error)
}

type Spec

type Spec interface {
	Id() string       // Returns Stream Spec ID
	IsDisabled() bool // True if spec is disabled and should not be run by Executor
	Validate() error  // Returns an error if Spec is not according to spec
	JSON() []byte     // Returns spec data as JSON
}

type Stream

type Stream interface {
	Spec() Spec
	Instance() string
	Extractor() Extractor
	Transformer() Transformer
	Loader() Loader
	Publish(ctx context.Context, event []byte) (string, error)
	ExtractFromSink(
		ctx context.Context,
		query model.ExtractorQuery,
		result *[]*model.Transformed) (error, bool)
}

type StreamBuilder

type StreamBuilder interface {
	Build(ctx context.Context, spec Spec) (Stream, error)
}

type StreamEntityFactory

type StreamEntityFactory interface {
	SetAdminLoader(loader Loader)
	CreateExtractor(ctx context.Context, spec Spec, instanceId string) (Extractor, error)
	CreateSinkExtractor(ctx context.Context, spec Spec, instanceId string) (Extractor, error)
	CreateTransformer(ctx context.Context, spec Spec) (Transformer, error)
	CreateLoader(ctx context.Context, spec Spec, instanceId string) (Loader, error)
}

type StreamRegistry

type StreamRegistry interface {
	Registry
	Executor
	SetAdminStream(stream Stream)
}

A StreamRegistry is a Registry also managing a stream as an Executor, receiving Specs to be added to registry in an arbitrary ETL stream, e.g. via Kafka or REST API into a db. It is also required to publish admin events when registry is modified (e.g. new stream registrations, etc).

type Transformer

type Transformer interface {
	// Based on input event data, and the transformation rules in the Spec, the Transform() function returns
	// a key-value map where keys are "id" fields from Transform spec, and values are the transformation results.
	// The output from Transform() can contain multiple new events, in case of applied
	// event-split transformations.
	// If Transform() succeeded, but the transformation resulted in no output, e.g. for non-applicable incoming events,
	// the return values are nil, nil (i.e., not regarded as an error).
	Transform(
		ctx context.Context,
		event []byte,
		retryable *bool) ([]*model.Transformed, error)
}

Transformer interface required for transformer implementations

Jump to

Keyboard shortcuts

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