From 967e75786f1f328b38ea2db7d10d38ccb2344642 Mon Sep 17 00:00:00 2001 From: Eugene Genov <60390597+e-genov-ks@users.noreply.github.com> Date: Wed, 9 Nov 2022 20:26:26 +0200 Subject: [PATCH] feat: remove Redis cluster node number check, it's redis client responsibility (#37) --- watcher.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/watcher.go b/watcher.go index b4c3b53..a1c6ef1 100644 --- a/watcher.go +++ b/watcher.go @@ -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) @@ -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)