()
| 110 | } |
| 111 | |
| 112 | func (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. |
no outgoing calls
no test coverage detected