Documentation ¶
Index ¶
- Variables
- type ConditionRecord
- type MockRepository
- func (_m *MockRepository) Create(ctx context.Context, serverID uuid.UUID, facilityCode string, ...) error
- func (_m *MockRepository) EXPECT() *MockRepository_Expecter
- func (_m *MockRepository) Get(ctx context.Context, serverID uuid.UUID) (*ConditionRecord, error)
- func (_m *MockRepository) GetActiveCondition(ctx context.Context, serverID uuid.UUID) (*condition.Condition, error)
- func (_m *MockRepository) List(ctx context.Context) ([]*ConditionRecord, error)
- func (_m *MockRepository) Update(ctx context.Context, serverID uuid.UUID, _a2 *condition.Condition) error
- type MockRepository_Create_Call
- func (_c *MockRepository_Create_Call) Return(_a0 error) *MockRepository_Create_Call
- func (_c *MockRepository_Create_Call) Run(run func(ctx context.Context, serverID uuid.UUID, facilityCode string, ...)) *MockRepository_Create_Call
- func (_c *MockRepository_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, ...*condition.Condition) error) *MockRepository_Create_Call
- type MockRepository_Expecter
- func (_e *MockRepository_Expecter) Create(ctx interface{}, serverID interface{}, facilityCode interface{}, ...) *MockRepository_Create_Call
- func (_e *MockRepository_Expecter) Get(ctx interface{}, serverID interface{}) *MockRepository_Get_Call
- func (_e *MockRepository_Expecter) GetActiveCondition(ctx interface{}, serverID interface{}) *MockRepository_GetActiveCondition_Call
- func (_e *MockRepository_Expecter) List(ctx interface{}) *MockRepository_List_Call
- func (_e *MockRepository_Expecter) Update(ctx interface{}, serverID interface{}, _a2 interface{}) *MockRepository_Update_Call
- type MockRepository_GetActiveCondition_Call
- func (_c *MockRepository_GetActiveCondition_Call) Return(_a0 *condition.Condition, _a1 error) *MockRepository_GetActiveCondition_Call
- func (_c *MockRepository_GetActiveCondition_Call) Run(run func(ctx context.Context, serverID uuid.UUID)) *MockRepository_GetActiveCondition_Call
- func (_c *MockRepository_GetActiveCondition_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*condition.Condition, error)) *MockRepository_GetActiveCondition_Call
- type MockRepository_Get_Call
- func (_c *MockRepository_Get_Call) Return(_a0 *ConditionRecord, _a1 error) *MockRepository_Get_Call
- func (_c *MockRepository_Get_Call) Run(run func(ctx context.Context, serverID uuid.UUID)) *MockRepository_Get_Call
- func (_c *MockRepository_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*ConditionRecord, error)) *MockRepository_Get_Call
- type MockRepository_List_Call
- func (_c *MockRepository_List_Call) Return(_a0 []*ConditionRecord, _a1 error) *MockRepository_List_Call
- func (_c *MockRepository_List_Call) Run(run func(ctx context.Context)) *MockRepository_List_Call
- func (_c *MockRepository_List_Call) RunAndReturn(run func(context.Context) ([]*ConditionRecord, error)) *MockRepository_List_Call
- type MockRepository_Update_Call
- func (_c *MockRepository_Update_Call) Return(_a0 error) *MockRepository_Update_Call
- func (_c *MockRepository_Update_Call) Run(run func(ctx context.Context, serverID uuid.UUID, _a2 *condition.Condition)) *MockRepository_Update_Call
- func (_c *MockRepository_Update_Call) RunAndReturn(run func(context.Context, uuid.UUID, *condition.Condition) error) *MockRepository_Update_Call
- type Repository
Constants ¶
This section is empty.
Variables ¶
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 )
var ( ErrRepository = errors.New("storage repository error") ErrActiveCondition = errors.New("server has an active condition") )
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 ¶
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 (_m *MockRepository) EXPECT() *MockRepository_Expecter
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
type MockRepository_Create_Call ¶ added in v1.1.4
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 (_c *MockRepository_Create_Call) Return(_a0 error) *MockRepository_Create_Call
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
func (_c *MockRepository_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, ...*condition.Condition) error) *MockRepository_Create_Call
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
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 (_c *MockRepository_GetActiveCondition_Call) Return(_a0 *condition.Condition, _a1 error) *MockRepository_GetActiveCondition_Call
func (*MockRepository_GetActiveCondition_Call) Run ¶ added in v1.0.9
func (_c *MockRepository_GetActiveCondition_Call) Run(run func(ctx context.Context, serverID uuid.UUID)) *MockRepository_GetActiveCondition_Call
func (*MockRepository_GetActiveCondition_Call) RunAndReturn ¶ added in v1.0.9
func (_c *MockRepository_GetActiveCondition_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*condition.Condition, error)) *MockRepository_GetActiveCondition_Call
type MockRepository_Get_Call ¶ added in v1.0.9
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 (_c *MockRepository_Get_Call) Return(_a0 *ConditionRecord, _a1 error) *MockRepository_Get_Call
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
func (_c *MockRepository_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*ConditionRecord, error)) *MockRepository_Get_Call
type MockRepository_List_Call ¶ added in v1.0.9
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 (_c *MockRepository_List_Call) Return(_a0 []*ConditionRecord, _a1 error) *MockRepository_List_Call
func (*MockRepository_List_Call) Run ¶ added in v1.0.9
func (_c *MockRepository_List_Call) Run(run func(ctx context.Context)) *MockRepository_List_Call
func (*MockRepository_List_Call) RunAndReturn ¶ added in v1.0.9
func (_c *MockRepository_List_Call) RunAndReturn(run func(context.Context) ([]*ConditionRecord, error)) *MockRepository_List_Call
type MockRepository_Update_Call ¶ added in v1.0.9
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 (_c *MockRepository_Update_Call) Return(_a0 error) *MockRepository_Update_Call
func (*MockRepository_Update_Call) Run ¶ added in v1.0.9
func (_c *MockRepository_Update_Call) Run(run func(ctx context.Context, serverID uuid.UUID, _a2 *condition.Condition)) *MockRepository_Update_Call
func (*MockRepository_Update_Call) RunAndReturn ¶ added in v1.0.9
func (_c *MockRepository_Update_Call) RunAndReturn(run func(context.Context, uuid.UUID, *condition.Condition) error) *MockRepository_Update_Call
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)