lib

package
v0.0.0-...-4e80ce2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeSync  = 0
	ModeSmart = 1
)
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 Host

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

Types

type Config

type Config struct {
	Comment string
	GOGC    int //GCPercent
	Relayer []RelayerConfig
}

func ReadConfig

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

type InterRecord

type InterRecord struct {
	Types     int                    `json:"type,omitempty"`
	Timestamp float64                `json:"_ts,number"`
	Data      map[string]interface{} `json:"data,omitempty"`
	Raw       []byte                 `json:"raw,omitempty"` // 0 json, 1 Raw bytes
}

func NewInterRecord

func NewInterRecord() *InterRecord

NewInterRecord create a InterRecord struct to the connection

func (*InterRecord) Add

func (r *InterRecord) Add(key, value string)

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, value string)

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 MainConfig

GlobalConfig is the configuration for the main programm

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 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
	Listen             string // Local url | also is streamName for Kinesis Firehose
	URL                string // Redis/SQS url endpoint
	MaxConnections     int    // Pool management
	MaxIdleConnections int    // Pool management
	Compress           bool
	Uncompress         bool
	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
	StreamName string  // Kinesis/Firehose stream name
	GroupID    string  // Group ID for AWS SQS fifo
	Region     string  // AWS region
	Profile    string  // AWS Profile name
	Spin       float64 // % of ignored messages
}

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
	ResponseChannel chan *redis.Resp // Channel 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