-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3158 from nulib/deploy/staging
Deploy Meadow v6.1.0
- Loading branch information
Showing
34 changed files
with
864 additions
and
267 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
defmodule Meadow.Data.ReindexWorker do | ||
@moduledoc """ | ||
IntervalTask that reindexes from V1 to V2 | ||
""" | ||
alias Meadow.Data.Reindexer | ||
alias Meadow.IntervalTask | ||
|
||
use IntervalTask, default_interval: 1_000, function: :synchronize | ||
|
||
@impl IntervalTask | ||
def initial_state(_args), | ||
do: %{override: true, tasks: %{}} | ||
|
||
def synchronize(%{tasks: tasks} = state) do | ||
tasks = Reindexer.synchronize(tasks) | ||
{:noreply, Map.replace(state, :tasks, tasks)} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
defmodule Meadow.Data.Reindexer do | ||
@moduledoc """ | ||
Reindexes from v1 to v2 using the OpenSearch Reindex API. | ||
""" | ||
use Meadow.Utils.Logging | ||
|
||
alias Meadow.Config | ||
alias Meadow.Data.Schemas.{Collection, FileSet, Work} | ||
alias Meadow.Search.Client, as: SearchClient | ||
|
||
require Logger | ||
|
||
def synchronize(tasks) do | ||
with_log_metadata module: __MODULE__ do | ||
[FileSet, Work, Collection] | ||
|> Enum.map(&process_schema(&1, Map.get(tasks, &1, nil))) | ||
|> Enum.into(%{}) | ||
end | ||
end | ||
|
||
defp process_schema(schema, task_id) do | ||
if SearchClient.task_completed?(task_id) do | ||
synchronize_schema(schema) | ||
else | ||
{schema, task_id} | ||
end | ||
end | ||
|
||
defp synchronize_schema(schema) do | ||
destination = Config.v2_index(schema) | ||
|
||
case SearchClient.latest_v2_indexed_time(schema) do | ||
{:ok, indexed_at} -> | ||
case SearchClient.reindex(schema, indexed_at) do | ||
{:ok, task} -> | ||
Logger.info( | ||
"Documents newer than #{indexed_at} reindexing into #{destination}, task: #{task}" | ||
) | ||
|
||
{schema, task} | ||
|
||
{:error, error} -> | ||
Logger.error("Error reindexing into #{destination}: #{inspect(error)}") | ||
{schema, nil} | ||
end | ||
|
||
{:error, error} -> | ||
Logger.error("Error reindexing into #{destination}: #{inspect(error)}") | ||
{schema, nil} | ||
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
Oops, something went wrong.