gadget

package
v0.0.0-...-1b9946f Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLabelNotFound = errors.New("label not found")
View Source
var ErrNullDataRef = errors.New("null data ref")

Functions

func ExtractBatchSize

func ExtractBatchSize(
	query url.Values,
	maxBatchSize int,
) (int, error)

ExtractBatchSize extracts the batch size from the query string. If the batch size is not specified, the default batch size is used. If the batch size is too large, an error is returned.

func GetOutputLabelFromRef

func GetOutputLabelFromRef(
	ctx context.Context,
	label *api.Label,
	ref *DataRef,
	log *zap.Logger,
) (*api.Label, error)

func HandleDeleteOutputLabel

func HandleDeleteOutputLabel(
	labelStore labelstore.LabelStore,
	log *zap.Logger,
) http.HandlerFunc

HandleDeleteOutputLabel deletes a label from the output channel. deleterID is required as it is used to track who deleted the label.

func HandleGetMetadata

func HandleGetMetadata(
	metadata *metadata.Metadata,
	log *zap.Logger,
) http.HandlerFunc

func HandleGetOutputDataFromRef

func HandleGetOutputDataFromRef(
	gadgetID string,
	ref *DataRef,
	log *zap.Logger,
) http.HandlerFunc

handleGetOutputDataFromRef returns the data associated with input label. This is a proxy method that calls the input gadget's /output/x without transforming the data in any way.

func HandleGetOutputLabel

func HandleGetOutputLabel(
	labelStore labelstore.LabelStore,
	ref *DataRef,
	log *zap.Logger,
) http.HandlerFunc

HandleGetOutputLabel handler for retrieving a label from the output channel. The frontend invokes this to retrieve a specific label's metadata from the host gadget's underlying storage given its id.

func HandleGetOutputLabelFromRef

func HandleGetOutputLabelFromRef(
	ref *DataRef,
	log *zap.Logger,
) http.HandlerFunc

HandleGetOutputLabelFromRef a handler that retrieves output labels from the referenced gadget

func HandleInputState

func HandleInputState(
	channels map[string]*DataRef,
	log *zap.Logger,
) http.HandlerFunc

func HandleOutputLabel

func HandleOutputLabel(
	labelStore labelstore.LabelStore,
	ref *DataRef,
	payloadValidator PayloadValidator,
	log *zap.Logger,
) http.HandlerFunc

HandleOutputLabel samples labels from the output channel. This is gadget-specific as it requires querying the gadget's underlying storage.

func HandlePutOutputLabel

func HandlePutOutputLabel(
	labelStore labelstore.LabelStore,
	payloadValidator PayloadValidator,
	log *zap.Logger,
) http.HandlerFunc

HandlePutOutputLabel handler for inserting a label into the output channel. The frontend invokes this to insert labels into the host gadget's underlying storage.

func HandleSampleOutputLabelsFromRef

func HandleSampleOutputLabelsFromRef(
	ref *DataRef,
	log *zap.Logger,
) http.HandlerFunc

func HandleSampleOutputLabelsFromStore

func HandleSampleOutputLabelsFromStore(
	labelStore labelstore.LabelStore,
	maxBatchSize int,
	log *zap.Logger,
) http.HandlerFunc

func HandlerError

func HandlerError(
	r *http.Request,
	w http.ResponseWriter,
	retCode int,
	err error,
	log *zap.Logger,
)

func ResolveBaseURL

func ResolveBaseURL(gadgetName string) string

func SetupInputChannel

func SetupInputChannel(
	mux *mux.Router,
	gadgetID string,
	name string,
	ref *DataRef,
	log *zap.Logger,
)

SetupInputChannel creates handlers for the named input channel that retrieves labels/data from the given data reference.

Types

type DataRef

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

func NewDataRef

func NewDataRef(
	gadget string,
	channel string,
) *DataRef

func (*DataRef) Get

func (g *DataRef) Get(ctx context.Context) (gadget string, channel string, err error)

func (*DataRef) Set

func (g *DataRef) Set(
	ctx context.Context,
	endpoint string,
	channel string,
) error

type PayloadValidator

type PayloadValidator func(map[string]interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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