Skip to content
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

[New platform] Extend request handler with request scoped core capabilities #33783

Closed
mshustov opened this issue Mar 25, 2019 · 3 comments · Fixed by #43103
Closed

[New platform] Extend request handler with request scoped core capabilities #33783

mshustov opened this issue Mar 25, 2019 · 3 comments · Fixed by #43103
Labels
enhancement New value added to drive a business result Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@mshustov
Copy link
Contributor

mshustov commented Mar 25, 2019

Description

Updated:
New implementation should be based on RFC #36509

Outdated Reactive nature of core services implies that core capabilities can be updated during the lifecycle. ```js setup(core){ const client = core.elasticsearch.adminClient$.pipe(first()).toPromise(); ... handler(request){ // - client can be outdated // - we have to bind a scope manually // - we provide full access to raw request const result = await client.asScoped(request, '...') }) ``` To prevent core capabilities from stalling we can provide an alternative mechanism that - always exposes the fresh version of core capabilities - binds them to the current request automatically
setup(core){ 
  ...
  // NOTE: passing core with scoped functionality as an additional argument is not final proposal
  handler(request, , core){
     const scopedClient = core.elasticsearch.scopedAdminClient;
     const result = await scopedClient('...')

Besides of scoped core services we may want to provide request scoped plugin capabilities.

setup(core, plugins){ 
  plugins.XXX.registerScopedCall({
    handler(..., core){
      const scopedClient = core.elasticsearch.scopedAdminClient;
    }
  });
  ...  
  // NOTE: passing core & plugins with scoped functionality as an additional arguments is not final proposal
  handler(request, , core, plugins){
     await plugins.scopedCall(...

Implementation

TBD

Related discussions

The previous discussion about request-scoped services with examples is in the umbrella issue #12464

@mshustov mshustov added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform enhancement New value added to drive a business result labels Mar 25, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@epixa
Copy link
Contributor

epixa commented Mar 25, 2019

To clarify, in your handler example, wouldn't it just be core.elasticsearch.scopedAdminClient rather than an observable? Basically, it would be based on the result of core.elasticsearch.adminClient$.pipe(first()).toPromise() at request-time.

@mshustov
Copy link
Contributor Author

@epixa right, fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants