Documentation ¶
Index ¶
- Constants
- Variables
- func OddKey(arg []interface{}) []uint8
- func RecursivelyWriteObjects(local *RESPHandle.WriterHandle, reply ...interface{}) (err error)
- func WriteBulk(local *RESPHandle.WriterHandle, reply []byte) error
- func WriteBulkStrings(local *RESPHandle.WriterHandle, reply []string) error
- func WriteError(local *RESPHandle.WriterHandle, err error) error
- func WriteInt(local *RESPHandle.WriterHandle, reply int64) error
- func WriteObjects(local *RESPHandle.WriterHandle, reply ...interface{}) (err error)
- func WriteSimpleString(local *RESPHandle.WriterHandle, reply string) error
- type Context
- type HandlerFunc
- type HandlersChain
- type IRoutes
- type OpFlag
- type OpInfo
- type VerifyFunc
Constants ¶
View Source
const ( ErrUnknownCommand = "ERR command resp type not support`%s`" ErrArguments = "ERR wrong number of arguments for '%s' command" )
View Source
const ( FlagWrite = 1 << iota FlagMasterOnly FlagMayWrite FlagNotAllow )
View Source
const AbortIndex int8 = math.MaxInt8 / 2
Variables ¶
View Source
var ( ErrLocalWriter = errors.New("client conn writer error") ErrLocalFlush = errors.New("client conn flush error") ErrCmdTypeWrong = errors.New("Err command type wrong") )
View Source
var FirstKeyIndex = []uint8{1}
View Source
var OpTable = make(map[string]OpInfo, 256)
Functions ¶
func RecursivelyWriteObjects ¶
func RecursivelyWriteObjects(local *RESPHandle.WriterHandle, reply ...interface{}) (err error)
func WriteBulk ¶
func WriteBulk(local *RESPHandle.WriterHandle, reply []byte) error
func WriteBulkStrings ¶
func WriteBulkStrings(local *RESPHandle.WriterHandle, reply []string) error
func WriteError ¶
func WriteError(local *RESPHandle.WriterHandle, err error) error
func WriteInt ¶
func WriteInt(local *RESPHandle.WriterHandle, reply int64) error
func WriteObjects ¶
func WriteObjects(local *RESPHandle.WriterHandle, reply ...interface{}) (err error)
func WriteSimpleString ¶
func WriteSimpleString(local *RESPHandle.WriterHandle, reply string) error
Types ¶
type Context ¶
type Context struct { Writer *RESPHandle.WriterHandle // Args [][]byte Args []interface{} Cmd string Handlers HandlersChain // Middleware and final handler functions Index int8 Op OpFlag Reply interface{} }
func (*Context) Abort ¶
func (c *Context) Abort()
Abort prevents pending Handlers from being called. Note that this will not stop the current handler. Let's say you have an authorization middleware that validates that the current request is authorized. If the authorization fails (ex: the password does not match), call Abort to ensure the remaining Handlers for this request are not called.
type HandlerFunc ¶
func IgnoreCMDMiddleware ¶
func IgnoreCMDMiddleware(enable bool, cmdList []string) HandlerFunc
Start the middleware according to the configuration
func Namespace ¶
func Namespace(prefix []byte) HandlerFunc
func PubSubMiddleware ¶
func PubSubMiddleware(router IRoutes, pubSub *p2p.PubSub) HandlerFunc
PubSubMiddleware Synchronize notification to peer node middleware
type HandlersChain ¶
type HandlersChain []HandlerFunc
HandlersChain defines a HandlerFunc array.
func (HandlersChain) Last ¶
func (c HandlersChain) Last() HandlerFunc
Last returns the last handler in the chain. ie. the last handler is the main one.
type IRoutes ¶
type IRoutes interface { Use(...HandlerFunc) IRoutes AddCommand(string, ...HandlerFunc) IRoutes InitCMD() Handle(w *RESPHandle.WriterHandle, args []interface{}) error Sync(args []interface{}) error Close() error }
type OpFlag ¶
type OpFlag uint32
func (OpFlag) IsMasterOnly ¶
func (OpFlag) IsNotAllowed ¶
func (OpFlag) IsReadOnly ¶
type OpInfo ¶
type OpInfo struct { Name string Flag OpFlag ArgsVerify VerifyFunc }
type VerifyFunc ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.