Documentation ¶
Index ¶
- Constants
- Variables
- func FlagsParseToStruct(prefix string, obj interface{})
- func FlagsSetToStruct(obj interface{})
- func GetAddressesFromRedisConfigSlice(rcfg []RedisConfig) []string
- func GetLogLevel() zapcore.Level
- func InitConfig(path string) error
- func LoadFlags() error
- func LogModuleName(prefix string) string
- func SetLogLevel(l zapcore.Level)
- type AofCmdFlags
- type ChannelConfig
- type ClusterConfig
- type Config
- type DiffCmdFlags
- type EtcdConfig
- type FilterConfig
- type FilterKeyConfig
- type FlagParser
- type Flags
- type FlushPolicy
- type InputConfig
- type InputMode
- type LogConfig
- type LogHandlerConfig
- type LogHandlerFileConfig
- type OutputConfig
- type OutputStats
- type RdbCmdFlags
- type RedisClusterOptions
- type RedisClusterShard
- type RedisConfig
- func (rc *RedisConfig) Address() string
- func (rc *RedisConfig) Clone() *RedisConfig
- func (rc *RedisConfig) FindNode(addr string) *RedisNode
- func (rc *RedisConfig) GetAllSlots() *RedisSlots
- func (rc *RedisConfig) GetClusterOptions() *RedisClusterOptions
- func (rc *RedisConfig) GetClusterShard(addr string) *RedisClusterShard
- func (rc *RedisConfig) GetClusterShards() []*RedisClusterShard
- func (rc *RedisConfig) GetSlots(address string) *RedisSlots
- func (rc *RedisConfig) Index(i int) RedisConfig
- func (rc *RedisConfig) IsCluster() bool
- func (rc *RedisConfig) IsMigrating() bool
- func (rc *RedisConfig) IsStanalone() bool
- func (rc *RedisConfig) SelNodeByAddress(addr string) *RedisConfig
- func (rc *RedisConfig) SelNodes(selAllShards bool, sel SelNodeStrategy) []RedisConfig
- func (rc *RedisConfig) SetClusterShards(sds []*RedisClusterShard)
- func (rc *RedisConfig) SetMigrating(m bool)
- func (rc *RedisConfig) SetSlots(slots map[string]*RedisSlots, sortedSlots *RedisSlots)
- type RedisNode
- type RedisRole
- type RedisSlotRange
- type RedisSlots
- type RedisType
- type SelNodeStrategy
- type ServerConfig
- type SliceInt
- type SliceString
- type StorerConfig
Constants ¶
View Source
const ( AppName = "redisGunYu" RedisRoleMasterStr = "master" RedisRoleSlaveStr = "slave" RedisRoleAllStr = "all" TypeDecode = "decode" TypeRestore = "restore" TypeDump = "dump" TypeSync = "sync" TypeRump = "rump" CheckpointKey = "redis-gunyu-checkpoint" CheckpointKeyHashKey = "redis-gunyu-checkpoint-hash" )
Variables ¶
View Source
var ( StartTime string Version = "1" RDBPipeSize = 1024 )
View Source
var (
ErrInvalidConfig = errors.New("invalid configuration")
)
Functions ¶
func FlagsParseToStruct ¶ added in v0.1.3
func FlagsParseToStruct(prefix string, obj interface{})
func FlagsSetToStruct ¶ added in v0.1.3
func FlagsSetToStruct(obj interface{})
func GetAddressesFromRedisConfigSlice ¶
func GetAddressesFromRedisConfigSlice(rcfg []RedisConfig) []string
func GetLogLevel ¶
func InitConfig ¶
func LogModuleName ¶
func SetLogLevel ¶
Types ¶
type ChannelConfig ¶
type ChannelConfig struct { Storer *StorerConfig VerifyCrc bool StaleCheckpointDuration time.Duration `yaml:"staleCheckpointDuration"` }
func (*ChannelConfig) Clone ¶
func (cc *ChannelConfig) Clone() *ChannelConfig
type ClusterConfig ¶
type Config ¶
type Config struct { Input *InputConfig Output *OutputConfig Channel *ChannelConfig Filter FilterConfig Cluster *ClusterConfig Log *LogConfig `yaml:"log"` Server ServerConfig `yaml:"server"` }
type EtcdConfig ¶
type EtcdConfig struct { // Endpoints is a list of URLs. Endpoints SliceString `yaml:"endpoints"` // AutoSyncInterval is the interval to update endpoints with its latest members. // 0 disables auto-sync. By default auto-sync is disabled. AutoSyncInterval time.Duration `json:"auto-sync-interval"` // DialTimeout is the timeout for failing to establish a connection. DialTimeout time.Duration `json:"dial-timeout"` // DialKeepAliveTime is the time after which client pings the server to see if // transport is alive. DialKeepAliveTime time.Duration `json:"dial-keep-alive-time"` // DialKeepAliveTimeout is the time that the client waits for a response for the // keep-alive probe. If the response is not received in this time, the connection is closed. DialKeepAliveTimeout time.Duration `json:"dial-keep-alive-timeout"` // Username is a user name for authentication. Username string `json:"username"` // Password is a password for authentication. Password string `json:"password"` // RejectOldCluster when set will refuse to create a client against an outdated cluster. RejectOldCluster bool `json:"reject-old-cluster"` Ttl int }
type FilterConfig ¶
type FilterConfig struct { DbBlacklist SliceInt `yaml:"dbBlacklist"` CmdBlacklist SliceString `yaml:"commandBlacklist"` KeyFilter *FilterKeyConfig `yaml:"keyFilter"` }
type FilterKeyConfig ¶
type FilterKeyConfig struct { PrefixKeyWhitelist SliceString `yaml:"prefixKeyWhitelist"` PrefixKeyBlacklist SliceString `yaml:"prefixKeyBlacklist"` }
type FlagParser ¶ added in v0.1.3
type FlagParser interface { FlagParse(prefix string) FlagSet() }
type Flags ¶
type Flags struct { ConfigPath string Cmd string RdbCmd RdbCmdFlags DiffCmd DiffCmdFlags AofCmd AofCmdFlags }
type FlushPolicy ¶
type InputConfig ¶
type InputConfig struct { Redis *RedisConfig RdbParallel int `yaml:"rdbParallel"` Mode InputMode `yaml:"mode"` SyncFrom SelNodeStrategy `yaml:"syncFrom"` SyncDelayTestKey string `yaml:"syncDelayTestKey"` // contains filtered or unexported fields }
func (*InputConfig) RdbLimiter ¶
func (ic *InputConfig) RdbLimiter() chan struct{}
type LogConfig ¶
type LogConfig struct { LevelStr string `yaml:"level"` StacktraceLevelStr string `yaml:"StacktraceLevel"` Handler LogHandlerConfig `yaml:"handler"` Caller *bool `yaml:"withCaller" default:"true"` Func *bool `yaml:"withFunc"` ModuleName *bool `yaml:"withModuleName" default:"true"` // contains filtered or unexported fields }
type LogHandlerConfig ¶
type LogHandlerConfig struct { File *LogHandlerFileConfig StdOut bool `yaml:"stdout"` }
type LogHandlerFileConfig ¶
type OutputConfig ¶
type OutputConfig struct { Redis *RedisConfig ResumeFromBreakPoint *bool `yaml:"resumeFromBreakPoint" default:"true"` ReplaceHashTag bool `yaml:"replaceHashTag"` KeyExists string `yaml:"keyExists"` // replace|ignore|error KeyExistsLog bool `yaml:"keyExistsLog"` FunctionExists string `yaml:"functionExists"` MaxProtoBulkLen int `yaml:"maxProtoBulkLen"` // proto-max-bulk-len, default value of redis is 512MiB TargetDbCfg *int `yaml:"targetDb" default:"-1"` TargetDb int `yaml:"-"` TargetDbMap map[int]int `yaml:"targetDbMap"` BatchCmdCount uint `yaml:"batchCmdCount"` BatchTicker time.Duration `yaml:"batchTicker"` BatchBufferSize uint64 `yaml:"batchBufferSize"` KeepaliveTicker time.Duration `yaml:"keepaliveTicker"` ReplayRdbParallel int `yaml:"replayRdbParallel"` ReplayRdbEnableRestore *bool `yaml:"replayRdbEnableRestore" default:"true"` UpdateCheckpointTicker time.Duration `yaml:"updateCheckpointTicker"` ReplayTransaction *bool `yaml:"replayTransaction" default:"true"` Stats OutputStats `yaml:"stats"` }
type OutputStats ¶ added in v0.1.5
type RdbCmdFlags ¶
type RedisClusterOptions ¶
type RedisClusterOptions struct { HandleMoveErr bool `yaml:"handleMoveErr" default:"true"` HandleAskErr bool `yaml:"handleAskErr" default:"true"` }
func (*RedisClusterOptions) Clone ¶
func (rco *RedisClusterOptions) Clone() *RedisClusterOptions
type RedisClusterShard ¶
type RedisClusterShard struct { Slots RedisSlots // sorted Master RedisNode Slaves []RedisNode // contains filtered or unexported fields }
func (*RedisClusterShard) AllAddresses ¶
func (rcs *RedisClusterShard) AllAddresses() []string
func (*RedisClusterShard) Clone ¶
func (rcs *RedisClusterShard) Clone() *RedisClusterShard
func (*RedisClusterShard) CompareTypology ¶
func (rcs *RedisClusterShard) CompareTypology(shard *RedisClusterShard) bool
func (*RedisClusterShard) Get ¶
func (rcs *RedisClusterShard) Get(sel SelNodeStrategy) *RedisNode
type RedisConfig ¶
type RedisConfig struct { Addresses SliceString UserName string `yaml:"userName"` Password string `yaml:"password"` TlsEnable bool `yaml:"tlsEnable"` Type RedisType // for new redis client Otype RedisType // original type Version string ClusterOptions *RedisClusterOptions `yaml:"clusterOptions"` KeepAlive int `yaml:"keepAlive"` // Maximum keep alive connecion in each node AliveTime time.Duration `yaml:"aliveTime"` // Keep alive timeout // contains filtered or unexported fields }
func (*RedisConfig) Address ¶
func (rc *RedisConfig) Address() string
func (*RedisConfig) Clone ¶
func (rc *RedisConfig) Clone() *RedisConfig
func (*RedisConfig) FindNode ¶
func (rc *RedisConfig) FindNode(addr string) *RedisNode
func (*RedisConfig) GetAllSlots ¶
func (rc *RedisConfig) GetAllSlots() *RedisSlots
func (*RedisConfig) GetClusterOptions ¶
func (rc *RedisConfig) GetClusterOptions() *RedisClusterOptions
func (*RedisConfig) GetClusterShard ¶
func (rc *RedisConfig) GetClusterShard(addr string) *RedisClusterShard
func (*RedisConfig) GetClusterShards ¶
func (rc *RedisConfig) GetClusterShards() []*RedisClusterShard
func (*RedisConfig) GetSlots ¶
func (rc *RedisConfig) GetSlots(address string) *RedisSlots
func (*RedisConfig) Index ¶
func (rc *RedisConfig) Index(i int) RedisConfig
func (*RedisConfig) IsCluster ¶
func (rc *RedisConfig) IsCluster() bool
func (*RedisConfig) IsMigrating ¶
func (rc *RedisConfig) IsMigrating() bool
func (*RedisConfig) IsStanalone ¶
func (rc *RedisConfig) IsStanalone() bool
func (*RedisConfig) SelNodeByAddress ¶
func (rc *RedisConfig) SelNodeByAddress(addr string) *RedisConfig
func (*RedisConfig) SelNodes ¶
func (rc *RedisConfig) SelNodes(selAllShards bool, sel SelNodeStrategy) []RedisConfig
func (*RedisConfig) SetClusterShards ¶
func (rc *RedisConfig) SetClusterShards(sds []*RedisClusterShard)
func (*RedisConfig) SetMigrating ¶
func (rc *RedisConfig) SetMigrating(m bool)
func (*RedisConfig) SetSlots ¶
func (rc *RedisConfig) SetSlots(slots map[string]*RedisSlots, sortedSlots *RedisSlots)
type RedisNode ¶
type RedisNode struct { Id string Ip string Port int TlsPort int Endpoint string Address string HostName string Role RedisRole ReplOffset int64 Health string }
func (*RedisNode) AddressEqual ¶
type RedisSlotRange ¶
type RedisSlots ¶
type RedisSlots struct {
Ranges []RedisSlotRange
}
func (*RedisSlots) Clone ¶
func (rs *RedisSlots) Clone() *RedisSlots
func (*RedisSlots) Equal ¶
func (rs *RedisSlots) Equal(b *RedisSlots) bool
func (*RedisSlots) Len ¶
func (rs *RedisSlots) Len() int
func (*RedisSlots) Less ¶
func (rs *RedisSlots) Less(i, j int) bool
func (*RedisSlots) Swap ¶
func (rs *RedisSlots) Swap(i, j int)
type SelNodeStrategy ¶
type SelNodeStrategy int
const ( SelNodeStrategySlave SelNodeStrategy = 1 // 0001 SelNodeStrategyPreferSlave SelNodeStrategy = 3 // 0011 SelNodeStrategyMaster SelNodeStrategy = 4 // 0100 )
func (*SelNodeStrategy) Set ¶ added in v0.1.3
func (rt *SelNodeStrategy) Set(val string) error
func (SelNodeStrategy) String ¶
func (rt SelNodeStrategy) String() string
func (*SelNodeStrategy) UnmarshalYAML ¶
func (rt *SelNodeStrategy) UnmarshalYAML(value *yaml.Node) error
type ServerConfig ¶
type ServerConfig struct { Listen string ListenPort int `yaml:"-"` ListenPeer string `yaml:"listenPeer"` // Used to communicate with peers. if it's empty, use Listen field MetricRoutePath string `yaml:"metricRoutePath"` CheckRedisTypologyTicker time.Duration `yaml:"checkRedisTypologyTicker"` // seconds GracefullStopTimeout time.Duration `yaml:"gracefullStopTimeout"` }
type SliceInt ¶ added in v0.1.3
type SliceInt []int
func (*SliceInt) UnmarshalYAML ¶ added in v0.1.3
type SliceString ¶ added in v0.1.3
type SliceString []string
func (*SliceString) UnmarshalYAML ¶ added in v0.1.3
func (ss *SliceString) UnmarshalYAML(value *yaml.Node) error
type StorerConfig ¶
type StorerConfig struct { DirPath string `yaml:"dirPath"` MaxSize int64 `yaml:"maxSize"` // -1 is unlimited, default is 50GiB LogSize int64 `yaml:"logSize"` // default is 100MiB Flush FlushPolicy `yaml:"flushPolicy"` }
Click to show internal directories.
Click to hide internal directories.