redistools

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultPoolSize = 10

	// DefaultDialTimeout bounds the initial TCP connect (and the AUTH/SELECT
	// handshake that follows it) when opening or re-opening a connection.
	DefaultDialTimeout = 5 * time.Second
	// DefaultCommandTimeout is the read/write deadline applied to every
	// command sent over a pooled connection, so a server that stops
	// responding cannot hang a caller (or a pool slot) forever.
	DefaultCommandTimeout = 5 * time.Second
	// DefaultMaxBulkLen caps how large a single RESP bulk string ($n) the
	// client will allocate for. A server (or a man-in-the-middle without
	// TLS) advertising a bigger length gets an error instead of an
	// unbounded allocation.
	DefaultMaxBulkLen = 16 * 1024 * 1024
	// DefaultMaxArrayLen caps how many elements a single RESP array (*n)
	// the client will allocate for, for the same reason.
	DefaultMaxArrayLen = 1_000_000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address  string `json:"address"`
	Password string `json:"password"`
	PoolSize int    `json:"pool_size"`
	DB       int    `json:"db"`
	UseTLS   bool   `json:"use_tls"`

	// DialTimeout bounds a (re)connect, including the AUTH/SELECT handshake.
	DialTimeout time.Duration `json:"dial_timeout"`
	// CommandTimeout is the read/write deadline applied to every command.
	CommandTimeout time.Duration `json:"command_timeout"`
	// MaxBulkLen caps the size the client will allocate for a RESP bulk
	// string reply. 0 uses DefaultMaxBulkLen; a negative value disables
	// the cap (not recommended).
	MaxBulkLen int64 `json:"max_bulk_len"`
	// MaxArrayLen caps the number of elements the client will allocate for
	// a RESP array reply. 0 uses DefaultMaxArrayLen; a negative value
	// disables the cap (not recommended).
	MaxArrayLen int64 `json:"max_array_len"`
}

func DefaultConfig

func DefaultConfig() Config

type DeleteResult

type DeleteResult struct {
	Deleted int64    `json:"deleted"`
	Keys    []string `json:"keys"`
}

type ExistsResult

type ExistsResult struct {
	Keys   []string `json:"keys"`
	Exists int64    `json:"exists"`
}

type GetResult

type GetResult struct {
	Key   string  `json:"key"`
	Value *string `json:"value,omitempty"`
	Found bool    `json:"found"`
}

type KeysResult

type KeysResult struct {
	Pattern string   `json:"pattern"`
	Keys    []string `json:"keys"`
	Count   int      `json:"count"`
}

type RedisClient

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

func NewRedisClient

func NewRedisClient(logger *slog.Logger, cfg Config) (*RedisClient, error)

func (*RedisClient) CallTool

func (c *RedisClient) CallTool(ctx context.Context, name string, args json.RawMessage) (interface{}, error)

func (*RedisClient) Close

func (c *RedisClient) Close()

func (*RedisClient) GetTools

func (c *RedisClient) GetTools() []ToolDefinition

type SetResult

type SetResult struct {
	Key    string `json:"key"`
	Status string `json:"status"`
}

type ToolDefinition

type ToolDefinition struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	InputSchema json.RawMessage `json:"inputSchema"`
}

type ToolHandler

type ToolHandler func(ctx context.Context, args json.RawMessage) (interface{}, error)

Jump to

Keyboard shortcuts

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