6.1.x de-guiced ActionFilter: how to get IndexResolver and TransportService?


(Simone Scarduzio) #1

Hi,

I saw in 6.1. you have de-guiced the ActionFilters.

How can I now get to get a grip of the things like IndexResolver and TransportService in my ActionFilter implementation?

I used to inject them with Guice in my ActionFilter implementation, now I can't. What's the alternative?

I can access a subset of what I used to inject via implementing this method from Plugin.java, but it's not all of the things I need:

 public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool,
                                           ResourceWatcherService resourceWatcherService, ScriptService scriptService,
                                           NamedXContentRegistry xContentRegistry, Environment environment,
                                           NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) {

For reference, the code I'm trying to port to 6.1.0 is this

Congrats for the new release, and thanks already for your help :slight_smile:


(Ryan Ernst) #2

Action filters should be simple and stateless. This is the reason the getActionFilters() method doesn't take any parameters. What do you need all those services for?


(Simone Scarduzio) #3

Hi @rjernst!

I need that because my plugin implements basic auth and I'd like users to know the taskID associated to each users.
That enables the admins to associate long standing task to a specific account.

Also I want to log the owner of each task and how long did the task take. So I measure response_time(taskID) - request_time(taskID) and associate it to a user name.

This way people can see what users this month requested inefficient queries.

So after all, I'd just be happy to find a way given an ActionRequest, to tell what task id it belongs to. That's all!


(Simone Scarduzio) #4

Never mind the taskID can be found in the ActionFilter.handleRequestmethod, and I could just instantiate the other like this new IndexNameExpressionResolver(settings).


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.