cmd

package
v0.0.0-...-7404c28 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cmd NOTES

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd interface {
	// GetCommand get Command.
	GetCommand() *Command
	// Validate Cmd.
	Validate() error
}

Cmd is an interface that represents a control tools command.

func WithDeregister

func WithDeregister(sd serviced.Service) Cmd

WithDeregister init and returns the deregister command.

func WithDisableMasterSlave

func WithDisableMasterSlave(sd serviced.Service) Cmd

WithDisableMasterSlave init and returns the disabling master-slave command.

func WithDisableWriteAuthAccess

func WithDisableWriteAuthAccess(opt *options.DisableWriteOption) Cmd

WithDisableWriteAuthAccess init and returns the disabling write auth access command, it blocks write operations on the authorization phase.

func WithEnableMasterSlave

func WithEnableMasterSlave(sd serviced.Service) Cmd

WithEnableMasterSlave init and returns the enabling master-slave command.

func WithEnableWriteAuthAccess

func WithEnableWriteAuthAccess(opt *options.DisableWriteOption) Cmd

WithEnableWriteAuthAccess init and returns the enabling write command.

func WithGetDisableWriteAuthAccess

func WithGetDisableWriteAuthAccess(opt *options.DisableWriteOption) Cmd

WithGetDisableWriteAuthAccess init and returns the getting disable write option command.

func WithLog

func WithLog() Cmd

WithLog init and returns the log command.

func WithQueryRuntimeSetting

func WithQueryRuntimeSetting(settings interface{}) Cmd

WithQueryRuntimeSetting init and returns the query runtime setting command for sidecar.

func WithRefreshCache

func WithRefreshCache(op client.Interface) Cmd

WithRefreshCache init and returns the refreshing cache command.

func WithRegister

func WithRegister(sd serviced.Service) Cmd

WithRegister init and returns the register command.

func WithWrites

func WithWrites(opt *options.DisableWriteOption) []Cmd

WithWrites init and returns the disable/enable/get write operations commands that auth server needed.

type Command

type Command struct {
	// Name of this command, used to call the http handler of the command.
	Name string
	// Usage of this command, used in helper to inform the user how to use the command.
	Usage string
	// Parameters List of all needed parameters of the command, children will inherit these parameters.
	Parameters []Parameter
	// FromURL defines whether to read the parameters from url or from body, parameters should <= 5 if read from url.
	FromURL bool
	// IsHidden defines whether to show this command to the caller. if is true, caller only call this command, but not
	// get this command from help info.
	IsHidden bool
	// Run the command handler function.
	Run func(kt *kit.Kit, params map[string]interface{}) (interface{}, error)
	// contains filtered or unexported fields
}

Command is the control tools command definition.

func (*Command) Help

func (c *Command) Help() *Help

Help returns the help of the command if user set sub-cmd=help.

func (*Command) Validate

func (c *Command) Validate() error

Validate Command

type Help

type Help struct {
	Usage             string            `json:"usage"`
	Example           string            `json:"example"`
	AvailableCommands map[string]string `json:"available_commands,omitempty"`
	Parameters        map[string]string `json:"parameters,omitempty"`
}

Help cmd help info.

func CtlHelp

func CtlHelp(commands map[string]*Command) *Help

CtlHelp returns the help of control tool if user set no cmd or cmd=help.

type Parameter

type Parameter struct {
	// Name of this parameter, used to pass to the command handler.
	Name string
	// Usage of this parameter, used in helper to inform the user how to use the parameter.
	Usage string
	// Default value of this parameter, this value is passed to the command handler if not set.
	Default interface{}
	// Value the **not nil pointer** with the value type of this parameter to decode param value into it.
	Value interface{}
}

Parameter is the control tools command parameter definition.

func (*Parameter) Validate

func (p *Parameter) Validate() error

Validate Parameter

Jump to

Keyboard shortcuts

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