@backstage/plugin-events-backend 0.2.18-next.2 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +18 -8
- package/alpha/package.json +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend
|
|
2
2
|
|
|
3
|
+
## 0.2.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 92ea615: Update `README.md`
|
|
8
|
+
- d5ddc4e: Add documentation on how to install the plugins with the new backend system.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/backend-common@0.20.1
|
|
11
|
+
- @backstage/backend-plugin-api@0.6.9
|
|
12
|
+
- @backstage/config@1.1.1
|
|
13
|
+
- @backstage/plugin-events-node@0.2.18
|
|
14
|
+
|
|
3
15
|
## 0.2.18-next.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -24,7 +24,15 @@ to the used event broker.
|
|
|
24
24
|
yarn add --cwd packages/backend @backstage/plugin-events-backend @backstage/plugin-events-node
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
###
|
|
27
|
+
### Add to backend
|
|
28
|
+
|
|
29
|
+
```ts title="packages/backend/src/index.ts"
|
|
30
|
+
backend.add(import('@backstage/plugin-events-backend/alpha'));
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Add to backend (old)
|
|
34
|
+
|
|
35
|
+
#### Event Broker
|
|
28
36
|
|
|
29
37
|
First you will need to add and implementation of the `EventBroker` interface to the backend plugin environment.
|
|
30
38
|
This will allow event broker instance any backend plugins to publish and subscribe to events in order to communicate
|
|
@@ -34,6 +42,7 @@ Add the following to `makeCreateEnv`
|
|
|
34
42
|
|
|
35
43
|
```diff
|
|
36
44
|
// packages/backend/src/index.ts
|
|
45
|
+
+ import { DefaultEventBroker } from '@backstage/plugin-events-backend';
|
|
37
46
|
+ const eventBroker = new DefaultEventBroker(root.child({ type: 'plugin' }));
|
|
38
47
|
```
|
|
39
48
|
|
|
@@ -41,10 +50,11 @@ Then update plugin environment to include the event broker.
|
|
|
41
50
|
|
|
42
51
|
```diff
|
|
43
52
|
// packages/backend/src/types.ts
|
|
53
|
+
+ import { EventBroker } from '@backstage/plugin-events-node';
|
|
44
54
|
+ eventBroker: EventBroker;
|
|
45
55
|
```
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
#### Publishing and Subscribing to events with the broker
|
|
48
58
|
|
|
49
59
|
Backend plugins are passed the event broker in the plugin environment at startup of the application. The plugin can
|
|
50
60
|
make use of this to communicate between parts of the application.
|
|
@@ -80,27 +90,27 @@ export default async function createPlugin(
|
|
|
80
90
|
}
|
|
81
91
|
```
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
#### Implementing an `EventSubscriber` class
|
|
84
94
|
|
|
85
95
|
More complex solutions might need the creation of a class that implements the `EventSubscriber` interface. e.g.
|
|
86
96
|
|
|
87
97
|
```typescript jsx
|
|
88
|
-
import { EventSubscriber } from
|
|
98
|
+
import { EventSubscriber } from './EventSubscriber';
|
|
89
99
|
|
|
90
100
|
class ExampleSubscriber implements EventSubscriber {
|
|
91
|
-
...
|
|
101
|
+
// ...
|
|
92
102
|
|
|
93
103
|
supportsEventTopics() {
|
|
94
|
-
|
|
104
|
+
return ['publish.example'];
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
async onEvent(params: EventParams) {
|
|
98
|
-
env.logger.info(`receieved ${params.topic} event`)
|
|
108
|
+
env.logger.info(`receieved ${params.topic} event`);
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
111
|
```
|
|
102
112
|
|
|
103
|
-
|
|
113
|
+
#### Events Backend
|
|
104
114
|
|
|
105
115
|
The events backend plugin provides a router to handler http events and publish the http requests onto the event
|
|
106
116
|
broker.
|
package/alpha/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-backend",
|
|
3
|
-
"version": "0.2.18
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,20 +39,20 @@
|
|
|
39
39
|
"postpack": "backstage-cli package postpack"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@backstage/backend-common": "^0.20.1
|
|
43
|
-
"@backstage/backend-plugin-api": "^0.6.9
|
|
42
|
+
"@backstage/backend-common": "^0.20.1",
|
|
43
|
+
"@backstage/backend-plugin-api": "^0.6.9",
|
|
44
44
|
"@backstage/config": "^1.1.1",
|
|
45
|
-
"@backstage/plugin-events-node": "^0.2.18
|
|
45
|
+
"@backstage/plugin-events-node": "^0.2.18",
|
|
46
46
|
"@types/express": "^4.17.6",
|
|
47
47
|
"express": "^4.17.1",
|
|
48
48
|
"express-promise-router": "^4.1.0",
|
|
49
49
|
"winston": "^3.2.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@backstage/backend-common": "^0.20.1
|
|
53
|
-
"@backstage/backend-test-utils": "^0.2.10
|
|
54
|
-
"@backstage/cli": "^0.25.1
|
|
55
|
-
"@backstage/plugin-events-backend-test-utils": "^0.1.19
|
|
52
|
+
"@backstage/backend-common": "^0.20.1",
|
|
53
|
+
"@backstage/backend-test-utils": "^0.2.10",
|
|
54
|
+
"@backstage/cli": "^0.25.1",
|
|
55
|
+
"@backstage/plugin-events-backend-test-utils": "^0.1.19",
|
|
56
56
|
"supertest": "^6.1.3"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|