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

RailsEventStore::Browser doesn't work out of the box #17

Closed
Samsinite opened this issue Apr 3, 2024 · 1 comment · Fixed by #18
Closed

RailsEventStore::Browser doesn't work out of the box #17

Samsinite opened this issue Apr 3, 2024 · 1 comment · Fixed by #18
Assignees
Labels
enhancement New feature or request

Comments

@Samsinite
Copy link
Contributor

Samsinite commented Apr 3, 2024

What did you do?

Tried to mount RailsEventStore::Browser engine and load the page (followed these instructions).

What did you expect to happen?

The page would load and I would be able to browse through the various events and stream specific events.

What actually happened?

It errored when trying to look up the event store using Rails.configuration.event_store because it was undefined.

Additional context

Creating a custom engine that used:

endpoint RubyEventStore::Browser::App.for(event_store_locator: -> { ActiveEventStore.event_store })

worked instead.

Can you think of an ideal way that active event store could be setup so that using this engine just works? My initial thoughts are that this library can define its own engine to include instead, and add a section to the README about it:

# frozen_string_literal: true

require "ruby_event_store/browser/app"
require "rails/engine"

module ActiveEventStore
  class Browser < Rails::Engine
    endpoint RubyEventStore::Browser::App.for(event_store_locator: -> { ActiveEventStore.event_store })

    railtie_name "ruby_event_store_browser_app"
  end
end

But maybe a different approach would be better (such as calling RailsEventStore::Browser.endpoint RubyEventStore::Browser::App.for(event_store_locator: -> { ActiveEventStore.event_store }) after ActiveEventStore.event_store is set). Or if you aren't interested in supporting this engine out of the box, no worries, it is easy enough to define a custom one in-app. If you are interested in supporting this engine using active event store, let me know what apporach you'd like to take, I'd be happy to take a stab at it.

Edit:

Actually, I think just calling

RailsEventStore::Browser.endpoint RubyEventStore::Browser::App.for(event_store_locator: -> { ActiveEventStore.event_store })

In the config.to_prepare do block after ActiveEventStore.event_store is set would work best and "just work" as expected for developers.

@palkan
Copy link
Owner

palkan commented Apr 18, 2024

I wonder if we'd better use Rails.configuration.event_store as an alias for ActiveEventStore.event_store as it's the "recommended location"?

That means, adding an initializers (in the Railtie) setting Rails.configuration.event_store = ActiveEventStore.event_store would make the browser work (and other tools relying on the default location).

@palkan palkan added the enhancement New feature or request label Apr 18, 2024
Samsinite added a commit to Samsinite/active_event_store that referenced this issue Apr 25, 2024
This commit updates ActiveEventStore to define Rails.configuration.event_store after the event store has been initialized. Fixes palkan#17
palkan pushed a commit that referenced this issue Apr 26, 2024
This commit updates ActiveEventStore to define Rails.configuration.event_store after the event store has been initialized. Fixes #17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants