updater

package
v0.5.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package updater will provide an interface to update the unit stucts before inserting into DB

Users can implement their own logic to mutate units struct to manipulate each unit struct

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplID         = errors.New("duplicate ID found in updaters config")
	ErrUnknownUpdater = errors.New("unknown updater found in the config")
	ErrInvalidID      = errors.New("invalid updater ID. It must contain only [a-zA-Z0-9-_]")
)

Custom errors.

Functions

func Register added in v0.2.0

func Register(
	name string,
	factory func(instance Instance, logger log.Logger) (Updater, error),
)

Register registers updater struct into factories.

Types

type Config

type Config[T any] struct {
	Instances []T `yaml:"updaters"`
}

Config contains the configuration of updater(s).

type Instance

type Instance struct {
	ID      string           `yaml:"id"`
	Updater string           `yaml:"updater"`
	Web     models.WebConfig `yaml:"web"`
	CLI     models.CLIConfig `yaml:"cli"`
	Extra   yaml.Node        `yaml:"extra_config"`
}

Instance contains the configuration of the given updater.

type UnitUpdater

type UnitUpdater struct {
	Updaters map[string]Updater
	Logger   log.Logger
}

UnitUpdater implements the interface to update compute units from different updaters.

func New added in v0.2.0

func New(logger log.Logger) (*UnitUpdater, error)

New creates a new UnitUpdater.

func (UnitUpdater) Update

func (u UnitUpdater) Update(
	ctx context.Context,
	startTime time.Time,
	endTime time.Time,
	clusterUnits []models.ClusterUnits,
) []models.ClusterUnits

Update implements updating units using registered updaters.

type Updater

type Updater interface {
	Update(
		ctx context.Context,
		startTime time.Time,
		endTime time.Time,
		units []models.ClusterUnits,
	) []models.ClusterUnits
}

Updater interface.

Directories

Path Synopsis
Package tsdb provides the TSDB based updater for CEEMS
Package tsdb provides the TSDB based updater for CEEMS

Jump to

Keyboard shortcuts

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