-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
367 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lib/caoutsearch/config/client.rb → lib/caoutsearch/concerns/client.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/caoutsearch/config/mappings.rb → lib/caoutsearch/concerns/mappings.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# frozen_string_literal: true | ||
|
||
module Caoutsearch | ||
class Configuration | ||
DEFAULT_INSTRUMENTATION_FORMAT = "full" | ||
|
||
attr_reader :client, :settings, :instrumentation_format | ||
|
||
def initialize | ||
self.client = Elasticsearch::Client.new | ||
self.settings = {} | ||
end | ||
|
||
def client=(client) | ||
@client = client | ||
|
||
index.client = client | ||
search.client = client | ||
end | ||
|
||
def settings=(settings) | ||
settings = Caoutsearch::Settings.new(settings) if settings.is_a?(Hash) | ||
@settings = settings | ||
end | ||
|
||
def instrument(format = DEFAULT_INSTRUMENTATION_FORMAT) | ||
@instrumentation_format = format.to_s | ||
|
||
index.instrument(format) | ||
search.instrument(format) | ||
end | ||
|
||
def index | ||
@index ||= IndexConfig.new | ||
yield(@index) if block_given? | ||
@index | ||
end | ||
|
||
def search | ||
@search ||= SearchConfig.new | ||
yield(@search) if block_given? | ||
@search | ||
end | ||
|
||
class IndexConfig | ||
attr_accessor :client | ||
attr_reader :instrumentation_format | ||
|
||
def instrument(format = DEFAULT_INSTRUMENTATION_FORMAT) | ||
@instrumentation_format = format.to_s | ||
Caoutsearch::Instrumentation::Index.attach_to :caoutsearch_index | ||
end | ||
end | ||
|
||
class SearchConfig | ||
attr_accessor :client | ||
attr_reader :instrumentation_format | ||
|
||
def instrument(format = DEFAULT_INSTRUMENTATION_FORMAT) | ||
@instrumentation_format = format.to_s | ||
Caoutsearch::Instrumentation::Search.attach_to :caoutsearch_search | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.