-
Notifications
You must be signed in to change notification settings - Fork 172
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
Refactor RealmContext
to RealmId
#741
Conversation
988c7ef
to
f4352b5
Compare
|
||
@ApplicationScoped | ||
public class QuarkusValueExpressionResolver implements ValueExpressionResolver { | ||
|
||
@Override | ||
public String resolve(@Nonnull String expression, @Nullable Object parameter) { | ||
// TODO maybe replace with CEL of some expression engine and make this more generic | ||
if (parameter instanceof RealmContext realmContext && expression.equals("realmIdentifier")) { | ||
return realmContext.getRealmIdentifier(); | ||
if (parameter instanceof RealmId realmId && expression.equals("realmIdentifier")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class exists only because the old RealmContext
did not have a meaningful toString()
representation.
When this class is passed as a method argument to a generated API method:
@Context @MeterTag(key="realm_id",expression="realmIdentifier") RealmContext realmContext
I had to use an expression + expression resolver in order to extract the id from RealmContext
.
Question: is it possible for RealmId
to have a custom toString()
representation that simply returns the realm ID? In this case we can get rid of the expression + resolver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me check...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meh - does not work :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's at least change the expression from "realmIdentifier"
to "id"
– I mean, for now it doesn't matter (it could be any string), but if we ever introduce CEL, then the expression must be valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be "realm.id" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yes, that's probably better 👍
b8de206
to
166b8ed
Compare
polaris-core/src/main/java/org/apache/polaris/core/context/RealmId.java
Outdated
Show resolved
Hide resolved
cdd336e
to
e273f1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new RealmId
name does look more appropriate given its usage.
`RealmContext` is not an actual context but just a container for the ID of the realm. This change makes this explicit.
e273f1f
to
be51c21
Compare
@PolarisImmutable | ||
@JsonSerialize(as = ImmutableRealmId.class) | ||
@JsonDeserialize(as = ImmutableRealmId.class) | ||
public interface RealmId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were making this change, why don't we call it Realm
, instead of RealmId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's the ID of a realm - not the realm itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The realmId
used to be a simple string, but it has now been replaced by a RealmId
type, which contains a field called id
—essentially an id
of an id
. While this approach works, it feels cumbersome and lacks extensibility. For instance, if we want to add new fields like a description
for a realm, we would have to either include it under this interface or create a separate interface, such as Realm
or RealmContext
.
Adding new fields directly under RealmId
feels odd since these fields typically represent a concept that is part of a realm
rather than the realmId
. On the other hand, introducing a separate interface adds complexity by requiring an additional structure to be defined.
Additionally, I’m questioning whether the concepts of realm
and realmId
are truly distinct or interchangeable. If they are interchangeable, using the name realm
instead of realmId
might be a more concise and descriptive choice, simplifying the naming and making the code easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change and is not compatible with the existing deployment. I'm fine with moving forward if others are comfortable with it, but I’d like to hear more input from the team first. cc @dennishuo @collado-mike @eric-maynard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems innocuous enough. My main concern would be if application users suddenly didn't see the keys they were looking for in the logs or the headers suddenly stopped working, bug AFAICT, there are no such changes
Please don’t merge a PR if there are open comments. It’s important to work through all feedback, especially for something as impactful as a breaking change. Plus this isn’t an urgent fix, and just filed 2 days ago, we should take the time to think it through carefully before merging. |
+1 There are a lot of changes to interfaces and user-facing APIs being pushed and some of them are not really more than cosmetic. I'm all for refactoring and nailing down the right APIs, but these changes should have appropriate review and feedback. If there are open comments, people shouldn't be merging without closing the conversation first. |
Absolutely ! It's required in an Apache project to have collaboration. If it helps we can enabled blocking PR merge if all discussions are not resolved. |
@flyrain @jbonofre The PR got two approvals. The comment with the approval from @collado-mike answering your question: "This seems innocuous enough. My main concern would be if application users suddenly didn't see the keys they were looking for in the logs or the headers suddenly stopped working, bug AFAICT, there are no such changes" (emphasis mine) BTW: This |
My previous comment was a general one: if there are comments before merge it should be considered. For this PR in particular, we had approval from two committers and no non resolved discussions (before the merge) so we are probably fine. If it needs to be revisited later, a committer can open a revert PR or an update PR that's fine. |
I explicitly did not mark the PR as approved, as I was expecting for other folks to chime in. The change does seem innocuous, but I think asking to wait for feedback and the expectation to wait for @flyrain to resolve the conversation before merging seems reasonable |
Shoot. I didn't mean to click approve. Sorry about the confusion. I meant for others to be able to chime in |
@jbonofre This comment wasn't resolved before the merge, #741 (comment). @snazy, we don’t really need an interface for an ID. An ID is just a string, which I see as an atomic concept—simple and self-contained, without properties. Adding sub-properties to an ID interface (e.g., |
A distinct type is needed to eventually inject it via CDI. Further, a distinct type makes it very clear that this string is the realm-id. I also noted above that the docs for this interface clearly state that this type represents the realm-ID extracted from a REST request - and there is only the ID that can be extracted from a REST request. That can then be used to get more information. |
If the ID is the only element we need to extract, |
That's your personal preference, right? |
If my name is Bob, I will be uncomfortable if others call me BobID. |
Is the |
I'll add my 2 cents, since I commented above saying that the renaming made sense :) It's true that As to Now, I see that |
RealmContext
is not an actual context but just a container for the ID of the realm. This change makes this explicit.