lib/esse/backend/index/open.rb in esse-0.0.5 vs lib/esse/backend/index/open.rb in esse-0.1.1
- old
+ new
@@ -19,11 +19,14 @@
# in case of failure
# @return [Hash] the elasticsearch response
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-open.html
def open!(suffix: index_version, **options)
- client.indices.open(options.merge(index: index_name(suffix: suffix)))
+ Esse::Events.instrument('elasticsearch.open') do |payload|
+ payload[:request] = attributes = options.merge(index: index_name(suffix: suffix))
+ payload[:response] = client.indices.open(**attributes)
+ end
end
# Open a previously closed index
#
# @option options [String, nil] :suffix The index suffix. Defaults to the index_version.
@@ -33,16 +36,16 @@
# @option options [String] :ignore_indices When performed on multiple indices, allows to ignore
# `missing` ones (options: none, missing) @until 1.0
# @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
# unavailable (missing, closed, etc)
# @option options [Time] :timeout Explicit operation timeout
- # @return [Hash, false] the elasticsearch response, or false in case of failure
+ # @return [Hash] the elasticsearch response, or an hash with 'errors' as true in case of failure
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-open.html
def open(suffix: index_version, **options)
open!(suffix: suffix, **options)
rescue Elasticsearch::Transport::Transport::ServerError
- false
+ { 'errors' => true }
end
end
include InstanceMethods
end