Documentation
¶
Overview ¶
Package goredis extend github.com/go-redis/redis to add support for the trpc-go ecosystem.
Index ¶
Constants ¶
View Source
const ( ContextKeyName ContextKeyType = "trpc-go-redis" // context key RetRedisNil = 30001 // redis field doesn't exist RetCASMismatch = 30002 // cas confict RetRedisCmdFail = 30003 // redis cmd fail RetParamInvalid = 30004 // invalid parameter RetTypeMismatch = 30005 // type mismatch RetLockOccupied = 30006 // lock is already occupied RetLockExpired = 30007 // lock has expired RetLockRobbed = 30008 // lock has been seized RetKeyNotFound = 30009 // key doesn't exist or expired, it will alert but RetRedisNil will not RetAddCronFail = 30010 // fail to add the cron job RetInitFail = 30011 // fail to initiate RetLockExtend = 30012 // fail to renew the lock InfinityMin = "-inf" // negative infinity InfinityMax = "+inf" // positive infinity CronSelectorName = "cron" // cron )
Variables ¶
View Source
var ( ErrM007RedisNil = errs.New(RetRedisNil, redis.Nil.Error()) // redis.Nil error. ErrParamInvalid = errs.New(RetParamInvalid, "param invalid") // invalid parameter. ErrTypeMismatch = errs.New(RetTypeMismatch, "type mismatch") // type missmatch. ErrLockOccupied = errs.New(RetLockOccupied, "lock occupied") // lock is occupied. MaxRspLen int64 = 100 // max response length. )
View Source
var New = func(name string, opts ...client.Option) ( redis.UniversalClient, error) { filters, err := joinfilters.New(name, opts...) if err != nil { return nil, errs.Wrapf(err, RetInitFail, "joinfilters.NewFilters fail %v", err) } trpcOptions, err := filters.LoadClientOptions() if err != nil { return nil, errs.Wrapf(err, RetInitFail, "filters.GetClientOptions fail %v", err) } option, err := options.New(trpcOptions) if err != nil { return nil, err } redisClient := redis.NewUniversalClient(option.RedisOption) redisHook, err := newHook(filters, option) if err != nil { return nil, err } redisClient.AddHook(redisHook) if _, err = redisClient.Ping(trpc.BackgroundContext()).Result(); err != nil { return nil, errs.Wrapf(err, RetInitFail, "New Ping fail %v", err) } return redisClient, nil }
New creates a redis client.
Functions ¶
Types ¶
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
joinfilters
Package joinfilters is a trpc filter adapter.
|
Package joinfilters is a trpc filter adapter. |
options
Package options is redis configuration parameters.
|
Package options is redis configuration parameters. |
proto
Package proto goredis is the library dependent proto contract file, and the pb.go file is generated according to proto.
|
Package proto goredis is the library dependent proto contract file, and the pb.go file is generated according to proto. |
script
Package script optimizes lua script execution.
|
Package script optimizes lua script execution. |
Package redcas realizes CAS extension function.
|
Package redcas realizes CAS extension function. |
Package redcron is distributed timers.
|
Package redcron is distributed timers. |
Package redlock distributed lock。
|
Package redlock distributed lock。 |
mockredlock
Package mockredlock is a generated GoMock package.
|
Package mockredlock is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.