Remove shared environment code & documentation
Signed-off-by: Philipp Hugenroth <philipph@spotify.com>
This commit is contained in:
@@ -37,4 +37,4 @@ At a high level, when you call `createBackend`, it will create a new backend ins
|
||||
|
||||
Underneath the hood, `createBackend` calls `createSpecializedBackend` from `@backstage/backend-app-api` which is responsible for actually creating the backend instance, but with no services or no features. You can think of `createBackend` more of a 'batteries included' approach, and `createSpecializedBackend` a little more low level.
|
||||
|
||||
As mentioned previously there's also the ability to create multiple of these backends in your project so that you can split apart your backend and deploy different backends that can scale independently of each other. For instance you might choose to deploy a backend with only the catalog plugin enabled, and one with just the scaffolder plugin enabled. We've provided some tools to be able to share services and defaults across your backend system, and you can find out more about that in the [shared environments docs](../building-backends/01-index.md#shared-environments).
|
||||
As mentioned previously there's also the ability to create multiple of these backends in your project so that you can split apart your backend and deploy different backends that can scale independently of each other. For instance you might choose to deploy a backend with only the catalog plugin enabled, and one with just the scaffolder plugin enabled.
|
||||
|
||||
@@ -148,35 +148,3 @@ backend.start();
|
||||
```
|
||||
|
||||
We've now split the backend into two separate deployments, but we still need to make sure that they can communicate with each other. This is the hard and somewhat tedious part, as Backstage currently doesn't provide an out of the box solution that solves this. You'll need to manually configure the two backends with custom implementations of the `DiscoveryService` and have them return the correct URLs for each other. Likewise, you'll also need to provide a custom implementation of the `DiscoveryApi` in the frontend, unless you surface the two backends via a proxy that handles the routing instead.
|
||||
|
||||
### Shared Environments
|
||||
|
||||
To make it a bit easier to manage multiple backends, it's possible to create a shared environment that can be used across multiple backends. You would typically house it in a separate package that can be referenced by backends in your monorepo, or published to a package registry for broader use.
|
||||
|
||||
A shared environment contains a set of service implementations that should be used across all backends. These services will override the default ones, but if a service is provided directly to the backend, it will override the one in the shared environment.
|
||||
|
||||
A shared environment is defined using `createSharedEnvironment`. In this example we place it in a new and separate package called `backend-env`:
|
||||
|
||||
```ts
|
||||
// packages/backend-env/src/index.ts
|
||||
import { createSharedEnvironment } from '@backstage/backend-plugin-api';
|
||||
import { customDiscoveryServiceFactory } from './customDiscoveryServiceFactory';
|
||||
|
||||
export const env = createSharedEnvironment({
|
||||
services: [
|
||||
customDiscoveryServiceFactory(), // custom DiscoveryService implementation
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
And passed on to backends using the `env` option:
|
||||
|
||||
```ts
|
||||
// packages/backend-b/src/index.ts, imports omitted
|
||||
import { env } from '@internal/backend-env';
|
||||
|
||||
const backend = createBackend({ env });
|
||||
|
||||
backend.add(scaffolderPlugin());
|
||||
backend.start();
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user