-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Introduce projectClient method on Client #129174
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
Conversation
We originally defined the `projectClient` method on `ProjectResolver` as a convenience method to execute API calls for specific projects. That method requires a reference to both a `ProjectResolver` and a `Client`. We now introduce the same method directly on the `Client` interface and inject a `ProjectResolver` there, removing the need for a `ProjectResolver` reference in places that just want to execute API requests on a specific project. To reduce the number of changes, this change solely focuses on introducing the new method. Future changes will migrate the uses of the original method to the new one and remove the original altogether.
|
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
samxbr
left a comment
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.
Thanks for making this change Niels! This will make my change for adding project id to PersistentTasksService easier too.
LGTM based on the discussion in the other thread, just post a question.
...elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusActionTests.java
Outdated
Show resolved
Hide resolved
samxbr
left a comment
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.
Oh I just saw the serverless tests failed, code compilation failed, looks like you need to update the serverless package as well
ywangd
left a comment
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.
LGTM
Some minor comments plus pending fix for the serverless CI.
| return new FilterClient(this) { | ||
| @Override | ||
| protected <Request extends ActionRequest, Response extends ActionResponse> void doExecute( | ||
| ActionType<Response> action, | ||
| Request request, | ||
| ActionListener<Response> listener | ||
| ) { | ||
| projectResolver.executeOnProject(projectId, () -> super.doExecute(action, request, listener)); | ||
| } | ||
| }; |
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.
I suggest we also override the projectClient method here to throw an exception says something like "not supporting nested project client creation". The execution should fail anyway without it due to double setting project-id. But an explicit exception makes it quicker to happen and 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.
Good idea!
x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/analysis/CancellationTests.java
Show resolved
Hide resolved
x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlAnomaliesIndexUpdateTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlIndexRolloverTests.java
Outdated
Show resolved
Hide resolved
We added a new `projectClient` method on `Client` in #129174. We now update the usages of the old method (on `ProjectResolver`) to use the new one and we delete the old method.
We added a new `projectClient` method on `Client` in #129174. We now update the usages of the old method (on `ProjectResolver`) to use the new one and we delete the old method.
We added a new `projectClient` method on `Client` in #129174. We now update the usages of the old method (on `ProjectResolver`) to use the new one and we delete the old method.
We added a new `projectClient` method on `Client` in elastic#129174. We now update the usages of the old method (on `ProjectResolver`) to use the new one and we delete the old method.
We added a new `projectClient` method on `Client` in elastic#129174. We now update the usages of the old method (on `ProjectResolver`) to use the new one and we delete the old method.
We added a new `projectClient` method on `Client` in #129174. We now update the usages of the old method (on `ProjectResolver`) to use the new one and we delete the old method.
We originally defined the
projectClientmethod onProjectResolveras a convenience method to execute API calls for specific projects. That method requires a reference to both aProjectResolverand aClient.We now introduce the same method directly on the
Clientinterface and inject aProjectResolverthere, removing the need for aProjectResolverreference in places that just want to execute API requests on a specific project.To reduce the number of changes, this change solely focuses on introducing the new method. Future changes will migrate the uses of the original method to the new one and remove the original altogether.