reactive

package
v0.0.0-...-623d1b0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(ctx context.Context, callback func([]protoreflect.Value), reactiveValues ...Value)

Bind groups multiple reactive.Value instances together, de-duplicating updates using the revision of the underlying config.

The callback is invoked when one or more reactive.Values change, and is passed the current or updated value of each reactive value, in the order they were passed to Bind. Values that have never been set will be invalid (protoreflect.Value.IsValid() returns false).

For partial updates, the values passed to the callback will be either the updated value or the current value, depending on whether the value was updated in the current revision.

The callback is guaranteed to be invoked exactly once for a single change to the active config, even if multiple values in the group change at the same time. The values must all be created from the same controller, otherwise the behavior is undefined.

Types

type Controller

type Controller[T server.ConfigType[T]] struct {
	ControllerOptions
	// contains filtered or unexported fields
}

func NewController

func NewController[T server.ConfigType[T]](tracker *server.DefaultingConfigTracker[T], opts ...ControllerOption) *Controller[T]

func (*Controller[T]) Reactive

func (s *Controller[T]) Reactive(path protopath.Path) Value

func (*Controller[T]) Start

func (s *Controller[T]) Start(ctx context.Context) error

type ControllerOption

type ControllerOption func(*ControllerOptions)

func WithDiffMode

func WithDiffMode(mode DiffMode) ControllerOption

func WithLogger

func WithLogger(eventLogger *slog.Logger) ControllerOption

type ControllerOptions

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

type ControllerServer

type ControllerServer[S WatchReactiveServerStream, T server.ConfigType[T]] struct {
	*Controller[T]
}

func (*ControllerServer[S, T]) Build

func (c *ControllerServer[S, T]) Build(ctrl *Controller[T])

func (*ControllerServer[S, T]) WatchReactive

func (s *ControllerServer[S, T]) WatchReactive(in *corev1.ReactiveWatchRequest, stream S) error

type DiffMode

type DiffMode int
const (
	DiffStat DiffMode = iota
	DiffFull
)

type Encoder

type Encoder[T any] interface {
	FromValue(protoreflect.Value) T
}

type Reactive

type Reactive[T any] interface {
	Value() T
	Watch(ctx context.Context) <-chan T
	WatchFunc(ctx context.Context, onChanged func(value T))
	// contains filtered or unexported methods
}

func Message

func Message[T proto.Message](rv Value) Reactive[T]

func Scalar

func Scalar[T scalar](rv Value) Reactive[T]

type Value

type WatchReactiveServerStream

type WatchReactiveServerStream interface {
	Send(*corev1.ReactiveEvents) error
	grpc.ServerStream
}

Directories

Path Synopsis
Functions in this package are useful in a few specific cases, but require careful consideration to ensure they are used correctly.
Functions in this package are useful in a few specific cases, but require careful consideration to ensure they are used correctly.

Jump to

Keyboard shortcuts

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