client

package
v0.2.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MPL-2.0 Imports: 11 Imported by: 3

Documentation

Overview

Package client provides a wrapper around gRPC State client to provide state.CoreState.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implement state.CoreState from the gRPC State client.

func NewAdapter

func NewAdapter(client v1alpha1.StateClient) *Adapter

NewAdapter returns new Adapter from the gRPC client.

func (*Adapter) Create

func (adapter *Adapter) Create(ctx context.Context, r resource.Resource, opt ...state.CreateOption) error

Create a resource.

If a resource already exists, Create returns an error.

func (*Adapter) Destroy

func (adapter *Adapter) Destroy(ctx context.Context, resourcePointer resource.Pointer, opt ...state.DestroyOption) error

Destroy a resource.

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

func (*Adapter) Get

func (adapter *Adapter) Get(ctx context.Context, resourcePointer resource.Pointer, opt ...state.GetOption) (resource.Resource, error)

Get a resource by type and ID.

If a resource is not found, error is returned.

func (*Adapter) List

func (adapter *Adapter) List(ctx context.Context, resourceKind resource.Kind, opt ...state.ListOption) (resource.List, error)

List resources by type.

func (*Adapter) Update

func (adapter *Adapter) Update(ctx context.Context, newResource resource.Resource, opt ...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 (*Adapter) Watch

func (adapter *Adapter) Watch(ctx context.Context, resourcePointer resource.Pointer, ch chan<- state.Event, opt ...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 (*Adapter) WatchKind

func (adapter *Adapter) WatchKind(ctx context.Context, resourceKind resource.Kind, ch chan<- state.Event, opt ...state.WatchKindOption) error

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

Jump to

Keyboard shortcuts

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