Giter Site home page Giter Site logo

Comments (6)

slashdotdash avatar slashdotdash commented on April 28, 2024

Thanks for a the bug report. I'll test what happens when you force a recompile (mix compile --force) and add a note to the README if that solves the issue. It's unlikely that a user will swap event store providers more than once after initial setup. The macro provides convenient, and quick, access to the module.

from commanded.

timbuchwaldt avatar timbuchwaldt commented on April 28, 2024

I think you could quote this code. It should be equally fast (as it will be evaluated at compiletime as well) but the expansion will happen at compiletime of the module that uses Commanded.EventStore. But thats guesswork now :D

from commanded.

slashdotdash avatar slashdotdash commented on April 28, 2024

Yes, that's exactly what it should be doing. Thanks for the pointer, want to submit a pull request with the change ;-)

from commanded.

timbuchwaldt avatar timbuchwaldt commented on April 28, 2024

I tried it locally, sadly my (poor) understanding of the macro system let to no improvement on this.

from commanded.

slashdotdash avatar slashdotdash commented on April 28, 2024

That's a shame, not to worry though. I'll take a look.

from commanded.

slashdotdash avatar slashdotdash commented on April 28, 2024

I've done some testing on this issue. It appears to be ok if you force a recompile of Commanded after making the config change.

To verify, I added logging to the Commanded.EventStore macro to output the configured adapter:

defmodule Commanded.EventStore do
  defmacro __using__(_) do
    adapter = Application.get_env(:commanded, :event_store_adapter) || raise ArgumentError, "Commanded expects :event_store_adapter to be configured in environment"
    IO.puts "event store adapter: #{inspect adapter}"

    quote do
      @event_store unquote(adapter)
    end
  end
end

Then I configured my app to use the in-memory adapter:

$ mix deps.compile commanded --force
==> commanded
Compiling 37 files (.ex)
event store adapter: Commanded.EventStore.Adapters.InMemory
...

I changed the config in my app to use the event store adapter and forced a recompile:

$ mix deps.compile commanded --force
==> commanded
Compiling 37 files (.ex)
event store adapter: Commanded.EventStore.Adapters.EventStore
...

So given that outcome, I've updated the README to include the above force recompile step when installing, or changing between, event store adapters.

from commanded.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.