Merge pull request #22146 from Bonial-International-GmbH/pjungermann/new-backend/events
new backend system: default exports for some event modules + docs
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/plugin-events-backend-module-bitbucket-cloud': patch
|
||||
'@backstage/plugin-events-backend-module-gerrit': patch
|
||||
'@backstage/plugin-events-backend-module-azure': patch
|
||||
---
|
||||
|
||||
Add default exports for the new backend system and documentation.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-events-backend-module-aws-sqs': patch
|
||||
'@backstage/plugin-events-backend': patch
|
||||
---
|
||||
|
||||
Add documentation on how to install the plugins with the new backend system.
|
||||
@@ -40,3 +40,7 @@ events:
|
||||
# From your Backstage root directory
|
||||
yarn add --cwd packages/backend @backstage/plugin-events-backend-module-aws-sqs
|
||||
```
|
||||
|
||||
```ts title="packages/backend/src/index.ts"
|
||||
backend.add(import('@backstage/plugin-events-backend-module-aws-sqs/alpha'));
|
||||
```
|
||||
|
||||
@@ -31,6 +31,14 @@ Install this module:
|
||||
yarn add --cwd packages/backend @backstage/plugin-events-backend-module-azure
|
||||
```
|
||||
|
||||
### Add to backend
|
||||
|
||||
```ts title="packages/backend/src/index.ts"
|
||||
backend.add(import('@backstage/plugin-events-backend-module-azure/alpha'));
|
||||
```
|
||||
|
||||
### Add to backend (old)
|
||||
|
||||
Add the event router to the `EventsBackend` instance in `packages/backend/src/plugins/events.ts`:
|
||||
|
||||
```diff
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
|
||||
// @alpha
|
||||
export const eventsModuleAzureDevOpsEventRouter: () => BackendFeature;
|
||||
const eventsModuleAzureDevOpsEventRouter: () => BackendFeature;
|
||||
export default eventsModuleAzureDevOpsEventRouter;
|
||||
export { eventsModuleAzureDevOpsEventRouter };
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -15,3 +15,4 @@
|
||||
*/
|
||||
|
||||
export { eventsModuleAzureDevOpsEventRouter } from './service/eventsModuleAzureDevOpsEventRouter';
|
||||
export { eventsModuleAzureDevOpsEventRouter as default } from './service/eventsModuleAzureDevOpsEventRouter';
|
||||
|
||||
@@ -31,6 +31,16 @@ Install this module:
|
||||
yarn add --cwd packages/backend @backstage/plugin-events-backend-module-bitbucket-cloud
|
||||
```
|
||||
|
||||
### Add to backend
|
||||
|
||||
```ts title="packages/backend/src/index.ts"
|
||||
backend.add(
|
||||
import('@backstage/plugin-events-backend-module-bitbucket-cloud/alpha'),
|
||||
);
|
||||
```
|
||||
|
||||
### Add to backend (old)
|
||||
|
||||
Add the event router to the `EventsBackend` instance in `packages/backend/src/plugins/events.ts`:
|
||||
|
||||
```diff
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
|
||||
// @alpha
|
||||
export const eventsModuleBitbucketCloudEventRouter: () => BackendFeature;
|
||||
const eventsModuleBitbucketCloudEventRouter: () => BackendFeature;
|
||||
export default eventsModuleBitbucketCloudEventRouter;
|
||||
export { eventsModuleBitbucketCloudEventRouter };
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -15,3 +15,4 @@
|
||||
*/
|
||||
|
||||
export { eventsModuleBitbucketCloudEventRouter } from './service/eventsModuleBitbucketCloudEventRouter';
|
||||
export { eventsModuleBitbucketCloudEventRouter as default } from './service/eventsModuleBitbucketCloudEventRouter';
|
||||
|
||||
@@ -30,6 +30,14 @@ Install this module:
|
||||
yarn add --cwd packages/backend @backstage/plugin-events-backend-module-gerrit
|
||||
```
|
||||
|
||||
### Add to backend
|
||||
|
||||
```ts title="packages/backend/src/index.ts"
|
||||
backend.add(import('@backstage/plugin-events-backend-module-gerrit/alpha'));
|
||||
```
|
||||
|
||||
### Add to backend (old)
|
||||
|
||||
Add the event router to the `EventsBackend` instance in `packages/backend/src/plugins/events.ts`:
|
||||
|
||||
```diff
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
|
||||
// @alpha
|
||||
export const eventsModuleGerritEventRouter: () => BackendFeature;
|
||||
const eventsModuleGerritEventRouter: () => BackendFeature;
|
||||
export default eventsModuleGerritEventRouter;
|
||||
export { eventsModuleGerritEventRouter };
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -15,3 +15,4 @@
|
||||
*/
|
||||
|
||||
export { eventsModuleGerritEventRouter } from './service/eventsModuleGerritEventRouter';
|
||||
export { eventsModuleGerritEventRouter as default } from './service/eventsModuleGerritEventRouter';
|
||||
|
||||
@@ -24,7 +24,15 @@ to the used event broker.
|
||||
yarn add --cwd packages/backend @backstage/plugin-events-backend @backstage/plugin-events-node
|
||||
```
|
||||
|
||||
### Event Broker
|
||||
### Add to backend
|
||||
|
||||
```ts title="packages/backend/src/index.ts"
|
||||
backend.add(import('@backstage/plugin-events-backend/alpha'));
|
||||
```
|
||||
|
||||
### Add to backend (old)
|
||||
|
||||
#### Event Broker
|
||||
|
||||
First you will need to add and implementation of the `EventBroker` interface to the backend plugin environment.
|
||||
This will allow event broker instance any backend plugins to publish and subscribe to events in order to communicate
|
||||
@@ -44,7 +52,7 @@ Then update plugin environment to include the event broker.
|
||||
+ eventBroker: EventBroker;
|
||||
```
|
||||
|
||||
### Publishing and Subscribing to events with the broker
|
||||
#### Publishing and Subscribing to events with the broker
|
||||
|
||||
Backend plugins are passed the event broker in the plugin environment at startup of the application. The plugin can
|
||||
make use of this to communicate between parts of the application.
|
||||
@@ -80,27 +88,27 @@ export default async function createPlugin(
|
||||
}
|
||||
```
|
||||
|
||||
### Implementing an `EventSubscriber` class
|
||||
#### Implementing an `EventSubscriber` class
|
||||
|
||||
More complex solutions might need the creation of a class that implements the `EventSubscriber` interface. e.g.
|
||||
|
||||
```typescript jsx
|
||||
import { EventSubscriber } from "./EventSubscriber";
|
||||
import { EventSubscriber } from './EventSubscriber';
|
||||
|
||||
class ExampleSubscriber implements EventSubscriber {
|
||||
...
|
||||
// ...
|
||||
|
||||
supportsEventTopics() {
|
||||
return ['publish.example']
|
||||
return ['publish.example'];
|
||||
}
|
||||
|
||||
async onEvent(params: EventParams) {
|
||||
env.logger.info(`receieved ${params.topic} event`)
|
||||
env.logger.info(`receieved ${params.topic} event`);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Events Backend
|
||||
#### Events Backend
|
||||
|
||||
The events backend plugin provides a router to handler http events and publish the http requests onto the event
|
||||
broker.
|
||||
|
||||
Reference in New Issue
Block a user