MCPcopy Create free account
hub / github.com/apache/casbin-etcd-watcher / createClient

Method createClient

watcher.go:112–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110}
111
112func (w *Watcher) createClient() error {
113 cfg := client.Config{
114 Endpoints: w.endpoints,
115 // set timeout per request to fail fast when the target endpoints is unavailable
116 DialKeepAliveTimeout: time.Second * 10,
117 DialTimeout: time.Second * 30,
118 Password: w.password,
119 }
120
121 if w.conf != nil {
122 cfg = client.Config{
123 Endpoints: w.conf.Hosts,
124 // set timeout per request to fail fast when the target endpoints is unavailable
125 DialTimeout: time.Second * w.conf.DialTimeout,
126 DialKeepAliveTimeout: time.Second * w.conf.DialKeepAliveTimeout,
127 Username: w.conf.User,
128 Password: w.conf.Pass,
129 }
130 }
131
132 c, err := client.New(cfg)
133 if err != nil {
134 return err
135 }
136 w.client = c
137 return nil
138}
139
140// SetUpdateCallback sets the callback function that the watcher will call
141// when the policy in DB has been changed by other instances.

Callers 2

NewWatcherFunction · 0.95
NewWatcherWithConfigFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected