store

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConditionExists      = errors.New("condition exists on server")
	ErrConditionNotFound    = errors.New("condition not found")
	ErrMalformedCondition   = errors.New("condition data is invalid")
	ErrNoCreate             = errors.New("unable to create condition")
	ErrConditionNotComplete = errors.New("condition is not complete") // can't delete
)
View Source
var (
	ErrRepository      = errors.New("storage repository error")
	ErrActiveCondition = errors.New("server has an active condition")
)

Functions

This section is empty.

Types

type ConditionRecord added in v1.0.1

type ConditionRecord struct {
	ID         uuid.UUID            `json:"id"`
	State      rctypes.State        `json:"state"`
	Conditions []*rctypes.Condition `json:"conditions"`
}

ConditionRecord is a container of multiple conditions all handled as a single unit-of-work.

func (*ConditionRecord) FromJSON added in v1.0.1

func (c *ConditionRecord) FromJSON(rm json.RawMessage) error

func (ConditionRecord) MustJSON added in v1.0.1

func (c ConditionRecord) MustJSON() json.RawMessage

type Repository

type Repository interface {
	// Get the last condition set on a server in any state, including finished ones.
	// @serverID: required
	Get(ctx context.Context, serverID uuid.UUID) (*ConditionRecord, error)

	// Get the currently active condition. If there is nothing active, return nil. Errors only
	// when the underlying storage is unavailable
	// @serverID: required
	GetActiveCondition(ctx context.Context, serverID uuid.UUID) (*rctypes.Condition, error)

	// @serverID: required
	// @condition: required
	Create(ctx context.Context, serverID uuid.UUID, condition *rctypes.Condition) error

	// Create a condition record that encapsulates a unit of work encompassing multiple conditions
	// If you create a condition record with 0 conditions, you don't actually create anything, but
	// no error is returned.
	CreateMultiple(ctx context.Context, serverID uuid.UUID, conditions ...*rctypes.Condition) error

	// Update a condition on a server
	// @serverID: required
	// @condition: required
	Update(ctx context.Context, serverID uuid.UUID, condition *rctypes.Condition) error
}

NOTE: when updating this interface, run make gen-store-mock to make sure the mocks are updated.

func NewStore

func NewStore(config *app.Configuration, logger *logrus.Logger, stream events.Stream) (Repository, error)

Directories

Path Synopsis
Package test is a generated GoMock package.
Package test is a generated GoMock package.

Jump to

Keyboard shortcuts

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