Skip to content

feat(storage): add eventStore.backend setting and a single event repository factory - #806

Open
Anshumancanrock wants to merge 5 commits into
cameri:mainfrom
Anshumancanrock:feat/event-store-backend-setting
Open

Anshumancanrock wants to merge 5 commits into
cameri:mainfrom
Anshumancanrock:feat/event-store-backend-setting

Conversation

@Anshumancanrock

Copy link
Copy Markdown
Collaborator

Description

Adds an eventStore.backend setting and a createEventRepository factory. All nine places that built EventRepository directly now go through the factory. postgres is the default and the only value for now, so nothing changes for existing relays.

  • The primary reads the setting once at startup and passes it to every worker as EVENT_STORE_BACKEND, so a re-forked worker gets the same store.
  • An unsupported value is rejected by validateSettings, and the relay exits with an error before forking any worker.
  • The startup banner prints the active store. The setting is documented in CONFIGURATION.md and default-settings.yaml.

Related Issue

Closes #802

Motivation and Context

First step toward serving events from strfry behind IEventRepository. Landing the seam on its own keeps the backend PR free of call-site changes.

The setting is read once because workers hot-reload settings.yaml, and the invoice, admission and payment-callback handlers build a repository on every request. A live read could split a running relay across two stores, or turn those endpoints into 500s after a typo.

How Has This Been Tested?

  • pnpm test:unit: 2107 passing, 24 of them new. pnpm lint, build:check and check:deps are clean.
  • The Docker integration suite wasn't run locally.

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@changeset-bot

changeset-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7765b37

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High impact] Centralizes event repository creation through a new factory.

The PR appears safe to merge, with a non-blocking correction needed to the settings API's restart guidance.

Findings

  1. P2 Wrong restart guidance ▶

Summary

Adds eventStore.backend, with postgres as the default and only supported store.

  • The relay chooses its event store once when it starts.
  • Event repositories now come from one shared factory.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Settings["Startup settings"] --> Primary["Primary resolves backend"]
  Primary --> Env["EVENT_STORE_BACKEND"]
  Env --> Workers["Workers and replacement workers"]
  Workers --> Factory["createEventRepository"]
  Import["Import command settings"] --> Factory
  Factory --> Postgres["EventRepository: postgres"]
Loading

Reviews (1) · Last reviewed commit: "chore: add changeset for eventStore.back..." · Reviewed by Greptile

Comment thread src/app/app.ts
Comment on lines +92 to +95
// Resolve once so every worker shares it and a bad value fails before forking.
let eventStoreBackend: EventStoreBackend
try {
eventStoreBackend = getConfiguredEventStoreBackend(settings)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Wrong restart guidance

eventStore.backend now needs a restart, but the settings PATCH API still labels it hot-reload. getSettingsReloadBehavior only marks workers., payments, and network. as restart-required, so clients receive the wrong guidance for this setting.

Add the new setting to that helper and test its PATCH response. Only postgres is supported today, so this is a non-blocking API guidance issue rather than an incorrect store switch.

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 73.072% (+0.5%) from 72.586% — Anshumancanrock:feat/event-store-backend-setting into cameri:main

This branch has not been deployed

No deployments
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.

[REQUEST] Add an eventStore.backend setting and build event repositories in one place

2 participants