Skip to content

Commit

Permalink
feat: remove Redis cluster node number check, it's redis client respo…
Browse files Browse the repository at this point in the history
…nsibility (#37)
  • Loading branch information
e-genov-ks authored Nov 9, 2022
1 parent 69ad23b commit 967e757
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ func (m *MSG) UnmarshalBinary(data []byte) error {
// addr is a redis target string in the format "host:port"
// setters allows for inline WatcherOptions
//
// Example:
// w, err := rediswatcher.NewWatcher("127.0.0.1:6379",WatcherOptions{}, nil)
//
// Example:
// w, err := rediswatcher.NewWatcher("127.0.0.1:6379",WatcherOptions{}, nil)
func NewWatcher(addr string, option WatcherOptions) (persist.Watcher, error) {
option.Options.Addr = addr
initConfig(&option)
Expand Down Expand Up @@ -141,14 +140,10 @@ func NewWatcher(addr string, option WatcherOptions) (persist.Watcher, error) {
// NewWatcherWithCluster creates a new Watcher to be used with a Casbin enforcer
// addrs is a redis-cluster target string in the format "host1:port1,host2:port2,host3:port3"
//
// Example:
// w, err := rediswatcher.NewWatcherWithCluster("127.0.0.1:6379,127.0.0.1:6379,127.0.0.1:6379",WatcherOptions{})
//
// Example:
// w, err := rediswatcher.NewWatcherWithCluster("127.0.0.1:6379,127.0.0.1:6379,127.0.0.1:6379",WatcherOptions{})
func NewWatcherWithCluster(addrs string, option WatcherOptions) (persist.Watcher, error) {
addrsStr := strings.Split(addrs, ",")
if len(addrsStr) < 3 {
return nil, errors.New("nodes num must >= 3")
}
option.ClusterOptions.Addrs = addrsStr
initConfig(&option)

Expand Down

0 comments on commit 967e757

Please sign in to comment.