handler

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package handler defines the mechanics to manipulate request across several redis instances.

It works by mimicking redis, listening for packets over TCP that complies with REdis Serialization Protocol (RESP), and then parsing the Redis command which might be modified before being routed against a real Redis server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(addr string, handler Handler) *redcon.Server

NewServer returns a new instance of *redcon.Server, using Handler as its connection processor. The difference with Run() function is that the server instance is not listening to any address yet, making it useful when you want configure the server before running it.

func Run

func Run(addr string, handler Handler) error

Run creates a new Listener with specified address on TCP network. The Listener will then use a Handler to process incoming connection.

func RunInstrumentation

func RunInstrumentation(addr string, handler Handler, errSignal chan error) error

RunInstrumentation creates and run a HTTP server which provides a couple of endpoints: - /health to check server health - /metrics to provide instrumentation metrics

Types

type ClientConfig

type ClientConfig struct {
	Addr         string
	Password     string
	MaxIdleConns int
	IdleTimeout  duration
}

ClientConfig holds the configuration for Redis client

type Handler

type Handler interface {
	Handle(conn redcon.Conn, cmd redcon.Command)
	Accept(conn redcon.Conn) bool
	Closed(conn redcon.Conn, err error)

	HealthCheck(w http.ResponseWriter, req *http.Request)
}

Handler provide set of methods to handle incoming connection.

func NewRedisHandler

func NewRedisHandler(config RedisConfig) Handler

NewRedisHandler returns new instance of redisHandler, a connection handler that handler redis-like interface

type RedisConfig

type RedisConfig struct {
	Password    string
	DeleteOnGet bool
	DeleteOnSet bool
	Source      ClientConfig
	Destination ClientConfig
}

RedisConfig holds configuration for initializing redisHandler

Jump to

Keyboard shortcuts

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