Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultUserInfoParser(req *ProbeRequest, object *UserInfo) error
- func ParseObjFromRequest[T customizedObjType](req *ProbeRequest, parse objectParser[T], validator objectValidator[T], ...) error
- func SentProbeEvent(ctx context.Context, opsResult OpsResult, resp *ProbeResponse, log logr.Logger)
- func SortRoleByWeight(r1, r2 RoleType) bool
- func String2RoleType(roleName string) RoleType
- func UserNameAndPasswdValidator(user UserInfo) error
- func UserNameAndRoleValidator(user UserInfo) error
- func UserNameValidator(user UserInfo) error
- type AccessMode
- type BaseInternalOps
- type BaseOperations
- func (ops *BaseOperations) CheckRoleOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) CheckRunningOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) GetRoleOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) Init(properties component.Properties)
- func (ops *BaseOperations) Invoke(ctx context.Context, req *ProbeRequest) (*ProbeResponse, error)
- func (ops *BaseOperations) JoinMemberOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) LeaveMemberOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) LockOps(ctx context.Context, req *ProbeRequest, rsp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) Operations() []OperationKind
- func (ops *BaseOperations) RegisterOperation(opsKind OperationKind, operation Operation)
- func (ops *BaseOperations) RegisterOperationOnDBReady(opsKind OperationKind, operation Operation, manager component.DBManager)
- func (ops *BaseOperations) SwitchoverOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) UnlockOps(ctx context.Context, req *ProbeRequest, rsp *ProbeResponse) (OpsResult, error)
- func (ops *BaseOperations) VolumeProtectionOps(ctx context.Context, req *ProbeRequest, rsp *ProbeResponse) (OpsResult, error)
- type Operation
- type OpsResult
- type ProbeRequest
- type ProbeResponse
- type RedisEntry
- type SlaveStatus
Constants ¶
const ( ReadWrite AccessMode = "ReadWrite" Readonly AccessMode = "Readonly" None AccessMode = "None" // keys from response's metadata. RespOpKey = "operation" RespStartTimeKey = "start-time" RespRowsAffectedKey = "rows-affected" RespEndTimeKey = "end-time" RespDurationKey = "duration" StatusCode = "status-code" // 451 Unavailable For Legal Reasons, used to indicate operation failed. OperationFailedHTTPCode = "451" // 404 Not Found, used to indicate operation not found. OperationNotFoundHTTPCode = "404" // CommandSQLKey keys from request's metadata. CommandSQLKey = "sql" RSMRoleUpdateMechanismVarName = "KB_RSM_ROLE_UPDATE_MECHANISM" )
const ( PRIMARY = "primary" SECONDARY = "secondary" MASTER = "master" SLAVE = "slave" LEADER = "Leader" FOLLOWER = "Follower" LEARNER = "Learner" CANDIDATE = "Candidate" )
Variables ¶
Functions ¶
func DefaultUserInfoParser ¶
func DefaultUserInfoParser(req *ProbeRequest, object *UserInfo) error
func ParseObjFromRequest ¶
func ParseObjFromRequest[T customizedObjType](req *ProbeRequest, parse objectParser[T], validator objectValidator[T], object *T) error
func SentProbeEvent ¶
func SortRoleByWeight ¶
func SortRoleByWeight(r1, r2 RoleType) bool
func String2RoleType ¶
func String2RoleType(roleName string) RoleType
func UserNameAndPasswdValidator ¶
func UserNameAndPasswdValidator(user UserInfo) error
func UserNameAndRoleValidator ¶
func UserNameAndRoleValidator(user UserInfo) error
func UserNameValidator ¶
func UserNameValidator(user UserInfo) error
Types ¶
type BaseInternalOps ¶
type BaseOperations ¶
type BaseOperations struct { CheckRunningFailedCount int CheckStatusFailedCount int CheckRoleFailedCount int RoleUnchangedCount int FailedEventReportFrequency int // RoleDetectionThreshold is used to set the report duration of role event after role changed, // then event controller can always get rolechanged events to maintain pod label accurately // in cases of: // 1 rolechanged event lost; // 2 pod role label deleted or updated incorrectly. RoleDetectionThreshold int DBPort int DBAddress string DBType string OriRole string DBRoles map[string]AccessMode Logger logr.Logger Metadata map[string]string InitIfNeed func() bool Manager component.DBManager GetRole func(context.Context, *ProbeRequest, *ProbeResponse) (string, error) OperationsMap map[OperationKind]Operation }
func (*BaseOperations) CheckRoleOps ¶
func (ops *BaseOperations) CheckRoleOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
func (*BaseOperations) CheckRunningOps ¶
func (ops *BaseOperations) CheckRunningOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
CheckRunningOps checks whether the binding service is in running status, If check fails continuously, report an event at FailedEventReportFrequency frequency
func (*BaseOperations) GetRoleOps ¶
func (ops *BaseOperations) GetRoleOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
func (*BaseOperations) Init ¶
func (ops *BaseOperations) Init(properties component.Properties)
func (*BaseOperations) Invoke ¶
func (ops *BaseOperations) Invoke(ctx context.Context, req *ProbeRequest) (*ProbeResponse, error)
Invoke handles all invoke operations.
func (*BaseOperations) JoinMemberOps ¶
func (ops *BaseOperations) JoinMemberOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
JoinMemberOps is used to join the current member into the DB cluster. If OpsResult["event"] == "success" and err == nil, it indicates that the member has successfully Joined. In any other situation, it signifies a failure.
func (*BaseOperations) LeaveMemberOps ¶
func (ops *BaseOperations) LeaveMemberOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
LeaveMemberOps is used to remove the current member from the DB cluster. If OpsResult["event"] == "success" and err == nil, it indicates that the member has successfully left. In any other situation, it signifies a failure. - "error": is used to indicate if the leave operation has failed. If error is nil, it signifies a successful leave, and if it is not nil, it indicates a failure. - "OpsResult": provides additional detailed messages regarding the operation.
- "OpsResult['event']" can hold either "fail" or "success" based on the outcome of the leave operation.
- "OpsResult['message']" provides a specific reason explaining the event.
func (*BaseOperations) LockOps ¶
func (ops *BaseOperations) LockOps(ctx context.Context, req *ProbeRequest, rsp *ProbeResponse) (OpsResult, error)
func (*BaseOperations) Operations ¶
func (ops *BaseOperations) Operations() []OperationKind
Operations returns list of operations supported by the binding.
func (*BaseOperations) RegisterOperation ¶
func (ops *BaseOperations) RegisterOperation(opsKind OperationKind, operation Operation)
func (*BaseOperations) RegisterOperationOnDBReady ¶
func (ops *BaseOperations) RegisterOperationOnDBReady(opsKind OperationKind, operation Operation, manager component.DBManager)
func (*BaseOperations) SwitchoverOps ¶
func (ops *BaseOperations) SwitchoverOps(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
func (*BaseOperations) UnlockOps ¶
func (ops *BaseOperations) UnlockOps(ctx context.Context, req *ProbeRequest, rsp *ProbeResponse) (OpsResult, error)
func (*BaseOperations) VolumeProtectionOps ¶
func (ops *BaseOperations) VolumeProtectionOps(ctx context.Context, req *ProbeRequest, rsp *ProbeResponse) (OpsResult, error)
type Operation ¶
type Operation func(ctx context.Context, req *ProbeRequest, resp *ProbeResponse) (OpsResult, error)
type OpsResult ¶
type OpsResult map[string]interface{}
func ExecuteObject ¶
func ExecuteObject[T customizedObjType](ctx context.Context, ops BaseInternalOps, req *ProbeRequest, opsKind OperationKind, sqlTplRend cmdRender[T], msgTplRend cmdRender[T], object T) (OpsResult, error)
func QueryObject ¶
func QueryObject[T customizedObjType](ctx context.Context, ops BaseInternalOps, req *ProbeRequest, opsKind OperationKind, sqlTplRend cmdRender[T], dataProcessor resultRender[T], object T) (OpsResult, error)
type ProbeRequest ¶
type ProbeResponse ¶
type RedisEntry ¶
type SlaveStatus ¶
type SlaveStatus struct {
SecondsBehindMaster int64 `json:"Seconds_Behind_Master"`
}