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

[core-new-docs] Adds a dev-doc for core documentation #92976

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dev_docs/kibana_platform_plugin_intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ We will continue to focus on adding clarity around these types of services and w

### Core services

Sometimes referred to just as Core, Core services provide the most basic and fundamental tools neccessary for building a plugin, like creating saved objects,
Sometimes referred to just as <DocLink id="kibServerAndCoreComponents" text="Core, Core services"/> provide the most basic and fundamental tools neccessary for building a plugin, like creating saved objects,
routing, application registration, notifications and <DocLink id="kibCoreLogging" text="logging"/>. The Core platform is not a plugin itself, although
there are some plugins that provide platform functionality. We call these <DocLink id="kibPlatformIntro" section="platform-plugins" text="Platform plugins"/>.

Expand Down Expand Up @@ -141,4 +141,4 @@ plugins to customize the Kibana experience. Examples of extension points are:

## Follow up material

Learn how to build your own plugin by following <DocLink id="kibDevTutorialBuildAPlugin" />
Learn how to build your own plugin by following <DocLink id="kibDevTutorialBuildAPlugin" />.
30 changes: 30 additions & 0 deletions dev_docs/kibana_server_core_components.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
id: kibServerAndCoreComponents
slug: /kibana-dev-docs/core-intro
title: Core components
summary: An introduction to the Kibana server and core components.
date: 2021-02-26
tags: ['kibana','onboarding', 'dev', 'architecture']
---

Core is a set of systems (frontend, backend etc.) that Kibana and its plugins are built on top of.

## Integration with the "legacy" Kibana
Copy link
Member

Choose a reason for hiding this comment

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

We'll probably want to rewrite some of this eventually, but for now since you're just copying from the existing README, it's probably fine to keep as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my thinking too. It will be a team effort and we'll probably need to set time aside before the new docs system "goes live". For now, I just wanted to add somewhere to house core's documentation.


Most of the existing core functionality is still spread over "legacy" Kibana and it will take some time to upgrade it.
Kibana is started using existing "legacy" CLI that bootstraps `core` which in turn creates the "legacy" Kibana server.
At the moment `core` manages HTTP connections, handles TLS configuration and base path proxy. All requests to Kibana server
will hit HTTP server exposed by the `core` first and it will decide whether request can be solely handled by the new
platform or request should be proxied to the "legacy" Kibana. This setup allows `core` to gradually introduce any "pre-route"
processing logic, expose new routes or replace old ones handled by the "legacy" Kibana currently.

Once config has been loaded and some of its parts were validated by the `core` it's passed to the "legacy" Kibana where
it will be additionally validated so that we can make config validation stricter with the new config validation system.
Even though the new validation system provided by the `core` is also based on Joi internally it is complemented with custom
rules tailored to our needs (e.g. `byteSize`, `duration` etc.). That means that config values that were previously accepted
by the "legacy" Kibana may be rejected by the `core` now.

### Logging
`core` has its own <DocLink id="kibCoreLogging" text="logging system"/> and will output log records directly (e.g. to file or terminal) when configured. When no specific configuration is provided, logs are forwarded to the "legacy" Kibana so that they look the same as the rest of the
log records throughout Kibana.

8 changes: 4 additions & 4 deletions src/core/CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ export class MyPlugin implements Plugin {
}
```

Prefer the pattern shown above, using `core.getStartServices()`, rather than store local references retrieved from `start`.
Prefer the pattern shown above, using `core.getStartServices()`, rather than store local references retrieved from `start`.

**Bad:**
```ts
export class MyPlugin implements Plugin {
// Anti pattern
private coreStart?: CoreStart;
private depsStart?: DepsStart;
private depsStart?: DepsStart;

public setup(core) {
core.application.register({
Expand All @@ -220,7 +220,7 @@ export class MyPlugin implements Plugin {
return renderApp(this.coreStart, this.depsStart, params);
}
});
}
}

