-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
169395632 v7 2 changes #69
Changes from all commits
434dc03
1193b28
0c56859
8262092
18cd7b0
47b1370
dbaec46
a786374
c13509a
ddc351e
4583c92
192133d
8c846d5
94bbb66
844d75a
4f6c6ad
77ab2a5
7a956cc
1b4354d
9cb9ba9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
version: 2 | ||
|
||
workflows: | ||
version: 2 | ||
main: | ||
jobs: | ||
- build_2_4 | ||
- build_2_5 | ||
- build_2_6 | ||
jobs: | ||
build_2_4: | ||
resource_class: small | ||
docker: | ||
- image: ruby:2.4 | ||
- image: elastic/elasticsearch:6.8.2 | ||
environment: | ||
- xpack.security.enabled=false | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- gem-cache-2_4-v2-{{ checksum "Gemfile.lock" }} | ||
- gem-cache-2_4-v2- | ||
- checkout | ||
- run: | ||
name: Install Ruby Dependencies | ||
command: bundle install | ||
- run: | ||
name: Run Tests | ||
command: bundle exec rspec | ||
- save_cache: | ||
key: gem-cache-2_4-v2-{{ checksum "Gemfile.lock" }} | ||
paths: | ||
- ./vendor/bundle | ||
- ./vendor/cache | ||
build_2_5: | ||
resource_class: small | ||
docker: | ||
- image: ruby:2.5 | ||
- image: elastic/elasticsearch:6.8.2 | ||
environment: | ||
- xpack.security.enabled=false | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- gem-cache-2_5-v2-{{ checksum "Gemfile.lock" }} | ||
- gem-cache-2_5-v2- | ||
- checkout | ||
- run: | ||
name: Install Ruby Dependencies | ||
command: bundle install | ||
- run: | ||
name: Run Tests | ||
command: bundle exec rspec | ||
- save_cache: | ||
key: gem-cache-2_5-v2-{{ checksum "Gemfile.lock" }} | ||
paths: | ||
- ./vendor/bundle | ||
- ./vendor/cache | ||
build_2_6: | ||
resource_class: small | ||
docker: | ||
- image: ruby:2.5 | ||
- image: elastic/elasticsearch:6.8.2 | ||
environment: | ||
- xpack.security.enabled=false | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- gem-cache-2_6-v2-{{ checksum "Gemfile.lock" }} | ||
- gem-cache-2_6-v2- | ||
- checkout | ||
- run: | ||
name: Install Ruby Dependencies | ||
command: bundle install | ||
- run: | ||
name: Run Tests | ||
command: bundle exec rspec | ||
- save_cache: | ||
key: gem-cache-2_6-v2-{{ checksum "Gemfile.lock" }} | ||
paths: | ||
- ./vendor/bundle | ||
- ./vendor/cache |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,15 @@ class AliasIndex | |
|
||
STATUSES = [:missing, :ok] | ||
|
||
def initialize(client, index_base_name, document_type) | ||
def initialize(client, index_base_name, document_type, use_new_timestamp_format = false, include_type_name_on_create = true) | ||
@client = client | ||
@main_alias = index_base_name | ||
@update_alias = "#{index_base_name}_update" | ||
@document_type = document_type | ||
|
||
# included for compatibility with v7 | ||
@use_new_timestamp_format = use_new_timestamp_format | ||
@include_type_name_on_create = include_type_name_on_create | ||
end | ||
|
||
def ref_index_name | ||
|
@@ -186,11 +190,12 @@ def update_indexes | |
|
||
def create(index_def) | ||
if missing? | ||
index_name = create_index(index_def) | ||
name = create_index(index_def) | ||
@created_index_name = name | ||
@client.index_update_aliases(body: { | ||
actions: [ | ||
{ add: { index: index_name, alias: @main_alias } }, | ||
{ add: { index: index_name, alias: @update_alias } }, | ||
{ add: { index: name, alias: @main_alias } }, | ||
{ add: { index: name, alias: @update_alias } }, | ||
] | ||
}) | ||
else | ||
|
@@ -257,6 +262,10 @@ def flush | |
@client.index_flush(index: @update_alias) | ||
end | ||
|
||
def refresh | ||
@client.index_refresh(index: @update_alias) | ||
end | ||
|
||
def settings | ||
@client.index_get_settings(index: @main_alias, type: @document_type).values.first | ||
rescue Elasticsearch::Transport::Transport::Errors::NotFound | ||
|
@@ -279,11 +288,20 @@ def mapping | |
|
||
private | ||
|
||
def build_index_name | ||
ts = String.new | ||
if @use_new_timestamp_format == true | ||
ts = Time.now.utc.strftime("%Y%m%d%H%M%S%6N") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance we could add some delimiters to make this easier to parse by humans reading the index names? Something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, we could. but this format should be familiar to rails devs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and I was a bit scared of some future upgrade declaring other chars There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - I was thinking that same thing about the chars too. I'm good either way, just figured I'd mention it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
else | ||
ts = Time.now.utc.strftime("%Y-%m-%d_%H:%M:%S.%6N") | ||
end | ||
"#{@main_alias}-#{ts}" | ||
end | ||
|
||
def create_index(index_def) | ||
ts = Time.now.utc.strftime("%Y-%m-%d_%H:%M:%S.%6N") | ||
index_name = "#{@main_alias}-#{ts}" | ||
@client.index_create(index: index_name, body: index_def) | ||
index_name | ||
name = build_index_name | ||
@client.index_create(index: name, body: index_def, include_type_name: @include_type_name_on_create) | ||
name | ||
end | ||
|
||
def retryable_error?(e) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Elasticity | ||
VERSION = "0.12.1" | ||
VERSION = "0.13.0" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would emitting a deprecation log warning be useful here, or is
flush_index
still have value if it doesn't force the writes?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flush
is still a validthing
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html#flush-api-desc
it just want have the side-effect of refreshing the index which made new documents visible to searches (the side-effect that is has pre v7)