Skip to content
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

Make private clients schema_path work better for releases #86

Closed
wants to merge 1 commit into from

Conversation

LostKobrakai
Copy link
Contributor

Hardcoding a path to schemas at compile time doesn't work well when using releases. This change would allow for the following notation (used by many elixir libraries e.g. see Plug.Static) schemas_path: {:my_app, "priv/schemas"}, which is then at runtime converted to the proper path.

@Strech
Copy link
Owner

Strech commented Jun 9, 2021

Provided values for the use statement in examples are just for demonstration purposes. If you want to have app_dir, feel free to use it

defmodule MyClient do
  use Avrora.Client,
    schemas_path: Application.app_dir(:my_elixir_app, "./path/to/schemas")
end

Or you can configure something under config/ folder and use it the same way in the example above ⬆️

@Strech Strech closed this Jun 9, 2021
@LostKobrakai
Copy link
Contributor Author

That's what we tried, but that will be hardcoded into the module at compile time. Application.app_dir will run at compile time, which will not be the correct path if the release is moved elsewhere afterwards.

@mdwaud
Copy link

mdwaud commented Jun 9, 2021

I can confirm the issue and that the proposed fix works.

@Strech
Copy link
Owner

Strech commented Jun 9, 2021

release is moved elsewhere afterwards

Another solution would be to expand the path in runtime, which will give you a semi-dynamic solution. I don't like the idea to use app_dir because it requires to know app, which is not the knowledge library should have

UPD: I can take a look is there a way to add a dynamic resolution to the schemas_path

@Strech
Copy link
Owner

Strech commented Jun 9, 2021

I will try to reproduce an issue. Is it correct that I will need to create a release (let's say distillery) and then I move the project to the docker in a different folder. Will it be enough to reproduce the issue?

@Strech
Copy link
Owner

Strech commented Jun 9, 2021

@LostKobrakai @mdwaud I've tried to compile a project with distillery and every time I move the binary around it was working fine, the path was changing every time to path expanded from the new folder I run it.

I would like to ask you for help with a test setup that will show the issue, so far I can't reproduce it. Don't hesitate to open a new issue where we can discuss our approach 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants