-
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
Configurator versioning #908
base: main
Are you sure you want to change the base?
Conversation
f65a08e
to
38ae9a4
Compare
38ae9a4
to
f02d8f6
Compare
iex> get_configuration_hash_version() | ||
"A6F0CC6917D195AB8A03129ACBE1FA48364845B8" | ||
""" | ||
def get_configuration_hash_version do |
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.
Why not :erlang.term_to_binary/1
the map configuration (or whatever subfields we actually want)?
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.
Because the query order of everything changes the hash everytime, and we only want to change the hash when the desired values change.
We can discuss a better approach in Slack.
|> Enum.map(fn config -> sum_shape_coordinates(config) end) | ||
|> Enum.reduce(fn coordinates_last, coordinates_current -> Decimal.add(coordinates_last, coordinates_current) end) | ||
|> Decimal.to_string() | ||
|> (fn coordinates -> :crypto.hash(:sha, coordinates) |> Base.encode16() 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.
Why base16?
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.
Just selected one at random. Any suggestions?
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.
Nope, was just curious. Also, don't think is worth discussing for this use case
651b5e8
@@ -8,8 +8,11 @@ defmodule ArenaWeb.HealthController do | |||
end | |||
|
|||
def version(conn, _params) do | |||
arena_version = Application.spec(:arena, :vsn) |> to_string() | |||
configurator_version = GameBackend.Configuration.get_configuration_hash_version() |
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.
This is not correct
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.
Be careful, this controller is duplicated in both arena and gateway apps.
We should distinct them somehow or see if both are needed.
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.
This is not working properly because this PR is trying to access to a module in another app.
It works locally, but it doesn't in the servers.
Warning
This won't be used until client's PR gets merged -> https://github.com/lambdaclass/champions_of_mirra/pull/2134
Motivation
Closes #918
We need a way to differentiate between configs.
If we change a map configuration (e.g. delete an obstacle or edit its size/position) the version should change to alert the clients.
Summary of changes
How to test it?
Make your client (https://github.com/lambdaclass/champions_of_mirra/pull/2134) point to localhost or central testing.
Then, update the version to match the configuration's.
Play a bit with map configuration params, it should ONLY change the version when something we take into account is changed (like an obstacle position, or a circle radius).
Checklist