managerclient

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const TolerateDirtyWrites = 20

TolerateDirtyWrites defines how many dirty writes the client should tolerate before giving up on writing the value to the manager.

Variables

View Source
var (
	// ErrVersionMismatch is returned when the requested operation errors out due to a mismatch in the document version.
	// Two writes using the same document version occurred but this writes failed as the document was modified by the other write.
	ErrVersionMismatch = errors.New("requested operation failed due to document version mismatch")

	// ErrNotFound is returned when the requested resource, i.e. Config, cluster, task etc. is not found.
	ErrNotFound = errors.New("not found")
)
View Source
var ErrRetriesExhausted = errors.New("exhausted all retries")

ErrRetriesExhausted is returned when all the TolerateDirtyWrites retries fail due to a dirty write.

Functions

func Retry

func Retry(logger *zerolog.Logger, description string, fn func() error) error

Retry retries the passed in function up to TolerateDirtyWrites times. On first error that is not ErrVersionMismatch or a total of TolerateDirtyWrites retries are executed, the underlying non-retryable error is returned or the ErrRetriesExhausted error is returned.

Types

type Client

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

func New

func New(logger *zerolog.Logger) (*Client, error)

func (*Client) Close

func (t *Client) Close() error

func (*Client) GetConfig

func (t *Client) GetConfig(ctx context.Context, request *GetConfigRequest) (*GetConfigResponse, error)

func (*Client) HealthCheck

func (t *Client) HealthCheck() error

func (*Client) ListConfigs

func (t *Client) ListConfigs(ctx context.Context, _ *ListConfigRequest) (*ListConfigResponse, error)

func (*Client) MarkForDeletion

func (t *Client) MarkForDeletion(ctx context.Context, request *MarkForDeletionRequest) error

func (*Client) NextTask

func (t *Client) NextTask(ctx context.Context) (*NextTaskResponse, error)

func (*Client) TaskComplete

func (t *Client) TaskComplete(ctx context.Context, req *TaskCompleteRequest) error

func (*Client) TaskUpdate

func (t *Client) TaskUpdate(ctx context.Context, req *TaskUpdateRequest) error

func (*Client) UpdateNodePool

func (t *Client) UpdateNodePool(ctx context.Context, req *UpdateNodePoolRequest) error

func (*Client) UpsertManifest

func (t *Client) UpsertManifest(ctx context.Context, request *UpsertManifestRequest) error

type ClientAPI

ClientAPI wraps all manager apis into a single interface.

type CrudAPI

type CrudAPI interface {
	// GetConfig will query the config with the specified name. If the requested
	// config is not found the ErrNotFound error is returned.
	GetConfig(ctx context.Context, request *GetConfigRequest) (*GetConfigResponse, error)
	// ListConfigs will query all the configs the manager handles.
	ListConfigs(ctx context.Context, request *ListConfigRequest) (*ListConfigResponse, error)
}

type GetConfigRequest

type GetConfigRequest struct{ Name string }

type GetConfigResponse

type GetConfigResponse struct{ Config *spec.Config }

type KubernetesContext

type KubernetesContext struct{ Name, Namespace string }

type ListConfigRequest

type ListConfigRequest struct{}

type ListConfigResponse

type ListConfigResponse struct{ Config []*spec.Config }

type Manifest

type Manifest struct{ Raw string }

type ManifestAPI

type ManifestAPI interface {
	// UpsertManifest will update the [store.Manifest] and [store.KubernetesContext] of an existing
	// config or will create a new config (if not present) from the passed in values.
	// The function will return the ErrVersionMismatch error indicating a Dirty write,
	// the application code should execute the Read/Update/Write cycle again, to resolve the merge conflicts.
	UpsertManifest(ctx context.Context, request *UpsertManifestRequest) error

	// MarkForDeletion will mark the Infrastructure of the specified Config to be deleted.
	// If the requested config with the specific version is not found the ErrVersionMismatch error is
	// returned indicating a Dirty write. On a Dirty write the application code should execute
	// the Read/Update/Write cycle again. If the config is not present an error will be returned
	// along with other errors. If the requested config for deletion is not found the ErrNotFound error
	// is returned.
	MarkForDeletion(ctx context.Context, request *MarkForDeletionRequest) error
}

type MarkForDeletionRequest

type MarkForDeletionRequest struct{ Name string }

type NextTaskResponse

type NextTaskResponse struct {
	Config  string
	Cluster string
	TTL     int32
	Current *spec.Clusters
	Event   *spec.TaskEvent
	State   *spec.Workflow
}

type StateAPI

type StateAPI interface {
	// UpdateNodePool will update the nodepool of a cluster within a config. If during an update a dirty
	// write occurs the ErrVersionMismatch error is returned. On a dirty write the application code should execute
	// the Read/Update/Write cycle again. If either one of nodepool, cluster, config is not found the ErrNotFound
	// error is returned.
	UpdateNodePool(ctx context.Context, request *UpdateNodePoolRequest) error
}

type TaskAPI

type TaskAPI interface {
	// NextTask will fetch the next task from the queue of tasks available at the Manager service.
	// If no tasks are available a nil response and a nil error is returned. If at any point an error
	// occurred an error is returned describing the cause. The API on server performs validation before
	// and initialization before returning the task, thus the error ErrVersionMismatch will be returned in
	// case a dirty write occurred on the server side. On the Client it is simply enough to call the
	// NextTask function again. Once new tasks are scheduled a non-nil response is returned.
	// If no tasks are scheduled or the Config for which the task was scheduled was deleted in the
	// meantime, the ErrNotFound error is returned.
	NextTask(ctx context.Context) (*NextTaskResponse, error)

	// TaskUpdate will update the state of the cluster within the specified config and version. If the requested config version is not
	// found the ErrVersionMismatch error is returned indicating a Dirty write. On a dirty write the application code
	// should execute the Read/Update/Write cycle again. If either the config or the cluster within the config or
	// the task for which the state should be updated is not found the ErrNotFound error is returned.
	TaskUpdate(ctx context.Context, request *TaskUpdateRequest) error

	// TaskComplete will mark the given task as completed either with status "DONE" or "ERROR. Further, it will update
	// the current state of the cluster within the specified config and version. If the requested config version is not
	// found the ErrVersionMismatch error is returned indicating a Dirty write. On a dirty write the application code
	// should execute the Read/Update/Write cycle again. If either the (cluster, config, task) triple is not found the
	// ErrNotFound error is returned.
	TaskComplete(ctx context.Context, request *TaskCompleteRequest) error
}

type TaskCompleteRequest

type TaskCompleteRequest struct {
	Config   string
	Cluster  string
	TaskId   string
	Workflow *spec.Workflow
	State    *spec.Clusters
}

type TaskUpdateRequest

type TaskUpdateRequest struct {
	Config  string
	Cluster string
	TaskId  string
	State   *spec.Workflow
}

type UpdateNodePoolRequest

type UpdateNodePoolRequest struct {
	Config   string
	Cluster  string
	NodePool *spec.NodePool
}

type UpsertManifestRequest

type UpsertManifestRequest struct {
	Name     string
	Manifest *Manifest
	K8sCtx   *KubernetesContext
}

Jump to

Keyboard shortcuts

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