Skip to content

Deguice rest handlers#22575

Merged
nik9000 merged 5 commits intoelastic:masterfrom
nik9000:deguice_rest_handlers
Jan 20, 2017
Merged

Deguice rest handlers#22575
nik9000 merged 5 commits intoelastic:masterfrom
nik9000:deguice_rest_handlers

Conversation

@nik9000
Copy link
Copy Markdown
Member

@nik9000 nik9000 commented Jan 12, 2017

There are presently 7 ctor args used in any rest handlers:

  • Settings: Every handler uses it to initialize a logger and
    some other strange things.
  • RestController: Every handler registers itself with it.
  • ClusterSettings: Used by RestClusterGetSettingsAction to
    render the default values for cluster settings.
  • IndexScopedSettings: Used by RestGetSettingsAction to get
    the default values for index settings.
  • SettingsFilter: Used by a few handlers to filter returned
    settings so we don't expose stuff like passwords.
  • IndexNameExpressionResolver: Used by _cat/indices to
    filter the list of indices.
  • Supplier<DiscoveryNodes>: Used to fill enrich the response
    by handlers that list tasks.

We probably want to reduce these arguments over time but
switching construction away from guice gives us tighter
control over the list of available arguments.

These parameters are passed to plugins using
ActionPlugin#initRestHandlers which is expected to build and
return that handlers immediately. This felt simpler than
returning an reference to the ctors given all the different
possible args.

Breaks java plugins by moving rest handlers off of guice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not really sure if it'd have been better to have the bits that are only needed to init the rest handlers on the rest handler method instead of the ctor but I went with the ctor because it felt like how we build these module now. I'm happy either way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See commit message for my I did this instead of some fancy ctor reference stuff.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Most of the files I touched I did this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops. I'll remove.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since we lost the "no duplicate" behavior from ActionModule I figured we should duplicate it here, but with paths.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exposed to ActionModule to build rest handlers. Still needs to be bound I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops. No need for this one. Can remove.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I switched this to the provider because I thought it'd be cleaner than exposing all of ClusterService.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I switched these to assert based on paths instead of class which makes more sense in the new world.

@nik9000 nik9000 force-pushed the deguice_rest_handlers branch from 7aeccca to c7f23f1 Compare January 12, 2017 00:53
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wonder if instead of exposing all of these to plugins we should remove a few. Some (indexScopedSettings, clusterSettings) are fairly single purpose.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should still call this getRestHandlers

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure.

@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Jan 17, 2017

@rjernst, could you have another look?

Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for this!

@nik9000 nik9000 force-pushed the deguice_rest_handlers branch from 8a9a5f4 to 1b0bb4c Compare January 20, 2017 15:47
There are presently 7 ctor args used in any rest handlers:
* `Settings`: Every handler uses it to initialize a logger and
  some other strange things.
* `RestController`: Every handler registers itself with it.
* `ClusterSettings`: Used by `RestClusterGetSettingsAction` to
  render the default values for cluster settings.
* `IndexScopedSettings`: Used by `RestGetSettingsAction` to get
  the default values for index settings.
* `SettingsFilter`: Used by a few handlers to filter returned
  settings so we don't expose stuff like passwords.
* `IndexNameExpressionResolver`: Used by `_cat/indices` to
  filter the list of indices.
* `Supplier<DiscoveryNodes>`: Used to fill enrich the response
  by handlers that list tasks.

We probably want to reduce these arguments over time but
switching construction away from guice gives us tighter
control over the list of available arguments.

These parameters are passed to plugins using
`ActionPlugin#initRestHandlers` which is expected to build and
return that handlers immediately. This felt simpler than
returning an reference to the ctors given all the different
possible args.
@nik9000 nik9000 force-pushed the deguice_rest_handlers branch from 1b0bb4c to a7cd47a Compare January 20, 2017 16:47
@nik9000 nik9000 merged commit 6265ef1 into elastic:master Jan 20, 2017
@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Jan 20, 2017

Thanks for reviewing @rjernst!

@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Jan 20, 2017

master: 6265ef1
5.x: 6050f22

nik9000 added a commit that referenced this pull request Jan 20, 2017
There are presently 7 ctor args used in any rest handlers:
* `Settings`: Every handler uses it to initialize a logger and
  some other strange things.
* `RestController`: Every handler registers itself with it.
* `ClusterSettings`: Used by `RestClusterGetSettingsAction` to
  render the default values for cluster settings.
* `IndexScopedSettings`: Used by `RestGetSettingsAction` to get
  the default values for index settings.
* `SettingsFilter`: Used by a few handlers to filter returned
  settings so we don't expose stuff like passwords.
* `IndexNameExpressionResolver`: Used by `_cat/indices` to
  filter the list of indices.
* `Supplier<DiscoveryNodes>`: Used to fill enrich the response
  by handlers that list tasks.

We probably want to reduce these arguments over time but
switching construction away from guice gives us tighter
control over the list of available arguments.

These parameters are passed to plugins using
`ActionPlugin#initRestHandlers` which is expected to build and
return that handlers immediately. This felt simpler than
returning an reference to the ctors given all the different
possible args.

Breaks java plugins by moving rest handlers off of guice.
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 23, 2017
* master: (33 commits)
  Docs fix - Added missing link to new Adjacency-matrix agg
  Pass `forceExecution` flag to transport interceptor (elastic#22739)
  Version: Add missing releases from 2.x in Version.java (elastic#22594)
  CONSOLE-ify filter aggregation docs
  CONSOLE-ify date_range aggregation docs
  Add single static instance of SpecialPermission (elastic#22726)
  Simplify InternalEngine#innerIndex (elastic#22721)
  Upgrade to Lucene 6.4.0 (elastic#22724)
  Fix broken TaskInfo.toString()
  Add CheckedSupplier and CheckedRunnable to core (elastic#22725)
  Revert "Make build Gradle 2.14 / 3.x compatible (elastic#22669)"
  Fixes retrieval of the latest snapshot index blob (elastic#22700)
  CONSOLE-ify date histogram docs
  CONSOLE-ify min and max aggregation docs
  CONSOLE-ify global-aggregation.asciidoc
  Fix script score function that combines _score and weight (elastic#22713)
  Corrected a plural verb to a singular one. (elastic#22681)
  Fix duplicates from search.query (elastic#22701)
  Readd unconverted snippets mark for doc
  Deguice rest handlers (elastic#22575)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants