Documentation
¶
Overview ¶
Package state describes interface of the core state manager/broker.
Index ¶
- func IsConflictError(err error) bool
- func IsNotFoundError(err error) bool
- func IsOwnerConflictError(err error) bool
- type CoreState
- type CreateOption
- type CreateOptions
- type DestroyOption
- type DestroyOptions
- type ErrConflict
- type ErrNotFound
- type ErrOwnerConflict
- type Event
- type EventType
- type GetOption
- type GetOptions
- type ListOption
- type ListOptions
- type ResourceConditionFunc
- type State
- type TeardownOption
- type TeardownOptions
- type UpdateOption
- type UpdateOptions
- type UpdaterFunc
- type WatchForCondition
- type WatchForConditionFunc
- type WatchKindOption
- type WatchKindOptions
- type WatchOption
- type WatchOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConflictError ¶
IsConflictError checks if err is resource already exists/update conflict.
func IsNotFoundError ¶
IsNotFoundError checks if err is resource not found.
func IsOwnerConflictError ¶
IsOwnerConflictError checks if err is owner conflict error.
Types ¶
type CoreState ¶
type CoreState interface { // Get a resource by type and ID. // // If a resource is not found, error is returned. Get(context.Context, resource.Pointer, ...GetOption) (resource.Resource, error) // List resources by type. List(context.Context, resource.Kind, ...ListOption) (resource.List, error) // Create a resource. // // If a resource already exists, Create returns an error. Create(context.Context, resource.Resource, ...CreateOption) 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. Update(ctx context.Context, curVersion resource.Version, newResource resource.Resource, opts ...UpdateOption) error // Destroy a resource. // // If a resource doesn't exist, error is returned. // If a resource has pending finalizers, error is returned. Destroy(context.Context, resource.Pointer, ...DestroyOption) 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. Watch(context.Context, resource.Pointer, chan<- Event, ...WatchOption) error // WatchKind watches resources of specific kind (namespace and type). WatchKind(context.Context, resource.Kind, chan<- Event, ...WatchKindOption) error }
CoreState is the central broker in the system handling state and changes.
CoreState provides the core API that should be implemented. State extends CoreState API, but it can be implemented on top of CoreState.
type CreateOption ¶
type CreateOption func(*CreateOptions)
CreateOption builds CreateOptions.
func WithCreateOwner ¶
func WithCreateOwner(owner string) CreateOption
WithCreateOwner sets an owner for the created object.
type CreateOptions ¶
type CreateOptions struct {
Owner string
}
CreateOptions for the CoreState.Create function.
type DestroyOption ¶
type DestroyOption func(*DestroyOptions)
DestroyOption builds DestroyOptions.
func WithDestroyOwner ¶
func WithDestroyOwner(owner string) DestroyOption
WithDestroyOwner checks an owner on the object being destroyed.
type DestroyOptions ¶
type DestroyOptions struct {
Owner string
}
DestroyOptions for the CoreState.Destroy function.
type ErrConflict ¶
type ErrConflict interface {
ConflictError()
}
ErrConflict should be implemented by already exists/update conflict errors.
type ErrNotFound ¶
type ErrNotFound interface {
NotFoundError()
}
ErrNotFound should be implemented by "not found" errors.
type ErrOwnerConflict ¶
type ErrOwnerConflict interface {
OwnerConflictError()
}
ErrOwnerConflict should be implemented by owner conflict errors.
type EventType ¶
type EventType int
EventType is a type of StateEvent related to resource change.
type GetOptions ¶
type GetOptions struct {
Owner string
}
GetOptions for the CoreState.Get function.
type ListOptions ¶
type ListOptions struct {
Owner string
}
ListOptions for the CoreState.List function.
type ResourceConditionFunc ¶
ResourceConditionFunc checks some condition on the resource.
type State ¶
type State interface { CoreState // UpdateWithConflicts automatically handles conflicts on update. UpdateWithConflicts(context.Context, resource.Pointer, UpdaterFunc, ...UpdateOption) (resource.Resource, error) // WatchFor watches for resource to reach all of the specified conditions. WatchFor(context.Context, resource.Pointer, ...WatchForConditionFunc) (resource.Resource, 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 returns a flag telling whether it's fine to destroy a resource. Teardown(context.Context, resource.Pointer, ...TeardownOption) (bool, error) // AddFinalizer adds finalizer to resource metadata handling conflicts. AddFinalizer(context.Context, resource.Pointer, ...resource.Finalizer) error // RemoveFinalizer removes finalizer from resource metadata handling conflicts. RemoveFinalizer(context.Context, resource.Pointer, ...resource.Finalizer) error }
State extends CoreState with additional features which can be implemented on any CoreState.
type TeardownOption ¶
type TeardownOption func(*TeardownOptions)
TeardownOption builds TeardownOptions.
func WithTeardownOwner ¶
func WithTeardownOwner(owner string) TeardownOption
WithTeardownOwner checks an owner on the object being torn down.
type TeardownOptions ¶
type TeardownOptions struct {
Owner string
}
TeardownOptions for the CoreState.Teardown function.
type UpdateOption ¶
type UpdateOption func(*UpdateOptions)
UpdateOption builds UpdateOptions.
func WithUpdateOwner ¶
func WithUpdateOwner(owner string) UpdateOption
WithUpdateOwner checks an owner on the object being updated.
type UpdateOptions ¶
type UpdateOptions struct {
Owner string
}
UpdateOptions for the CoreState.Update function.
type UpdaterFunc ¶
UpdaterFunc is called on resource to update it to the desired state.
UpdaterFunc should also bump resource version.
type WatchForCondition ¶
type WatchForCondition struct { // If set, match only if func returns true. Condition ResourceConditionFunc // If set, wait for resource phase to be one of the specified. Phases []resource.Phase // If set, watch only for specified event types. EventTypes []EventType // If true, wait for the finalizers to empty FinalizersEmpty bool }
WatchForCondition describes condition WatchFor is waiting for.
type WatchForConditionFunc ¶
type WatchForConditionFunc func(*WatchForCondition) error
WatchForConditionFunc builds WatchForCondition.
func WithCondition ¶
func WithCondition(conditionFunc ResourceConditionFunc) WatchForConditionFunc
WithCondition for specified condition on the resource.
func WithEventTypes ¶
func WithEventTypes(types ...EventType) WatchForConditionFunc
WithEventTypes watches for specified event types (one of).
func WithFinalizerEmpty ¶
func WithFinalizerEmpty() WatchForConditionFunc
WithFinalizerEmpty waits for the resource finalizers to be empty.
func WithPhases ¶
func WithPhases(phases ...resource.Phase) WatchForConditionFunc
WithPhases watches for specified resource phases.
type WatchKindOption ¶
type WatchKindOption func(*WatchKindOptions)
WatchKindOption builds WatchOptions.
func WithBootstrapContents ¶
func WithBootstrapContents(enable bool) WatchKindOption
WithBootstrapContents enables loading initial list of resources as 'created' events for WatchKind API.
type WatchKindOptions ¶
type WatchKindOptions struct {
BootstrapContents bool
}
WatchKindOptions for the CoreState.WatchKind function.
Directories
¶
Path | Synopsis |
---|---|
Package conformance implements tests which verify conformance of the implementation with the spec.
|
Package conformance implements tests which verify conformance of the implementation with the spec. |
impl
|
|
inmem
Package inmem provides an implementation of state.State in memory.
|
Package inmem provides an implementation of state.State in memory. |
namespaced
Package namespaced provides an implementation of state split by namespaces.
|
Package namespaced provides an implementation of state split by namespaces. |
Package protobuf provides wrappers/adapters between gRPC service and state.CoreState.
|
Package protobuf provides wrappers/adapters between gRPC service and state.CoreState. |
client
Package client provides a wrapper around gRPC State client to provide state.CoreState.
|
Package client provides a wrapper around gRPC State client to provide state.CoreState. |
server
Package server provides a wrapper around state.CoreState into gRPC server.
|
Package server provides a wrapper around state.CoreState into gRPC server. |
Package registry provides registries for namespaces and resource definitions.
|
Package registry provides registries for namespaces and resource definitions. |