store

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 17 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")
	ErrConditionComplete  = errors.New("condition is in a final state") // can't update
)
View Source
var (
	ErrRepository      = errors.New("storage repository error")
	ErrActiveCondition = errors.New("server has an active condition")
)
View Source
var (
	ActiveConditionBucket = "active-conditions"
)

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"`
	Facility   string               `json:"facility"`
	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 MockRepository

type MockRepository struct {
	mock.Mock
}

MockRepository is an autogenerated mock type for the Repository type

func NewMockRepository

func NewMockRepository(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRepository

NewMockRepository creates a new instance of MockRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRepository) Create

func (_m *MockRepository) Create(ctx context.Context, serverID uuid.UUID, facilityCode string, conditions ...*condition.Condition) error

Create provides a mock function with given fields: ctx, serverID, facilityCode, conditions

func (*MockRepository) EXPECT

func (*MockRepository) Get

func (_m *MockRepository) Get(ctx context.Context, serverID uuid.UUID) (*ConditionRecord, error)

Get provides a mock function with given fields: ctx, serverID

func (*MockRepository) GetActiveCondition added in v0.1.12

func (_m *MockRepository) GetActiveCondition(ctx context.Context, serverID uuid.UUID) (*condition.Condition, error)

GetActiveCondition provides a mock function with given fields: ctx, serverID

func (*MockRepository) List

func (_m *MockRepository) List(ctx context.Context) ([]*ConditionRecord, error)

List provides a mock function with given fields: ctx

func (*MockRepository) Update

func (_m *MockRepository) Update(ctx context.Context, serverID uuid.UUID, _a2 *condition.Condition) error

Update provides a mock function with given fields: ctx, serverID, _a2

type MockRepository_Create_Call added in v1.1.4

type MockRepository_Create_Call struct {
	*mock.Call
}

MockRepository_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'

func (*MockRepository_Create_Call) Return added in v1.1.4

func (*MockRepository_Create_Call) Run added in v1.1.4

func (_c *MockRepository_Create_Call) Run(run func(ctx context.Context, serverID uuid.UUID, facilityCode string, conditions ...*condition.Condition)) *MockRepository_Create_Call

func (*MockRepository_Create_Call) RunAndReturn added in v1.1.4

type MockRepository_Expecter added in v1.0.9

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

func (*MockRepository_Expecter) Create added in v1.1.4

func (_e *MockRepository_Expecter) Create(ctx interface{}, serverID interface{}, facilityCode interface{}, conditions ...interface{}) *MockRepository_Create_Call

Create is a helper method to define mock.On call

  • ctx context.Context
  • serverID uuid.UUID
  • facilityCode string
  • conditions ...*condition.Condition

func (*MockRepository_Expecter) Get added in v1.0.9

func (_e *MockRepository_Expecter) Get(ctx interface{}, serverID interface{}) *MockRepository_Get_Call

Get is a helper method to define mock.On call

  • ctx context.Context
  • serverID uuid.UUID

func (*MockRepository_Expecter) GetActiveCondition added in v1.0.9

func (_e *MockRepository_Expecter) GetActiveCondition(ctx interface{}, serverID interface{}) *MockRepository_GetActiveCondition_Call

GetActiveCondition is a helper method to define mock.On call

  • ctx context.Context
  • serverID uuid.UUID

func (*MockRepository_Expecter) List added in v1.0.9

func (_e *MockRepository_Expecter) List(ctx interface{}) *MockRepository_List_Call

List is a helper method to define mock.On call

  • ctx context.Context

func (*MockRepository_Expecter) Update added in v1.0.9

func (_e *MockRepository_Expecter) Update(ctx interface{}, serverID interface{}, _a2 interface{}) *MockRepository_Update_Call

Update is a helper method to define mock.On call

  • ctx context.Context
  • serverID uuid.UUID
  • _a2 *condition.Condition

type MockRepository_GetActiveCondition_Call added in v1.0.9

type MockRepository_GetActiveCondition_Call struct {
	*mock.Call
}

MockRepository_GetActiveCondition_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetActiveCondition'

func (*MockRepository_GetActiveCondition_Call) Return added in v1.0.9

func (*MockRepository_GetActiveCondition_Call) Run added in v1.0.9

func (*MockRepository_GetActiveCondition_Call) RunAndReturn added in v1.0.9

type MockRepository_Get_Call added in v1.0.9

type MockRepository_Get_Call struct {
	*mock.Call
}

MockRepository_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'

func (*MockRepository_Get_Call) Return added in v1.0.9

func (*MockRepository_Get_Call) Run added in v1.0.9

func (_c *MockRepository_Get_Call) Run(run func(ctx context.Context, serverID uuid.UUID)) *MockRepository_Get_Call

func (*MockRepository_Get_Call) RunAndReturn added in v1.0.9

type MockRepository_List_Call added in v1.0.9

type MockRepository_List_Call struct {
	*mock.Call
}

MockRepository_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'

func (*MockRepository_List_Call) Return added in v1.0.9

func (*MockRepository_List_Call) Run added in v1.0.9

func (*MockRepository_List_Call) RunAndReturn added in v1.0.9

type MockRepository_Update_Call added in v1.0.9

type MockRepository_Update_Call struct {
	*mock.Call
}

MockRepository_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update'

func (*MockRepository_Update_Call) Return added in v1.0.9

func (*MockRepository_Update_Call) Run added in v1.0.9

func (*MockRepository_Update_Call) RunAndReturn added in v1.0.9

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 ErrNoConditionFound.
	// @serverID: required
	GetActiveCondition(ctx context.Context, serverID uuid.UUID) (*rctypes.Condition, error)

	// Create a condition record that encapsulates a unit of work, which can encompass one or many conditions.
	// If you create a condition record with 0 conditions, you don't actually create anything, but
	// no error is returned.
	Create(ctx context.Context, serverID uuid.UUID, facilityCode string, 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

	// List all condition records
	List(ctx context.Context) ([]*ConditionRecord, 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)

Jump to

Keyboard shortcuts

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