diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-06-21 19:06:17 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-06-21 19:06:17 -0700 |
commit | 42f28ab8e374137fe3f5d25424489d879d4724f8 (patch) | |
tree | 20353f2446b506d32e6d353b72a57bf48f070389 /vendor/gopkg.in/olivere/elastic.v5/client.go | |
parent | 6b39c308d882a0aeac533f8ab1d90b48a2ae4b5a (diff) | |
download | chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.gz chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.bz2 chat-42f28ab8e374137fe3f5d25424489d879d4724f8.zip |
Updating server dependancies (#6712)
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/client.go')
-rw-r--r-- | vendor/gopkg.in/olivere/elastic.v5/client.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/client.go b/vendor/gopkg.in/olivere/elastic.v5/client.go index df0d9a7dd..c8cb17c87 100644 --- a/vendor/gopkg.in/olivere/elastic.v5/client.go +++ b/vendor/gopkg.in/olivere/elastic.v5/client.go @@ -22,7 +22,7 @@ import ( const ( // Version is the current version of Elastic. - Version = "5.0.38" + Version = "5.0.41" // DefaultURL is the default endpoint of Elasticsearch on the local machine. // It is used e.g. when initializing a new Client without a specific URL. @@ -817,8 +817,12 @@ func (c *Client) sniff(timeout time.Duration) error { // Start sniffing on all found URLs ch := make(chan []*conn, len(urls)) + + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + for _, url := range urls { - go func(url string) { ch <- c.sniffNode(url) }(url) + go func(url string) { ch <- c.sniffNode(ctx, url) }(url) } // Wait for the results to come back, or the process times out. @@ -829,7 +833,7 @@ func (c *Client) sniff(timeout time.Duration) error { c.updateConns(conns) return nil } - case <-time.After(timeout): + case <-ctx.Done(): // We get here if no cluster responds in time return errors.Wrap(ErrNoClient, "sniff timeout") } @@ -840,7 +844,7 @@ func (c *Client) sniff(timeout time.Duration) error { // in sniff. If successful, it returns the list of node URLs extracted // from the result of calling Nodes Info API. Otherwise, an empty array // is returned. -func (c *Client) sniffNode(url string) []*conn { +func (c *Client) sniffNode(ctx context.Context, url string) []*conn { var nodes []*conn // Call the Nodes Info API at /_nodes/http @@ -855,7 +859,7 @@ func (c *Client) sniffNode(url string) []*conn { } c.mu.RUnlock() - res, err := c.c.Do((*http.Request)(req)) + res, err := c.c.Do((*http.Request)(req).WithContext(ctx)) if err != nil { return nodes } @@ -995,7 +999,7 @@ func (c *Client) healthcheck(timeout time.Duration, force bool) { if basicAuth { req.SetBasicAuth(basicAuthUsername, basicAuthPassword) } - res, err := c.c.Do((*http.Request)(req)) + res, err := c.c.Do((*http.Request)(req).WithContext(ctx)) if res != nil { status = res.StatusCode if res.Body != nil { @@ -1103,7 +1107,7 @@ func (c *Client) next() (*conn, error) { } // We tried hard, but there is no node available - return nil, errors.Wrap(ErrNoClient, "no avaiable connection") + return nil, errors.Wrap(ErrNoClient, "no available connection") } // mustActiveConn returns nil if there is an active connection, @@ -1629,12 +1633,16 @@ func (c *Client) TasksList() *TasksListService { // -- Snapshot and Restore -- -// TODO Snapshot Create // TODO Snapshot Delete // TODO Snapshot Get // TODO Snapshot Restore // TODO Snapshot Status +// SnapshotCreate creates a snapshot. +func (c *Client) SnapshotCreate(repository string, snapshot string) *SnapshotCreateService { + return NewSnapshotCreateService(c).Repository(repository).Snapshot(snapshot) +} + // SnapshotCreateRepository creates or updates a snapshot repository. func (c *Client) SnapshotCreateRepository(repository string) *SnapshotCreateRepositoryService { return NewSnapshotCreateRepositoryService(c).Repository(repository) |