+4
-2
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FilterPredicate } from '@backstage/filter-predicates';
|
||||
|
||||
export interface Config {
|
||||
events?: {
|
||||
modules?: {
|
||||
@@ -96,7 +98,7 @@ export interface Config {
|
||||
* 'message.data.action': { $in: ['created', 'deleted'] }
|
||||
* ```
|
||||
*/
|
||||
filter?: object;
|
||||
filter?: FilterPredicate;
|
||||
|
||||
/**
|
||||
* Pub/Sub message attributes are by default copied to the event
|
||||
@@ -190,7 +192,7 @@ export interface Config {
|
||||
* 'event.eventPayload.action': { $in: ['created', 'deleted'] }
|
||||
* ```
|
||||
*/
|
||||
filter?: object;
|
||||
filter?: FilterPredicate;
|
||||
|
||||
/**
|
||||
* Event metadata fields are by default copied to the Pub/Sub
|
||||
|
||||
+9
-1
@@ -19,7 +19,9 @@ import {
|
||||
RootConfigService,
|
||||
RootLifecycleService,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { ForwardedError } from '@backstage/errors';
|
||||
import { EventParams, EventsService } from '@backstage/plugin-events-node';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { Message, PubSub, Subscription } from '@google-cloud/pubsub';
|
||||
import { Counter, metrics } from '@opentelemetry/api';
|
||||
import { readSubscriptionTasksFromConfig } from './config';
|
||||
@@ -197,7 +199,13 @@ export class GooglePubSubConsumingEventPublisher {
|
||||
message: Message,
|
||||
task: SubscriptionTask,
|
||||
): EventParams | undefined {
|
||||
const eventPayload = JSON.parse(message.data.toString());
|
||||
let eventPayload: JsonValue;
|
||||
try {
|
||||
eventPayload = JSON.parse(message.data.toString());
|
||||
} catch (error) {
|
||||
throw new ForwardedError('Payload was not valid JSON', error);
|
||||
}
|
||||
|
||||
const attributes = message.attributes;
|
||||
|
||||
const context: MessageContext = {
|
||||
|
||||
Reference in New Issue
Block a user