namespaced

package
v0.3.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package namespaced provides an implementation of state split by namespaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State implements delegating State for each namespace.

func NewState

func NewState(builder StateBuilder) *State

NewState initializes new namespaced State.

func (*State) Create

func (st *State) Create(ctx context.Context, res resource.Resource, opts ...state.CreateOption) error

Create a resource.

If a resource already exists, Create returns an error.

func (*State) Destroy

func (st *State) Destroy(ctx context.Context, ptr resource.Pointer, opts ...state.DestroyOption) error

Destroy a resource.

If a resource doesn't exist, error is returned.

func (*State) Get

func (st *State) Get(ctx context.Context, ptr resource.Pointer, opts ...state.GetOption) (resource.Resource, error)

Get a resource by type and ID.

If a resource is not found, error is returned.

func (*State) List

func (st *State) List(ctx context.Context, kind resource.Kind, opts ...state.ListOption) (resource.List, error)

List resources by kind.

func (*State) Update

func (st *State) Update(ctx context.Context, newResource resource.Resource, opts ...state.UpdateOption) error

Update a resource.

If a resource doesn't exist, error is returned. On update current version of resource `new` in the state should match the version on the backend, otherwise conflict error is returned.

func (*State) Watch

func (st *State) Watch(ctx context.Context, ptr resource.Pointer, ch chan<- state.Event, opts ...state.WatchOption) error

Watch state of a resource by type.

It's fine to watch for a resource which doesn't exist yet. Watch is canceled when context gets canceled. Watch sends initial resource state as the very first event on the channel, and then sends any updates to the resource as events.

func (*State) WatchKind

func (st *State) WatchKind(ctx context.Context, kind resource.Kind, ch chan<- state.Event, opts ...state.WatchKindOption) error

WatchKind watches resources of specific kind (namespace and type).

type StateBuilder

type StateBuilder func(resource.Namespace) state.CoreState

StateBuilder builds state by namespace.

Jump to

Keyboard shortcuts

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