Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Operations ¶
Types ¶
type Base ¶
type Base struct { }
func (*Base) Do ¶
func (b *Base) Do(ctx context.Context, request *OpsRequest) (*OpsResponse, error)
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
type Operation ¶
type Operation interface { Init(context.Context) error IsReadonly(context.Context) bool PreCheck(context.Context, *OpsRequest) error Do(context.Context, *OpsRequest) (*OpsResponse, error) }
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) 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)
type Switchover ¶
type Switchover struct { Base // contains filtered or unexported fields }
func (*Switchover) Do ¶
func (s *Switchover) Do(_ context.Context, req *OpsRequest) (*OpsResponse, error)
func (*Switchover) PreCheck ¶
func (s *Switchover) PreCheck(ctx context.Context, req *OpsRequest) error
Click to show internal directories.
Click to hide internal directories.