update

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidURN         = errors.New("invalid URN")
	ErrInvalidType        = errors.New("type must be one of plugin or agent")
	ErrMultipleStrategies = errors.New("multiple strategies found in manifest")
	ErrMultipleTypes      = errors.New("multiple types found in manifest")
	ErrNoEntries          = errors.New("no entries found in manifest")
	ErrInvalidConfig      = errors.New("invalid config")
)

Functions

func ErrInvalidNamespace

func ErrInvalidNamespace(ns string) error

func GetType

func GetType[T entry](entries []T) (urn.UpdateType, error)

func ManifestMetadataFromContext

func ManifestMetadataFromContext(ctx context.Context) (*controlv1.UpdateManifest, bool)

func RegisterAgentSyncHandlerBuilder

func RegisterAgentSyncHandlerBuilder(strategy string, builder SyncHandlerBuilder)

func RegisterPluginSyncHandlerBuilder

func RegisterPluginSyncHandlerBuilder(strategy string, builder SyncHandlerBuilder)

Types

type ManifestEntryList

type ManifestEntryList []*controlv1.UpdateManifestEntry

type SyncConfig added in v0.11.1

type SyncConfig struct {
	Client      controlv1.UpdateSyncClient
	StatsClient clients.ConnStatsQuerier
	Syncer      SyncHandler
	Logger      *slog.Logger
}

func (SyncConfig) DoSync added in v0.11.1

func (conf SyncConfig) DoSync(ctx context.Context) error

func (SyncConfig) Result added in v0.11.1

func (conf SyncConfig) Result(ctx context.Context) (*controlv1.UpdateManifest, error)

type SyncHandler

type SyncHandler interface {
	GetCurrentManifest(context.Context) (*controlv1.UpdateManifest, error)
	HandleSyncResults(context.Context, *controlv1.SyncResults) error
	Strategy() string
}

type SyncHandlerBuilder

type SyncHandlerBuilder func(...any) (SyncHandler, error)

func GetAgentSyncHandlerBuilder

func GetAgentSyncHandlerBuilder[T ~string](strategy T) SyncHandlerBuilder

func GetPluginSyncHandlerBuilder

func GetPluginSyncHandlerBuilder[T ~string](strategy T) SyncHandlerBuilder

type UpdateServer

type UpdateServer struct {
	controlv1.UnsafeUpdateSyncServer
	// contains filtered or unexported fields
}

func NewUpdateServer

func NewUpdateServer(lg *slog.Logger) *UpdateServer

func (*UpdateServer) Collectors

func (s *UpdateServer) Collectors() []prometheus.Collector

func (*UpdateServer) RegisterUpdateHandler

func (s *UpdateServer) RegisterUpdateHandler(strategy string, handler UpdateTypeHandler)

func (*UpdateServer) StreamServerInterceptor

func (s *UpdateServer) StreamServerInterceptor() grpc.StreamServerInterceptor

func (*UpdateServer) SyncManifest

func (s *UpdateServer) SyncManifest(ctx context.Context, manifest *controlv1.UpdateManifest) (*controlv1.SyncResults, error)

SyncManifest implements UpdateSync. It expects a manifest with a single type and a single strategy. It will return an error if either of these conditions are not met. The package URN must be in the following format urn:opni:<type>:<strategy>:<name>

type UpdateStreamInterceptor

type UpdateStreamInterceptor interface {
	StreamServerInterceptor() grpc.StreamServerInterceptor
}

type UpdateTypeHandler

type UpdateTypeHandler interface {
	CalculateUpdate(context.Context, *controlv1.UpdateManifest) (*controlv1.PatchList, error)
	CalculateExpectedManifest(context.Context, urn.UpdateType) (*controlv1.UpdateManifest, error)
	Collectors() []prometheus.Collector
	Strategy() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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