Skip to content

Commit

Permalink
Merge pull request #1 from Frameio/mguarino/clean_up_monitoring
Browse files Browse the repository at this point in the history
Clean up monitoring leftovers
  • Loading branch information
michaeljguarino authored Jul 18, 2018
2 parents 079514e + 6c84f25 commit 35db823
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
8 changes: 0 additions & 8 deletions lib/exlasticsearch/monitoring.ex

This file was deleted.

32 changes: 18 additions & 14 deletions lib/exlasticsearch/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ defmodule ExlasticSearch.Repo do
Creates an index as defined in `model`
"""
@spec create_index(atom) :: response
def create_index(model),
do: es_url() |> Index.create(model.__es_index__(), model.__es_settings__())
def create_index(model) do
es_url()
|> Index.create(model.__es_index__(), model.__es_settings__())
end

@doc """
Updates the index for `model`
Expand Down Expand Up @@ -52,15 +54,19 @@ defmodule ExlasticSearch.Repo do
Updates an index's mappings to the current definition in `model`
"""
@spec create_mapping(atom) :: response
def create_mapping(model),
do: es_url() |> Mapping.put(model.__es_index__(), model.__doc_type__(), model.__es_mappings__())
def create_mapping(model) do
es_url()
|> Mapping.put(model.__es_index__(), model.__doc_type__(), model.__es_mappings__())
end

@doc """
Removes the index defined in `model`
"""
@spec delete_index(atom) :: response
def delete_index(model),
do: es_url() |> Index.delete(model.__es_index__())
def delete_index(model) do
es_url()
|> Index.delete(model.__es_index__())
end

@doc """
Checks if the index for `model` exists
Expand Down Expand Up @@ -124,8 +130,10 @@ defmodule ExlasticSearch.Repo do
Removes `struct` from the index of its model
"""
@spec delete(struct) :: response
def delete(%{__struct__: model} = struct),
do: es_url() |> Document.delete(model.__es_index__(), model.__doc_type__(), Indexable.id(struct))
def delete(%{__struct__: model} = struct) do
es_url()
|> Document.delete(model.__es_index__(), model.__doc_type__(), Indexable.id(struct))
end


@doc """
Expand All @@ -143,16 +151,12 @@ defmodule ExlasticSearch.Repo do
struct to the `ExlasticSearch.Indexable` protocol
"""
def bulk(operations, opts \\ []) do
ExlasticSearch.Monitoring.increment("elasticsearch.batch_operations", length(operations))
bulk_request = operations
|> Enum.map(&bulk_operation/1)
|> Enum.concat()

result = es_url()
|> Bulk.post(bulk_request, [], opts)

Logger.debug fn -> "ES Bulk response #{inspect(result)}" end
result
es_url()
|> Bulk.post(bulk_request, [], opts)
end

def index_stream(stream, parallelism \\ 10, demand \\ 10) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Exlasticsearch.MixProject do
use Mix.Project

@version "0.2.2"
@version "0.2.3"

def project do
[
Expand Down

0 comments on commit 35db823

Please sign in to comment.