An example "skew" in current code: IcebergCatalogAdapter gets RealmContext
injected as a field, but also as a method parameters in createNamespace().

On Thu, Jun 5, 2025 at 8:35 PM Dmitri Bourlatchkov <di...@apache.org> wrote:

> Hi All,
>
> Recently a few runtime issues related to the resolution of RealmContex got
> fixed (mostly by Yun's PRs).
>
> These fixes center around the idea of passing RealmContext as a parameter
> across various method calls.
>
> That approach is effective, however, I tend to think it goes against the
> grain of the dependency injection paradigm. The main point is that realm is
> a contextual concept in Polaris REST APIs (it is not a parameter in any API
> operations). Subsequently, all the service and core code logic is normally
> realm-neutral. That is to say that services operate without having to know
> what realm they are servicing.
>
> Realm IDs become prominent only at the persistence level (to ensure
> isolation of realm data).
>
> I'd like to propose refactoring Polaris code to remove RealmContext from
> method parameters and keep it in instance fields only where it is used.
>
> * MetaStore objects for REST API endpoints will be produced for a
> particular real with the request scope lifetime
> * Tasks will operate in a similar way, where PR [1817] provides a POC
> * The Quarkus runtime will use CDI for injection
> * The polaris-core module will remain free from CDI annotations, but some
> changes will probably be required to allow injection via constructors.
>
> WDYT?
>
> If there are no strong objections up front, I can work on a bigger POC PR
> to allow reviewing / exploring this idea in more depth.
>
> [1817] https://github.com/apache/polaris/pull/1817
>
> Cheers,
> Dmitri.
>

Reply via email to