docs(events): update docs about events-backend used with the new backend system

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
Patrick Jungermann
2024-01-23 22:36:52 +01:00
parent 52479092dc
commit 3c5f58622e
@@ -632,7 +632,7 @@ A basic installation of the events plugin looks as follows.
```ts title="packages/backend/src/index.ts"
const backend = createBackend();
/* highlight-add-next-line */
backend.add(import('@backstage/plugin-events-backend'));
backend.add(import('@backstage/plugin-events-backend/alpha'));
```
If you have other customizations made to `plugins/events.ts`, such as adding
@@ -646,6 +646,7 @@ depends on the appropriate extension point and interacts with it.
```ts title="packages/backend/src/index.ts"
/* highlight-add-start */
import { eventsServiceRef } from '@backstage/plugin-events-node';
import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha';
import { createBackendModule } from '@backstage/backend-plugin-api';
/* highlight-add-end */
@@ -663,7 +664,28 @@ const eventsModuleCustomExtensions = createBackendModule({
async init({ events /* ..., other dependencies */ }) {
// Here you have the opportunity to interact with the extension
// point before the plugin itself gets instantiated
events.addSubscribers(new MySubscriber()); // just an example
events.addHttpPostIngress({
// ...
});
},
});
},
});
/* highlight-add-end */
/* highlight-add-start */
const otherPluginModuleCustomExtensions = createBackendModule({
pluginId: 'other-plugin', // name of the plugin that the module is targeting
moduleId: 'custom-extensions',
register(env) {
env.registerInit({
deps: {
events: eventsServiceRef,
// ... and other dependencies as needed
},
async init({ events /* ..., other dependencies */ }) {
// Here you have the opportunity to interact with the extension
// point before the plugin itself gets instantiated
},
});
},
@@ -671,17 +693,11 @@ const eventsModuleCustomExtensions = createBackendModule({
/* highlight-add-end */
const backend = createBackend();
backend.add(import('@backstage/plugin-events-backend'));
backend.add(import('@backstage/plugin-events-backend/alpha'));
/* highlight-add-next-line */
backend.add(eventsModuleCustomExtensions());
```
This also requires that you have a dependency on the corresponding node package,
if you didn't already have one.
```bash
# from the repository root
yarn --cwd packages/backend add @backstage/plugin-events-node
/* highlight-add-next-line */
backend.add(otherPluginModuleCustomExtensions());
```
Here we've placed the module directly in the backend index file just to get