diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-07-20 15:22:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 15:22:49 -0700 |
commit | 58839cefb50e56ae5b157b37e9814ae83ceee70b (patch) | |
tree | 5de966481678096fc9567f74f96673b34a65127c /vendor/gopkg.in/olivere/elastic.v5/client.go | |
parent | e2f4492eadb5d3c58606b1fdd5774b63a07c236a (diff) | |
download | chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.gz chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.bz2 chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.zip |
Upgrading server dependancies (#6984)
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/client.go')
-rw-r--r-- | vendor/gopkg.in/olivere/elastic.v5/client.go | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/client.go b/vendor/gopkg.in/olivere/elastic.v5/client.go index c8cb17c87..13be369bd 100644 --- a/vendor/gopkg.in/olivere/elastic.v5/client.go +++ b/vendor/gopkg.in/olivere/elastic.v5/client.go @@ -9,20 +9,24 @@ import ( "context" "encoding/json" "fmt" + "log" "net/http" "net/http/httputil" "net/url" + "os" "regexp" "strings" "sync" "time" "github.com/pkg/errors" + + "gopkg.in/olivere/elastic.v5/config" ) const ( // Version is the current version of Elastic. - Version = "5.0.41" + Version = "5.0.43" // 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. @@ -288,6 +292,47 @@ func NewClient(options ...ClientOptionFunc) (*Client, error) { return c, nil } +// NewClientFromConfig initializes a client from a configuration. +func NewClientFromConfig(cfg *config.Config) (*Client, error) { + var options []ClientOptionFunc + if cfg != nil { + if cfg.URL != "" { + options = append(options, SetURL(cfg.URL)) + } + if cfg.Errorlog != "" { + f, err := os.OpenFile(cfg.Errorlog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + return nil, errors.Wrap(err, "unable to initialize error log") + } + l := log.New(f, "", 0) + options = append(options, SetErrorLog(l)) + } + if cfg.Tracelog != "" { + f, err := os.OpenFile(cfg.Tracelog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + return nil, errors.Wrap(err, "unable to initialize trace log") + } + l := log.New(f, "", 0) + options = append(options, SetTraceLog(l)) + } + if cfg.Infolog != "" { + f, err := os.OpenFile(cfg.Infolog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + return nil, errors.Wrap(err, "unable to initialize info log") + } + l := log.New(f, "", 0) + options = append(options, SetInfoLog(l)) + } + if cfg.Username != "" || cfg.Password != "" { + options = append(options, SetBasicAuth(cfg.Username, cfg.Password)) + } + if cfg.Sniff != nil { + options = append(options, SetSniff(*cfg.Sniff)) + } + } + return NewClient(options...) +} + // NewSimpleClient creates a new short-lived Client that can be used in // use cases where you need e.g. one client per request. // @@ -1233,6 +1278,9 @@ func (c *Client) PerformRequest(ctx context.Context, method, path string, params defer res.Body.Close() } + // Tracing + c.dumpResponse(res) + // Check for errors if err := checkResponse((*http.Request)(req), res, ignoreErrors...); err != nil { // No retry if request succeeded @@ -1241,9 +1289,6 @@ func (c *Client) PerformRequest(ctx context.Context, method, path string, params return resp, err } - // Tracing - c.dumpResponse(res) - // We successfully made a request with this connection conn.MarkAsHealthy() @@ -1625,6 +1670,11 @@ func (c *Client) TasksList() *TasksListService { return NewTasksListService(c) } +// TasksGetTask retrieves a task running on the cluster. +func (c *Client) TasksGetTask() *TasksGetTaskService { + return NewTasksGetTaskService(c) +} + // TODO Pending cluster tasks // TODO Cluster Reroute // TODO Cluster Update Settings |