server

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package server provides a wrapper around state.CoreState into gRPC server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertIDQuery added in v0.3.0

func ConvertIDQuery(input *v1alpha1.IDQuery) ([]resource.IDQueryOption, error)

ConvertIDQuery converts protobuf representation of IDQuery to state representation.

func ConvertLabelQuery

func ConvertLabelQuery(terms []*v1alpha1.LabelTerm) ([]resource.LabelQueryOption, error)

ConvertLabelQuery converts protobuf representation of LabelQuery to state representation.

Types

type State

type State struct {
	v1alpha1.UnimplementedStateServer
	// contains filtered or unexported fields
}

State implements gRPC State service.

func NewState

func NewState(state state.CoreState) *State

NewState initializes new gRPC State service implementation.

func (*State) Create

func (server *State) Create(ctx context.Context, req *v1alpha1.CreateRequest) (*v1alpha1.CreateResponse, error)

Create a resource.

If a resource already exists, Create returns an error.

func (*State) Destroy

func (server *State) Destroy(ctx context.Context, req *v1alpha1.DestroyRequest) (*v1alpha1.DestroyResponse, error)

Destroy a resource.

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

func (*State) Get

func (server *State) Get(ctx context.Context, req *v1alpha1.GetRequest) (*v1alpha1.GetResponse, error)

Get a resource by type and ID.

If a resource is not found, error is returned.

func (*State) List

func (server *State) List(req *v1alpha1.ListRequest, srv v1alpha1.State_ListServer) error

List resources by type.

func (*State) Teardown added in v1.16.0

func (server *State) Teardown(ctx context.Context, req *v1alpha1.TeardownRequest) (*v1alpha1.TeardownResponse, error)

Teardown a resource (mark as being destroyed).

If a resource doesn't exist, error is returned. It's not an error to tear down a resource which is already being torn down.

Teardown delegates to the wrapped CoreState if it implements state.Teardowner; otherwise it falls back to the default Get + Update implementation, performed in-process against the wrapped state.

func (*State) TeardownAndDestroy added in v1.16.0

TeardownAndDestroy tears down a resource and destroys it once all finalizers are gone.

The call blocks until the resource has no pending finalizers and has been destroyed.

TeardownAndDestroy delegates to the wrapped CoreState if it implements state.TeardownAndDestroyer; otherwise it falls back to the default Teardown + WatchFor + Destroy implementation, performed in-process against the wrapped state.

func (*State) Update

func (server *State) Update(ctx context.Context, req *v1alpha1.UpdateRequest) (*v1alpha1.UpdateResponse, 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 curVersion, otherwise conflict error is returned.

func (*State) Watch

func (server *State) Watch(req *v1alpha1.WatchRequest, srv v1alpha1.State_WatchServer) error

Watch state of a resource by (namespace, type) or a specific resource by (namespace, type, id).

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.

Jump to

Keyboard shortcuts

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