coherence icon indicating copy to clipboard operation
coherence copied to clipboard

Config separation in umbrella projects

Open tooreht opened this issue 8 years ago • 6 comments

Setup

In an umbrella project I have two phoenix apps A and B both using Coherence in combination with ExAdmin (using Coherence.Authentication.Session) and a REST API (using Coherence.Authentication.Token). The configuration of Coherence and ExAdmin in both apps is basically the same and works flawlessly when running only one phoenix app.

Problem

After I added app B the configuration is not used. It seems that the configuration of A is shared among both apps. Because of that the following error occurs when the /admin route of ExAdmin is requested in instance B:

function Core.User.rememberable?/0 is undefined (module Core.User is not available)

For me this looks like a bug in Coherence not isolating configurations of different apps.

tooreht avatar Dec 22 '16 12:12 tooreht

Got it. I need to review umbrella apps. I have not used them since Elixir version 0.9 and figure out how to handle the Agent naming.

smpallen99 avatar Dec 22 '16 23:12 smpallen99

This is going to be an easy fix. It appears that configuration is shared by each of the apps in the umbrella. So, if multiple apps have :coherence config entries, only one copy is possible. Also, some of the coherence resources are not name spaced with the app's module.

I need to do a little more research to see how other projects solve this issue. I have a few ideas, but would to understand if there is a common pattern...

smpallen99 avatar Dec 23 '16 00:12 smpallen99

Good to hear it's going to be an easy fix. This issue seems to grow to a show stopper for coherence in my project, because it has many implications. For example:

  • Building releases with distillery

     ==> Failed to build release:
    
      Duplicated modules:
          'Elixir.ExAdmin.Authentication.Plug.Conn' specified in app1 and app2
          'Elixir.Coherence.UnlockView' specified in app1 and app2
          'Elixir.Coherence.SessionView' specified in app1 and app2
          'Elixir.Coherence.Redirects' specified in app1 and app2
          'Elixir.Coherence.PasswordView' specified in app1 and app2
          'Elixir.Coherence.LayoutView' specified in app1 and app2
          'Elixir.Coherence.InvitationView' specified in app1 and app2
          'Elixir.Coherence.EmailView' specified in app1 and app2
          'Elixir.Coherence.CoherenceView' specified in app1 and app2
    
  • Compilation

      ==> app1
      Compiling 72 files (.ex)
      warning: redefining module Coherence.EmailView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.EmailView.beam)
        web/views/coherence/email_view.ex:1
    
      warning: redefining module Coherence.UnlockView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.UnlockView.beam)
        web/views/coherence/unlock_view.ex:1
    
      warning: redefining module Coherence.PasswordView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.PasswordView.beam)
        web/views/coherence/password_view.ex:1
    
      warning: redefining module Coherence.CoherenceView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.CoherenceView.beam)
        web/views/coherence/coherence_view.ex:1
    
      warning: redefining module Coherence.Redirects (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.Redirects.beam)
        web/controllers/coherence/redirects.ex:1
    
      warning: redefining module Coherence.InvitationView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.InvitationView.beam)
        web/views/coherence/invitation_view.ex:1
    
      warning: redefining module Coherence.LayoutView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.LayoutView.beam)
        web/views/coherence/layout_view.ex:1
    
      warning: redefining module ExAdmin.Authentication.Plug.Conn (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.ExAdmin.Authentication.Plug.Conn.beam)
        lib/app1/authentication.ex:1
    
      warning: redefining module Coherence.SessionView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app2/ebin/Elixir.Coherence.SessionView.beam)
        web/views/coherence/session_view.ex:1
    
      Generated app1 app
      ==> app2
      Compiling 41 files (.ex)
      warning: redefining module Coherence.EmailView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.EmailView.beam)
        web/views/coherence/email_view.ex:1
    
      warning: redefining module Coherence.UnlockView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.UnlockView.beam)
        web/views/coherence/unlock_view.ex:1
    
      warning: redefining module Coherence.PasswordView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.PasswordView.beam)
        web/views/coherence/password_view.ex:1
    
      warning: redefining module Coherence.CoherenceView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.CoherenceView.beam)
        web/views/coherence/coherence_view.ex:1
    
      warning: redefining module Coherence.Redirects (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.Redirects.beam)
        web/controllers/coherence/redirects.ex:1
    
      warning: redefining module Coherence.InvitationView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.InvitationView.beam)
        web/views/coherence/invitation_view.ex:1
    
      warning: redefining module Coherence.LayoutView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.LayoutView.beam)
        web/views/coherence/layout_view.ex:1
    
      warning: redefining module ExAdmin.Authentication.Plug.Conn (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.ExAdmin.Authentication.Plug.Conn.beam)
        lib/app2/authentication.ex:1
    
      warning: redefining module Coherence.SessionView (current version loaded from /Users/tooreht/projects/umbrella/_build/dev/lib/app1/ebin/Elixir.Coherence.SessionView.beam)
        web/views/coherence/session_view.ex:1
    

I'm glad to help with testing or similar tasks.

tooreht avatar Dec 29 '16 08:12 tooreht

I revise my earlier statement that its going to be an easy fix. I should know better that to use that statement with software :)

I have started the work to support different user models in the same project. This requires name spacing the config for each user model and storing the namespace in the conn. This requires touching every area of coherence that references config. So its a very large change.

I have a lot of the work done, but have a couple challenging issues that still have to solve. Stay tuned for an update...

smpallen99 avatar Dec 29 '16 16:12 smpallen99

Any update on this issue? I just ran into it on an umbrella app as well

joshuaballoch avatar Aug 07 '17 08:08 joshuaballoch

Ran into same issue too. Just when I start relief because Coherence is awesomely useful :) Hope you're seeing the end of the tunnel

dominique-vassard avatar Aug 15 '17 10:08 dominique-vassard