Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientName optional config, and do not auto-set it #23

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ type Config struct {
DBIndex int `toml:"db_index"` // default: 0
MaxIdle int `toml:"max_idle"` // default: 5
MaxActive int `toml:"max_active"` // default: 10

Backend Backend `toml:"backend"` // default: ""
}

type Backend string

const (
BackendMemoryStore Backend = "memory-store"
pkieltyka marked this conversation as resolved.
Show resolved Hide resolved
)
3 changes: 2 additions & 1 deletion httprateredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func NewCounter(cfg *Config) *redisCounter {
if cfg.Port < 1 {
cfg.Port = 6379
}
if cfg.ClientName == "" {
// MemoryStore does not support client setname.
if cfg.Backend != BackendMemoryStore && cfg.ClientName == "" {
cfg.ClientName = filepath.Base(os.Args[0])
}
if cfg.PrefixKey == "" {
Expand Down
Loading