lib

package
v8.8.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 19 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ModeSync  = 0
	ModeSmart = 1
)
View Source
const (
	GzCompressionLevel = 1
)
View Source
const (
	MinCompressSize = 256
)
View Source
const (
	UnknownDB = -1
)

Variables

View Source
var NoDeadline = time.Time{}

Functions

func Debugf

func Debugf(format string, a ...interface{})

Debugf function, if the debug flag is set, then display. Do nothing otherwise If Docker is in damon mode, also send the debug info on the socket Convenience debug function, courtesy of http://github.com/dotcloud/docker

func GetGzipReader

func GetGzipReader(r io.Reader) (*gzip.Reader, error)

func GetGzipWriter

func GetGzipWriter(w io.Writer) *gzip.Writer

func GetGzipWriterLevel

func GetGzipWriterLevel(w io.Writer, level int) *gzip.Writer

func Host

func Host(s string) (host string, err error)

func PutGzipReader

func PutGzipReader(zr *gzip.Reader)

func PutGzipWriter

func PutGzipWriter(zw *gzip.Writer)

Types

type Config

type Config struct {
	Comment        string
	GOGC           int //GCPercent
	Relayer        []RelayerConfig
	BufferPoolSize int // If > 0 it will use bybufferpools in redis.Resp if size > BufferPoolSize
}

func ReadConfig

func ReadConfig(filename string) (config *Config, err error)

type InterRecord

type InterRecord struct {
	Types int                    `json:"type,omitempty"`
	Ts    int64                  `json:"ts,number"`
	Data  map[string]interface{} `json:"data,omitempty"`
	Raw   []byte                 `json:"raw,omitempty"` // 0 json, 1 Raw bytes
	// contains filtered or unexported fields
}

func NewInterRecord

func NewInterRecord() *InterRecord

NewInterRecord create a InterRecord struct to the connection

func (*InterRecord) Add

func (r *InterRecord) Add(key string, value interface{})

func (*InterRecord) Bytes

func (r *InterRecord) Bytes() []byte

Bytes return the record in bytes

func (*InterRecord) BytesUniqID

func (r *InterRecord) BytesUniqID() ([]byte, string)

BytesUniqID return the record content in bytes and the uniq ID

func (*InterRecord) Len

func (r *InterRecord) Len() int

Len return the bytes used in Raw or the len of the map data

func (*InterRecord) Mhset

func (r *InterRecord) Mhset(key, k string, v interface{})

func (*InterRecord) Sadd

func (r *InterRecord) Sadd(key string, value interface{})

func (*InterRecord) String

func (r *InterRecord) String() string

String return the record in string format

func (*InterRecord) StringUniqID

func (r *InterRecord) StringUniqID() (string, string)

StringUniqID build a uniq ID based on the content in string format

type Listener

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

func NewListener

func NewListener(c RelayerConfig) (l *Listener, e error)

MewListener check sockets and files and return a listener alread listening

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

func (*Listener) Close

func (l *Listener) Close() error

type MainConfig

type MainConfig struct {
	ConfigFileName string
	Debug          bool
	ShowVersion    bool
}
var (
	// GlobalConfig is the configuration for the main programm
	GlobalConfig MainConfig
)

type NetBuffedReadWriter

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

NetBuffedReadWriter is a reader-writer buffered net connection

func NewNetReadWriter

func NewNetReadWriter(conn net.Conn, readTimeout, writeTimeout time.Duration) *NetBuffedReadWriter

func (*NetBuffedReadWriter) Flush

func (nb *NetBuffedReadWriter) Flush() (e error)

func (*NetBuffedReadWriter) Read

func (nb *NetBuffedReadWriter) Read(b []byte) (n int, e error)

Read complies with io.Reader interface

func (*NetBuffedReadWriter) Write

func (nb *NetBuffedReadWriter) Write(b []byte) (n int, e error)

Write complies with io.Writer interface

type NetReadWriter

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

NetBuffedReadWriter is a reader-writer buffered net connection

func NewSingleReadWriter

func NewSingleReadWriter(conn net.Conn, readTimeout, writeTimeout time.Duration) *NetReadWriter

NewSingleReadWriter returns a single io.reaWriter with timeout handling

func (*NetReadWriter) Flush

func (rw *NetReadWriter) Flush() (e error)

Flush is a no-op for this non buffered

func (*NetReadWriter) Read

func (rw *NetReadWriter) Read(b []byte) (n int, e error)

Read complies with io.Reader interface

func (*NetReadWriter) Write

func (rw *NetReadWriter) Write(b []byte) (n int, e error)

Write complies with io.Writer interface

type Relayer

type Relayer interface {
	Start() error
	Reload(*RelayerConfig) error
	Exit()
}

type RelayerClient

type RelayerClient interface {
	IsValid() bool
	Exit()
	Send(r interface{}) error
	Reload(*RelayerConfig)
}

type RelayerConfig

type RelayerConfig struct {
	Protocol           string // redis | redis2 | redis-cluster | redis-plus | firehose
	Mode               string // smart | sync
	Critical           bool
	Listen             string // Local url | also is streamName for Kinesis Firehose
	URL                string // Redis/SQS url endpoint
	MaxConnections     int    // Pool management
	MaxIdleConnections int    // Pool management
	MinIdleConnections int    // Pool management
	MaxConnectedSecs   int    // Pool management
	Compress           bool
	Uncompress         bool
	Gzip               int  // If > 0 is enabled and is the compression level
	Gunzip             bool // Read with uncompress

	UseBufferPool bool // used by the http proxy, enable or diable buffer pool

	//	Parallel           bool // For redis-cluster, send parallel requests
	Pipeline int // If > 0 it does pipelining (buffering)
	Timeout  int // Timeout in seconds to wait for responses from the server

	MaxRecords int    // To send in batch to Kinesis
	Buffer     int    // Size for the channel (queue for Kinesis/Firehose)
	StreamName string // Kinesis/Firehose stream name
	GroupID    string // Group ID for AWS SQS fifo
	Region     string // AWS region
	Profile    string // AWS Profile name
	Concat     bool   // Kinesis/Firehose contact messages, valid just for S3 backend
	Path       string // Path were to store the logs
	S3Bucket   string // S3 Bucket name

	Shards          int // Shards for FS plugin
	Writers         int // Writers BY shard (each shard will have the number of workers defined here)
	BreakMultiplier int // Limit to declare as failing. Total writes plus this value

	AsynCommands string
}

func (*RelayerConfig) Host

func (c *RelayerConfig) Host() (host string)

func (*RelayerConfig) ListenHost

func (c *RelayerConfig) ListenHost() (host string)

func (*RelayerConfig) ListenScheme

func (c *RelayerConfig) ListenScheme() (scheme string)

func (*RelayerConfig) Scheme

func (c *RelayerConfig) Scheme() (scheme string)

func (*RelayerConfig) Type

func (c *RelayerConfig) Type() int

Type return the value of Mode coded in a integer

type Request

type Request struct {
	Resp     *redis.Resp
	Items    []*redis.Resp
	Command  string
	Conn     io.Writer // Writer to send the response to the original client
	Database int       // The current database at the time the request was issued
}

Request stores the data for each client request

func NewRequest

func NewRequest(resp *redis.Resp, c *RelayerConfig) *Request

Jump to

Keyboard shortcuts

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