dispatch

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJSONArgument

func ExtractJSONArgument(args []string, jsonIndex int) (string, bool)

ExtractJSONArgument extracts a json argument.

Types

type ConnEnv

type ConnEnv struct {
	SubscribeConfigYAML   func() (int64, error)
	UnsubscribeConfigYAML func() (int64, error)
	IsSubscribed          func() bool
}

type Env

type Env struct {
	Runtime *home.Runtime
	Conn    *ConnEnv

	// ClientIP is the remote TCP client's IP address as resolved by the RESP server.
	// It can be empty when the address cannot be resolved.
	ClientIP string
}

type Handler

type Handler func(ctx context.Context, env Env, args []string) Reply

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new registry.

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, env Env, args []string) Reply

Execute handles an execute.

func (*Registry) RegisterDirect

func (r *Registry) RegisterDirect(command string, key string, handler Handler) error

RegisterDirect handles a register direct.

func (*Registry) RegisterDynamic

func (r *Registry) RegisterDynamic(command string, typeValue string, handler Handler) error

RegisterDynamic handles a register dynamic.

func (*Registry) Routes

func (r *Registry) Routes() []Route

Routes handles a routes.

func (*Registry) SetDirectDefault

func (r *Registry) SetDirectDefault(command string, handler Handler) error

SetDirectDefault sets a direct default.

func (*Registry) SetDynamicDefault

func (r *Registry) SetDynamicDefault(command string, handler Handler) error

SetDynamicDefault sets a dynamic default.

type Reply

type Reply struct {
	Kind ReplyKind

	SimpleString string
	BulkString   []byte
	RedisError   string
	Integer      int64
	Array        []Reply
}

func Array

func Array(elements ...Reply) Reply

Array builds a dispatch reply.

func BulkString

func BulkString(payload []byte) Reply

BulkString builds a dispatch reply.

func Err

func Err(message string) Reply

Err builds a dispatch reply.

func Integer

func Integer(value int64) Reply

Integer builds a dispatch reply.

func RedisError

func RedisError(message string) Reply

RedisError builds a dispatch reply.

func SimpleString

func SimpleString(value string) Reply

SimpleString builds a dispatch reply.

type ReplyKind

type ReplyKind int
const (
	ReplyKindSimpleString ReplyKind = iota
	ReplyKindBulkString
	ReplyKindRedisError
	ReplyKindInteger
	ReplyKindArray
)

type Route

type Route struct {
	Kind      RouteKind
	Command   string
	Key       string
	Type      string
	IsDefault bool
}

type RouteKind

type RouteKind int
const (
	RouteKindDirect RouteKind = iota
	RouteKindDynamic
)

Jump to

Keyboard shortcuts

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