query

package
v0.0.1-alpha2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTableName

func GetTableName(componentName string) string

Types

type GetFunc

type GetFunc func(context.Context) (any, error)

Queries the component data from the host. Each get output is persisted to the storage if enabled.

type Item

type Item struct {
	Time metav1.Time `json:"time"`

	// Generic component output.
	// Either Output or OutputEncoded should be set.
	Output any `json:"output,omitempty"`

	Error error `json:"error,omitempty"`
}

Item is the basic unit of data that poller returns. If enabled, each result is persisted in the storage.

type Poller

type Poller interface {
	// Returns the poller ID.
	ID() string

	// Config returns the config used to start the poller.
	// This is useful for debugging and logging.
	Config() query_config.Config

	// Starts the poller routine.
	// Redundant calls will be skipped if there's an existing poller.
	Start(ctx context.Context, cfg query_config.Config, componentName string)
	// Stops the poller routine.
	// Safe to call multiple times.
	// Returns "true" if the poller was stopped with its reference count being zero.
	Stop(componentName string) bool

	// Last returns the last result.
	// Useful for constructing the state.
	Last() (*Item, error)
	// All returns all results.
	// Useful for constructing the events.
	All(since time.Time) ([]Item, error)
}

Defines the common query/poller interface. It polls the data source (rather than watch) in order to share the same data source with multiple components (consumer). Poll is better when there are multiple consumers (e.g., multiple log tailers) reading from the same file.

func New

func New(id string, cfg query_config.Config, getFunc GetFunc) Poller

Directories

Path Synopsis
log

Jump to

Keyboard shortcuts

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