Skip to content

Conversation

@Gladear
Copy link

@Gladear Gladear commented Mar 24, 2025

Hello 👋

It has been brought to my attention through our tooling that the classic schema when using
Cloak.Ecto creates compile-connected dependencies between the schema and the vault.
Indeed, using field :field, CustomType creates a compile dependency to CustomType,
which, in this library's use case, has in turn a runtime dependency to MyApp.Vault,
creating a compile-connected dependency.

I tried to think of some ways to avoid this:

  • One of the solution was to use an API similar to :polymorphic_embed, and make
    Cloak.Ecto require to use its own field macro, but I couldn't really figure
    out how to make it work honestly 😶
  • The second, much simpler solution, is to allow providing a
    config :cloak_ecto, default_vault: MyApp.Vault in the configuration, so that
    the CustomType module does not have to reference the MyApp.Vault module.
    That obviously does not cover the use-case where projects have multiple vaults...

I did a small PoC of the second option. I did not update the documentation, nor the
unit tests, as I'm just asking your opinion on this option.

Thanks in advance!

@a3kov
Copy link

a3kov commented Apr 25, 2025

In my opinion the vault should not be a genserver at all, but a module with it's own settings. See #62. Then automatically you won't have this issue

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.

2 participants