summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/olivere/elastic.v5/config
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-07-20 15:22:49 -0700
committerGitHub <noreply@github.com>2017-07-20 15:22:49 -0700
commit58839cefb50e56ae5b157b37e9814ae83ceee70b (patch)
tree5de966481678096fc9567f74f96673b34a65127c /vendor/gopkg.in/olivere/elastic.v5/config
parente2f4492eadb5d3c58606b1fdd5774b63a07c236a (diff)
downloadchat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.gz
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.bz2
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.zip
Upgrading server dependancies (#6984)
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/config')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/config/config.go90
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/config/config_test.go45
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/config/doc.go9
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/config/elasticsearch.yml15
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/config/jvm.options100
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/config/log4j2.properties74
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/config/scripts/.gitkeep0
7 files changed, 144 insertions, 189 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/config/config.go b/vendor/gopkg.in/olivere/elastic.v5/config/config.go
new file mode 100644
index 000000000..a511c4157
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/config/config.go
@@ -0,0 +1,90 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package config
+
+import (
+ "fmt"
+ "net/url"
+ "strconv"
+ "strings"
+)
+
+// Config represents an Elasticsearch configuration.
+type Config struct {
+ URL string
+ Index string
+ Username string
+ Password string
+ Shards int
+ Replicas int
+ Sniff *bool
+ Infolog string
+ Errorlog string
+ Tracelog string
+}
+
+// Parse returns the Elasticsearch configuration by extracting it
+// from the URL, its path, and its query string.
+//
+// Example:
+// http://127.0.0.1:9200/store-blobs?shards=1&replicas=0&sniff=false&tracelog=elastic.trace.log
+//
+// The code above will return a URL of http://127.0.0.1:9200, an index name
+// of store-blobs, and the related settings from the query string.
+func Parse(elasticURL string) (*Config, error) {
+ cfg := &Config{
+ Shards: 1,
+ Replicas: 0,
+ Sniff: nil,
+ }
+
+ uri, err := url.Parse(elasticURL)
+ if err != nil {
+ return nil, fmt.Errorf("error parsing elastic parameter %q: %v", elasticURL, err)
+ }
+ index := uri.Path
+ if strings.HasPrefix(index, "/") {
+ index = index[1:]
+ }
+ if strings.HasSuffix(index, "/") {
+ index = index[:len(index)-1]
+ }
+ if index == "" {
+ return nil, fmt.Errorf("missing index in elastic parameter %q", elasticURL)
+ }
+ if uri.User != nil {
+ cfg.Username = uri.User.Username()
+ cfg.Password, _ = uri.User.Password()
+ }
+ uri.User = nil
+
+ if i, err := strconv.Atoi(uri.Query().Get("shards")); err == nil {
+ cfg.Shards = i
+ }
+ if i, err := strconv.Atoi(uri.Query().Get("replicas")); err == nil {
+ cfg.Replicas = i
+ }
+ if s := uri.Query().Get("sniff"); s != "" {
+ if b, err := strconv.ParseBool(s); err == nil {
+ cfg.Sniff = &b
+ }
+ }
+ if s := uri.Query().Get("infolog"); s != "" {
+ cfg.Infolog = s
+ }
+ if s := uri.Query().Get("errorlog"); s != "" {
+ cfg.Errorlog = s
+ }
+ if s := uri.Query().Get("tracelog"); s != "" {
+ cfg.Tracelog = s
+ }
+
+ uri.Path = ""
+ uri.RawQuery = ""
+ cfg.URL = uri.String()
+ cfg.Index = index
+
+ return cfg, nil
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/config/config_test.go b/vendor/gopkg.in/olivere/elastic.v5/config/config_test.go
new file mode 100644
index 000000000..caa3bbadb
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/config/config_test.go
@@ -0,0 +1,45 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package config
+
+import "testing"
+
+func TestParse(t *testing.T) {
+ urls := "http://user:pwd@elastic:19220/store-blobs?shards=5&replicas=2&sniff=true&errorlog=elastic.error.log&infolog=elastic.info.log&tracelog=elastic.trace.log"
+ cfg, err := Parse(urls)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if want, got := "http://elastic:19220", cfg.URL; want != got {
+ t.Fatalf("expected URL = %q, got %q", want, got)
+ }
+ if want, got := "store-blobs", cfg.Index; want != got {
+ t.Fatalf("expected Index = %q, got %q", want, got)
+ }
+ if want, got := "user", cfg.Username; want != got {
+ t.Fatalf("expected Username = %q, got %q", want, got)
+ }
+ if want, got := "pwd", cfg.Password; want != got {
+ t.Fatalf("expected Password = %q, got %q", want, got)
+ }
+ if want, got := 5, cfg.Shards; want != got {
+ t.Fatalf("expected Shards = %v, got %v", want, got)
+ }
+ if want, got := 2, cfg.Replicas; want != got {
+ t.Fatalf("expected Replicas = %v, got %v", want, got)
+ }
+ if want, got := true, *cfg.Sniff; want != got {
+ t.Fatalf("expected Sniff = %v, got %v", want, got)
+ }
+ if want, got := "elastic.error.log", cfg.Errorlog; want != got {
+ t.Fatalf("expected Errorlog = %q, got %q", want, got)
+ }
+ if want, got := "elastic.info.log", cfg.Infolog; want != got {
+ t.Fatalf("expected Infolog = %q, got %q", want, got)
+ }
+ if want, got := "elastic.trace.log", cfg.Tracelog; want != got {
+ t.Fatalf("expected Tracelog = %q, got %q", want, got)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/config/doc.go b/vendor/gopkg.in/olivere/elastic.v5/config/doc.go
new file mode 100644
index 000000000..c9acd5ff1
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/config/doc.go
@@ -0,0 +1,9 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+/*
+Package config allows parsing a configuration for Elasticsearch
+from a URL.
+*/
+package config
diff --git a/vendor/gopkg.in/olivere/elastic.v5/config/elasticsearch.yml b/vendor/gopkg.in/olivere/elastic.v5/config/elasticsearch.yml
deleted file mode 100644
index 9923cfe4f..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/config/elasticsearch.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-# bootstrap.ignore_system_bootstrap_checks: true
-
-discovery.zen.minimum_master_nodes: 1
-
-network.host:
-- _local_
-- _site_
-
-network.publish_host: _local_
-
-
-# Enable scripting as described here: https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
-script.inline: true
-script.stored: true
-script.file: true
diff --git a/vendor/gopkg.in/olivere/elastic.v5/config/jvm.options b/vendor/gopkg.in/olivere/elastic.v5/config/jvm.options
deleted file mode 100644
index d97fbc9ec..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/config/jvm.options
+++ /dev/null
@@ -1,100 +0,0 @@
-## JVM configuration
-
-################################################################
-## IMPORTANT: JVM heap size
-################################################################
-##
-## You should always set the min and max JVM heap
-## size to the same value. For example, to set
-## the heap to 4 GB, set:
-##
-## -Xms4g
-## -Xmx4g
-##
-## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
-## for more information
-##
-################################################################
-
-# Xms represents the initial size of total heap space
-# Xmx represents the maximum size of total heap space
-
--Xms2g
--Xmx2g
-
-################################################################
-## Expert settings
-################################################################
-##
-## All settings below this section are considered
-## expert settings. Don't tamper with them unless
-## you understand what you are doing
-##
-################################################################
-
-## GC configuration
--XX:+UseConcMarkSweepGC
--XX:CMSInitiatingOccupancyFraction=75
--XX:+UseCMSInitiatingOccupancyOnly
-
-## optimizations
-
-# disable calls to System#gc
--XX:+DisableExplicitGC
-
-# pre-touch memory pages used by the JVM during initialization
--XX:+AlwaysPreTouch
-
-## basic
-
-# force the server VM
--server
-
-# set to headless, just in case
--Djava.awt.headless=true
-
-# ensure UTF-8 encoding by default (e.g. filenames)
--Dfile.encoding=UTF-8
-
-# use our provided JNA always versus the system one
--Djna.nosys=true
-
-# flags to keep Netty from being unsafe
--Dio.netty.noUnsafe=true
--Dio.netty.noKeySetOptimization=true
-
-# log4j 2
--Dlog4j.shutdownHookEnabled=false
--Dlog4j2.disable.jmx=true
--Dlog4j.skipJansi=true
-
-## heap dumps
-
-# generate a heap dump when an allocation from the Java heap fails
-# heap dumps are created in the working directory of the JVM
--XX:+HeapDumpOnOutOfMemoryError
-
-# specify an alternative path for heap dumps
-# ensure the directory exists and has sufficient space
-#-XX:HeapDumpPath=${heap.dump.path}
-
-## GC logging
-
-#-XX:+PrintGCDetails
-#-XX:+PrintGCTimeStamps
-#-XX:+PrintGCDateStamps
-#-XX:+PrintClassHistogram
-#-XX:+PrintTenuringDistribution
-#-XX:+PrintGCApplicationStoppedTime
-
-# log GC status to a file with time stamps
-# ensure the directory exists
-#-Xloggc:${loggc}
-
-# Elasticsearch 5.0.0 will throw an exception on unquoted field names in JSON.
-# If documents were already indexed with unquoted fields in a previous version
-# of Elasticsearch, some operations may throw errors.
-#
-# WARNING: This option will be removed in Elasticsearch 6.0.0 and is provided
-# only for migration purposes.
-#-Delasticsearch.json.allow_unquoted_field_names=true
diff --git a/vendor/gopkg.in/olivere/elastic.v5/config/log4j2.properties b/vendor/gopkg.in/olivere/elastic.v5/config/log4j2.properties
deleted file mode 100644
index 9a3147f5a..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/config/log4j2.properties
+++ /dev/null
@@ -1,74 +0,0 @@
-status = error
-
-# log action execution errors for easier debugging
-logger.action.name = org.elasticsearch.action
-logger.action.level = debug
-
-appender.console.type = Console
-appender.console.name = console
-appender.console.layout.type = PatternLayout
-appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
-
-appender.rolling.type = RollingFile
-appender.rolling.name = rolling
-appender.rolling.fileName = ${sys:es.logs}.log
-appender.rolling.layout.type = PatternLayout
-appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.10000m%n
-appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log
-appender.rolling.policies.type = Policies
-appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
-appender.rolling.policies.time.interval = 1
-appender.rolling.policies.time.modulate = true
-
-rootLogger.level = info
-rootLogger.appenderRef.console.ref = console
-rootLogger.appenderRef.rolling.ref = rolling
-
-appender.deprecation_rolling.type = RollingFile
-appender.deprecation_rolling.name = deprecation_rolling
-appender.deprecation_rolling.fileName = ${sys:es.logs}_deprecation.log
-appender.deprecation_rolling.layout.type = PatternLayout
-appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.10000m%n
-appender.deprecation_rolling.filePattern = ${sys:es.logs}_deprecation-%i.log.gz
-appender.deprecation_rolling.policies.type = Policies
-appender.deprecation_rolling.policies.size.type = SizeBasedTriggeringPolicy
-appender.deprecation_rolling.policies.size.size = 1GB
-appender.deprecation_rolling.strategy.type = DefaultRolloverStrategy
-appender.deprecation_rolling.strategy.max = 4
-
-logger.deprecation.name = org.elasticsearch.deprecation
-logger.deprecation.level = warn
-logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling
-logger.deprecation.additivity = false
-
-appender.index_search_slowlog_rolling.type = RollingFile
-appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling
-appender.index_search_slowlog_rolling.fileName = ${sys:es.logs}_index_search_slowlog.log
-appender.index_search_slowlog_rolling.layout.type = PatternLayout
-appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.10000m%n
-appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs}_index_search_slowlog-%d{yyyy-MM-dd}.log
-appender.index_search_slowlog_rolling.policies.type = Policies
-appender.index_search_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy
-appender.index_search_slowlog_rolling.policies.time.interval = 1
-appender.index_search_slowlog_rolling.policies.time.modulate = true
-
-logger.index_search_slowlog_rolling.name = index.search.slowlog
-logger.index_search_slowlog_rolling.level = trace
-logger.index_search_slowlog_rolling.appenderRef.index_search_slowlog_rolling.ref = index_search_slowlog_rolling
-logger.index_search_slowlog_rolling.additivity = false
-
-appender.index_indexing_slowlog_rolling.type = RollingFile
-appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling
-appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs}_index_indexing_slowlog.log
-appender.index_indexing_slowlog_rolling.layout.type = PatternLayout
-appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.10000m%n
-appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs}_index_indexing_slowlog-%d{yyyy-MM-dd}.log
-appender.index_indexing_slowlog_rolling.policies.type = Policies
-appender.index_indexing_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy
-appender.index_indexing_slowlog_rolling.policies.time.interval = 1
-appender.index_indexing_slowlog_rolling.policies.time.modulate = true
-
-logger.index_indexing_slowlog.name = index.indexing.slowlog.index
-logger.index_indexing_slowlog.level = trace
-logger.index_indexing_slowlog.appenderRef.index_indexing_slowlog_rolling.ref = index_indexing_slowlog_rolling
-logger.index_indexing_slowlog.additivity = false
diff --git a/vendor/gopkg.in/olivere/elastic.v5/config/scripts/.gitkeep b/vendor/gopkg.in/olivere/elastic.v5/config/scripts/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
--- a/vendor/gopkg.in/olivere/elastic.v5/config/scripts/.gitkeep
+++ /dev/null