internal

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNestedMap

func GetNestedMap[K1, K2 comparable, V any, M ~map[K2]V](m map[K1]M, k K1) M

GetNestedMap is a utility function for nested maps. It will create the map at the given key if it does not already exist, then returns the corresponding map.

Types

type RawResourceHandler

type RawResourceHandler interface {
	// AllSubscriptions returns a sequence of all the subscriptions in this client.
	AllSubscriptions() iter.Seq[string]
	// HandleResponses should be called whenever responses are received. Accepts a slice of responses,
	// since the client may support chunking. The given boolean parameter indicates whether this is the
	// set of responses received for a stream. This is used to determine whether any resources were
	// deleted while the client was disconnected.
	HandleResponses(isFirst bool, responses []*ads.DeltaDiscoveryResponse) error
}

RawResourceHandler is a non-generic interface implemented by ResourceHandler. Used by the non-generic github.com/linkedin/diderot.ADSClient.

type ResourceHandler

type ResourceHandler[T proto.Message] struct {
	// contains filtered or unexported fields
}

ResourceHandler implements the core logic of managing notifications for watchers.

func NewResourceHandler

func NewResourceHandler[T proto.Message]() *ResourceHandler[T]

func (*ResourceHandler[T]) AddWatcher

func (h *ResourceHandler[T]) AddWatcher(name string, w Watcher[T]) bool

AddWatcher registers the given Watcher against the given resource name. The watcher will be notified whenever the resource is created, updated or deleted. The returned boolean indicates whether the watcher was a new registration, or was already previously registered. If a value for the given resource is already known, the watcher is immediately notified.

func (*ResourceHandler[T]) AllSubscriptions

func (h *ResourceHandler[T]) AllSubscriptions() iter.Seq[string]

func (*ResourceHandler[T]) HandleResponses

func (h *ResourceHandler[T]) HandleResponses(isFirst bool, responses []*ads.DeltaDiscoveryResponse) error

type Watcher

type Watcher[T proto.Message] interface {
	Notify(resources iter.Seq2[string, *ads.Resource[T]]) error
}

Watcher is a copy of the interface of the same name in the root package, to avoid import cycles.

Jump to

Keyboard shortcuts

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