source

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 33

Documentation

Overview

Package source provides high-level constructs to easily build source plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(p Plugin)

Register registers a Plugin source plugin in the framework. This function needs to be called in a Go init() function. Calling this function more than once will cause a panic.

Register registers a source plugin in the SDK. In order to register a source plugin with optional extraction capabilities, the extractor.Register function must be called by passing the same Plugin argument. In this case, the order in which Register and extractor.Register are called in the init() function is not relevant. This is needed for the framework to notice that the source plugin implements the extraction-related methods.

Types

type BaseInstance

type BaseInstance struct {
	plugins.BaseEvents
	plugins.BaseProgress
}

BaseInstance is a base implementation of the Instance interface. Developer-defined Instance implementations should be composed with BaseInstance to have out-of-the-box compliance with all the required interfaces.

type Instance

type Instance interface {
	// (optional) sdk.Closer
	// (optional) sdk.Progresser
	sdk.Events
	sdk.NextBatcher
	sdk.ProgressBuffer
}

Instance is an interface representing a source capture session instance returned by a call to Open of a source plugin.

Implementations of this interface must implement sdk.NextBatcher, and can optionally implement sdk.Closer and sdk.Progresser. If sdk.Closer is implemented, the Close method will be called while closing the source capture session.

type Plugin

type Plugin interface {
	plugins.Plugin
	sdk.Stringer
	sdk.StringerBuffer
	sdk.OpenParamsBuffer

	//
	// Open opens the source and starts a capture (e.g. stream of events).
	//
	// The argument string represents the user-defined parameters and
	// can be used to customize how the source is opened.
	// The return value is an Instance representing the source capture session.
	// There can be multiple instances of the same source open.
	// A successfull call to Open returns a nil error.
	//
	// The sdk.EventWriters event buffer, that is reused during each cycle
	// of new event creation, is initialized in automatic after the execution
	// of Open with the SetEvents method of the Instance interface.
	// Developers may override the default sdk.EventWriters by setting it
	// on the returned Instance with SetEvents, before returning from Open.
	// This can help specifying the data event size, the size of each
	// event batch, or just to use an implementation of the
	// sdk.EventWriters interface different from the SDK default one.
	Open(params string) (Instance, error)
}

Plugin is an interface representing a source plugin.

Jump to

Keyboard shortcuts

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