public start(core, deps) {
// Anti pattern
Expand Down Expand Up @@ -361,5 +361,5 @@ Migration example from the legacy format is available in `src/core/MIGRATION_EXA

### Naming conventions

Export start and setup contracts as `MyPluginStart` and `MyPluginSetup`.
Export start and setup contracts as `MyPluginStart` and `MyPluginSetup`.
This avoids naming clashes, if everyone exported them simply as `Start` and `Setup`.
16 changes: 8 additions & 8 deletions src/core/CORE_CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ area of Core API's and does not apply to internal types.

- 1.1 All API types must be exported from the top-level `server` or `public`
directories.

```ts
// -- good --
import { IRouter } from 'src/core/server';

// -- bad --
import { IRouter } from 'src/core/server/http/router.ts';
```

> Why? This is required for generating documentation from our inline
> typescript doc comments, makes it easier for API consumers to find the
> relevant types and creates a clear distinction between external and
> internal types.

- 1.2 Classes must not be exposed directly. Instead, use a separate type,
prefixed with an 'I', to describe the public contract of the class.

```ts
// -- good (alternative 1) --
/**
Expand Down Expand Up @@ -66,27 +66,27 @@ area of Core API's and does not apply to internal types.
```

> Why? Classes' private members form part of their type signature making it
> impossible to mock a dependency typed as a `class`.
> impossible to mock a dependency typed as a `class`.
>
> Until we can use ES private field support in Typescript 3.8
> https://github.com/elastic/kibana/issues/54906 we have two alternatives
> each with their own pro's and cons:
>
> #### Using a derived class (alternative 1)
>
>
> Pro's:
> - TSDoc comments are located with the source code
> - The class acts as a single source of type information
>
> Con's:
> - "Go to definition" first takes you to where the type gets derived
> requiring a second "Go to definition" to navigate to the type source.
>
>
> #### Using a separate interface (alternative 2)
> Pro's:
> - Creates an explicit external API contract
> - "Go to definition" will take you directly to the type definition.
>
>
> Con's:
> - TSDoc comments are located with the interface not next to the
> implementation source code.
Expand Down
10 changes: 5 additions & 5 deletions src/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Core Plugin API Documentation:
- [Conventions for Plugins](./CONVENTIONS.md)
- [Testing Kibana Plugins](./TESTING.md)
- [Kibana Platform Plugin API](./docs/developer/architecture/kibana-platform-plugin-api.asciidoc )

Internal Documentation:
- [Saved Objects Migrations](./server/saved_objects/migrations/README.md)

Expand All @@ -18,18 +18,18 @@ Internal Documentation:
Most of the existing core functionality is still spread over "legacy" Kibana and it will take some time to upgrade it.
Kibana is started using existing "legacy" CLI that bootstraps `core` which in turn creates the "legacy" Kibana server.
At the moment `core` manages HTTP connections, handles TLS configuration and base path proxy. All requests to Kibana server
will hit HTTP server exposed by the `core` first and it will decide whether request can be solely handled by the new
will hit HTTP server exposed by the `core` first and it will decide whether request can be solely handled by the new
platform or request should be proxied to the "legacy" Kibana. This setup allows `core` to gradually introduce any "pre-route"
processing logic, expose new routes or replace old ones handled by the "legacy" Kibana currently.

Once config has been loaded and some of its parts were validated by the `core` it's passed to the "legacy" Kibana where
Once config has been loaded and some of its parts were validated by the `core` it's passed to the "legacy" Kibana where
it will be additionally validated so that we can make config validation stricter with the new config validation system.
Even though the new validation system provided by the `core` is also based on Joi internally it is complemented with custom
Even though the new validation system provided by the `core` is also based on Joi internally it is complemented with custom
rules tailored to our needs (e.g. `byteSize`, `duration` etc.). That means that config values that were previously accepted
by the "legacy" Kibana may be rejected by the `core` now.

### Logging
`core` has its own [logging system](./server/logging/README.mdx) and will output log records directly (e.g. to file or terminal) when configured. When no
`core` has its own [logging system](./server/logging/README.mdx) and will output log records directly (e.g. to file or terminal) when configured. When no
specific configuration is provided, logs are forwarded to the "legacy" Kibana so that they look the same as the rest of the
log records throughout Kibana.

Expand Down