query

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package query provides the query/poller implementation.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoData = errors.New("no data collected yet in the poller")

Functions

This section is empty.

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

	// 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)

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

	// 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 item in the queue.
	// It returns ErrNoData if no item is collected yet.
	Last() (*Item, error)
	// All returns all results in the queue since the given time.
	// It returns ErrNoData if no item is collected yet.
	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
Package config provides the query/poller configuration.
Package config provides the query/poller configuration.
log
Package log provides the log file/output poller implementation.
Package log provides the log file/output poller implementation.
common
Package common provides the common log components.
Package common provides the common log components.
config
Package config provides the log poller configuration.
Package config provides the log poller configuration.
state
Package state provides the persistent storage layer for the log poller.
Package state provides the persistent storage layer for the log poller.
tail
Package tail implements the log file/output tail-ing operations.
Package tail implements the log file/output tail-ing operations.

Jump to

Keyboard shortcuts

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