Skip to content

Instantly share code, notes, and snippets.

@arnarthor
Created October 30, 2015 11:45
Show Gist options
  • Select an option

  • Save arnarthor/53bfa0e8f667d9c41b4a to your computer and use it in GitHub Desktop.

Select an option

Save arnarthor/53bfa0e8f667d9c41b4a to your computer and use it in GitHub Desktop.
/**
* Put this in your env (or something similar)
* ELASTICSEARCH_TOPICS_URL=elasticsearch://localhost:9300,localhost2:9300
*/
/**
* This is all I need to do to connect using the elasticsearch protocol.
*/
def apply(esHosts: String, clusterName: String): ElasticClient = {
val settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName)
sys.env.getOrElse("ENV_NAME", "development") match {
case "production" => ElasticClient.remote(settings.build, ElasticsearchClientUri(esHosts))
case "staging" => ElasticClient.remote(settings.build, ElasticsearchClientUri(esHosts))
case "development" => ElasticClient.local
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment