kibana/docs
Marco Antonio Ghiani 747ecea18a
[Discover] Create Discover Shared plugin and features registry (#181952)
## 📓 Summary

Closes #181528 
Closes #181976 

**N.B.** This work was initially reviewed on a separate PR at
https://github.com/tonyghiani/kibana/pull/1.

This implementation aims to have a stateful layer that allows the
management of dependencies between Discover and other plugins, reducing
the need for a direct dependency.

Although the initial thought was to have a plugin to register features
for Discover, there might be other cases in future where we need to
prevent cyclic dependencies.
With this in mind, I created the plugin as a more generic solution to
hold stateful logic as a communication layer for Discover <-> Plugins.

## Discover Shared

Based on some recurring naming in the Kibana codebase, `discover_shared`
felt like the right place for owning these dependencies and exposing
Discover functionalities to the external world.
It is initially pretty simple and only exposes a registry for the
Discover features, but might be a good place to implement other upcoming
concepts related to Discover.

Also, this plugin should ideally never depend on other solution plugins
and keep its dependencies to a bare minimum of packages and core/data
services.

```mermaid
flowchart TD

A(Discover) -- Get --> E[DiscoverShared]
B(Logs Explorer) -- Set --> E[DiscoverShared]
C(Security) -- Set --> E[DiscoverShared]
D(Any app) -- Set --> E[DiscoverShared]
```

## DiscoverFeaturesService

This service initializes and exposes a strictly typed registry to allow
consumer apps to register additional features and Discover and retrieve
them.

The **README** file explains a real use case of when we'd need to use it
and how to do that step-by-step.

Although it introduces a more nested folder structure, I decided to
implement the service as a client-service and expose it through the
plugin lifecycle methods to provide the necessary flexibility we might
need:
- We don't know yet if any of the features we register will be done on
the setup/start steps, so having the registry available in both places
opens the door to any case we face.
- The service is client-only on purpose. My opinion is that if we ever
need to register features such as server services or anything else, it
should be scoped to a similar service dedicated for the server lifecycle
and its environment.
It should never be possible to register the ObsAIAssistant
presentational component from the server, as it should not be permitted
to register a server service in the client registry.
A server DiscoverFeaturesService is not required yet for any feature, so
I left it out to avoid overcomplicating the implementation.

## FeaturesRegistry

To have a strictly typed utility that suggests the available features on
a registry and adheres to a base contract, the registry exposed on the
DiscoverFeaturesService is an instance of the `FeaturesRegistry` class,
which implements the registration/retrieval logic such that:
- If a feature is already registered, is not possible to override it and
an error is thrown to notify the user of the collision.
- In case we need to react to registry changes, is possible to subscribe
to the registry or obtain it as an observable for more complex
scenarios.

The FeaturesRegistry already takes care of the required logic for the
registry, so that `DiscoverFeaturesService`is left with the
responsibility of instantiating/exposing an instance and provide the set
of allowed features.

---------

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
2024-05-03 11:27:32 +02:00
..
api [Synthetics] Monitor CRUD's public api's (#169928) 2024-04-12 15:10:11 -04:00
apm [DOCS] Update Observability docs to fix problems found during testing (#175636) 2024-01-29 11:05:21 -08:00
canvas Removes duplicate images (#173097) 2023-12-11 11:36:25 -08:00
concepts [data views] cache field caps requests (#168910) 2024-01-16 06:54:38 -06:00
dev-tools Sort out objectization in variable substitution (#162382) 2023-07-27 09:30:52 +09:00
developer [Discover] Create Discover Shared plugin and features registry (#181952) 2024-05-03 11:27:32 +02:00
development/plugins/expressions/public Remove old doc generation system for core APIs (#134313) 2022-06-21 17:43:17 +02:00
discover [ES|QL] Rename the setting to a more generic one and move to the general section (#182074) 2024-05-01 16:13:53 +02:00
fleet [DOCS] Fleet managed content (#178380) 2024-03-25 22:14:29 +00:00
getting-started [DOCS] Updates the quick start guide (#163165) 2023-08-04 15:55:25 +02:00
management [ES|QL] Rename the setting to a more generic one and move to the general section (#182074) 2024-05-01 16:13:53 +02:00
maps [Docs][Chore] Fix asset tracking tutorial from 8.12 improvements (#176061) 2024-02-02 05:22:55 -07:00
migration [DOCS] Remove breaking changes tags (#162928) 2023-08-02 08:27:22 -04:00
observability
osquery [DOCS] Documents Osquery Timeout setting (#174595) 2024-01-17 15:29:23 +00:00
settings [GenAI] Bedrock Claude 3 Support (#179304) 2024-03-27 13:24:10 -06:00
setup Config: add support for ${VAR:default} syntax (#182139) 2024-05-01 07:55:24 +02:00
siem [DOCS] Elastic Sec Overview (Fixing Image) (#104529) 2021-07-07 09:58:09 -04:00
spaces Removing docs about multi-tenancy (#143698) 2022-10-24 16:01:43 -04:00
user [DOCS] Fix docs and screenshots for rule creation changes (#181925) 2024-05-01 09:18:17 -07:00
accessibility.asciidoc
action-type-template.asciidoc [DOCS] Add preconfigured AWS Bedrock connector (#168663) 2023-10-16 08:23:12 -07:00
CHANGELOG.asciidoc [DOCS] Add a bug fix for 8.13.3 release notes (#182373) 2024-05-02 22:25:05 +03:00
gs-index.asciidoc [DOCS] Remove or move book-scoped attributes (#155210) 2023-04-20 09:12:09 -07:00
index.asciidoc [Docs] remove Kibana book-scoped variables (#178676) 2024-03-14 11:53:33 -04:00
index.x.asciidoc
landing-page.asciidoc [DOCS] Fix welcome-to-elastic link (#166357) 2023-09-14 06:08:35 -04:00
limitations.asciidoc
migration.asciidoc
redirects.asciidoc [DOCS] Create stub page for Playground (#181266) 2024-04-22 10:16:52 +02:00
rule-type-template.asciidoc [DOCS] Create and manage rule action frequencies (#150957) 2023-02-23 13:16:46 -08:00
template.asciidoc [DOCS] Remove snapshot and restore docs (#114836) 2021-11-16 16:59:24 -05:00