Documentation ¶
Index ¶
- func Operations() map[string]Operation
- func Register(name string, op Operation) error
- type Base
- func (b *Base) Do(ctx context.Context, request *OpsRequest) (*OpsResponse, error)
- func (b *Base) Init(ctx context.Context) error
- func (b *Base) IsReadonly(ctx context.Context) bool
- func (b *Base) PreCheck(ctx context.Context, request *OpsRequest) error
- func (b *Base) SetTimeout(timeout time.Duration)
- type FakeFuncType
- type FakeOperations
- func (f *FakeOperations) Do(ctx context.Context, request *OpsRequest) (*OpsResponse, error)
- func (f *FakeOperations) Init(ctx context.Context) error
- func (f *FakeOperations) IsReadonly(ctx context.Context) bool
- func (f *FakeOperations) PreCheck(ctx context.Context, request *OpsRequest) error
- func (f *FakeOperations) SetTimeout(timeout time.Duration)
- type Operation
- type Ops
- type OpsMetadata
- type OpsRequest
- type OpsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Operations ¶
Types ¶
type Base ¶
func (*Base) Do ¶
func (b *Base) Do(ctx context.Context, request *OpsRequest) (*OpsResponse, error)
func (*Base) SetTimeout ¶ added in v0.8.4
type FakeFuncType ¶
type FakeFuncType string
const ( FakeInit FakeFuncType = "fake-init" FakeIsReadOnly FakeFuncType = "fake-is-read-only" FakePreCheck FakeFuncType = "fake-pre-check" FakeDo FakeFuncType = "fake-do" FakeDefault FakeFuncType = "fake-default" )
type FakeOperations ¶
type FakeOperations struct { InitFunc func(ctx context.Context) error IsReadOnlyFunc func(ctx context.Context) bool PreCheckFunc func(ctx context.Context, request *OpsRequest) error DoFunc func(ctx context.Context, request *OpsRequest) (*OpsResponse, error) }
func NewFakeOperations ¶
func NewFakeOperations(funcType FakeFuncType, fakeFunc interface{}) *FakeOperations
func (*FakeOperations) Do ¶
func (f *FakeOperations) Do(ctx context.Context, request *OpsRequest) (*OpsResponse, error)
func (*FakeOperations) IsReadonly ¶
func (f *FakeOperations) IsReadonly(ctx context.Context) bool
func (*FakeOperations) PreCheck ¶
func (f *FakeOperations) PreCheck(ctx context.Context, request *OpsRequest) error
func (*FakeOperations) SetTimeout ¶ added in v0.8.4
func (f *FakeOperations) SetTimeout(timeout time.Duration)
type OpsMetadata ¶
type OpsMetadata struct { Operation util.OperationKind `json:"operation,omitempty"` StartTime string `json:"startTime,omitempty"` EndTime string `json:"endTime,omitempty"` Extra string `json:"extra,omitempty"` }
type OpsRequest ¶
type OpsRequest struct { Data []byte `json:"data,omitempty"` Parameters map[string]any `json:"parameters,omitempty"` }
OpsRequest is the request for Operation
func (*OpsRequest) GetBool ¶
func (r *OpsRequest) GetBool(key string) bool
func (*OpsRequest) GetString ¶
func (r *OpsRequest) GetString(key string) string
type OpsResponse ¶
type OpsResponse struct { Data map[string]any `json:"data,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
OpsResponse is the response for Operation
func NewOpsResponse ¶
func NewOpsResponse(operation util.OperationKind) *OpsResponse
func (*OpsResponse) WithError ¶
func (resp *OpsResponse) WithError(err error) (*OpsResponse, error)
func (*OpsResponse) WithSuccess ¶
func (resp *OpsResponse) WithSuccess(msg string) (*OpsResponse, error)
Click to show internal directories.
Click to hide internal directories.