Skip to content

Commit

Permalink
chore: PubSub naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoenig134 committed Nov 21, 2023
1 parent 3949b65 commit a79cf85
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .dev/pubsub/samplePubsubPublisher.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PubSub } from "@google-cloud/pubsub";

const pubsub = new PubSub({
const pubSub = new PubSub({
projectId: process.env.PUBSUB_PROJECT_ID,
keyFile: process.env.PUBSUB_KEY_FILE
});

async function run() {
const topicName = process.env.PUBSUB_TOPIC_NAME;
const topic = pubsub.topic(topicName!);
const topic = pubSub.topic(topicName!);

const topicExists = (await topic.exists())[0];
if (!topicExists) throw new Error(`Topic ${topicName} does not exist.`);
Expand Down
4 changes: 2 additions & 2 deletions .dev/pubsub/samplePubsubReader.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PubSub } from "@google-cloud/pubsub";

const pubsub = new PubSub({
const pubSub = new PubSub({
projectId: process.env.PUBSUB_PROJECT_ID,
keyFile: process.env.PUBSUB_KEY_FILE
});

async function run() {
const topicName = process.env.PUBSUB_TOPIC_NAME;
const topic = pubsub.topic(topicName!);
const topic = pubSub.topic(topicName!);

const topicExists = (await topic.exists())[0];
if (!topicExists) throw new Error(`Topic ${topicName} does not exist.`);
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 3.6.0

- new module: 'pubsubPublisher' (see https://enmeshed.eu/operate/configuration#pubsubPublisher for more details on how to configure it)
- new module: 'PubSubPublisher' (see https://enmeshed.eu/operate/configuration#PubSubPublisher for more details on how to configure it)
- upgrade the runtime version to 2.10.0

## 3.5.6
Expand Down
4 changes: 2 additions & 2 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
"displayName": "AMQP Publisher",
"location": "amqpPublisher/AMQPPublisherModule"
},
"pubsubPublisher": {
"PubSubPublisher": {
"enabled": false,
"displayName": "PubSub Publisher",
"location": "pubsubPublisher/PubsubPublisherModule",
"location": "pubSubPublisher/PubSubPublisherModule",
"projectId": "",
"topic": "",
"keyFile": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ import { DataEvent, Event } from "@js-soft/ts-utils";
import { DataEvent as RuntimeDataEvent } from "@nmshd/runtime";
import { ConnectorRuntimeModule, ConnectorRuntimeModuleConfiguration } from "../../ConnectorRuntimeModule";

export interface PubsubPublisherModuleConfiguration extends ConnectorRuntimeModuleConfiguration {
export interface PubSubPublisherModuleConfiguration extends ConnectorRuntimeModuleConfiguration {
projectId: string;
topicName: string;
keyFile: string;
}

export default class PubsubPublisherModule extends ConnectorRuntimeModule<PubsubPublisherModuleConfiguration> {
private pubsub: PubSub;
export default class PubSubPublisherModule extends ConnectorRuntimeModule<PubSubPublisherModuleConfiguration> {
private pubSub: PubSub;
private topic: Topic;

public async init(): Promise<void> {
if (!this.configuration.projectId) throw new Error("Cannot start the module, the projectId is not defined.");
if (!this.configuration.topicName) throw new Error("Cannot start the module, the topic is not defined.");
if (!this.configuration.keyFile) throw new Error("Cannot start the module, the keyFile is not defined.");

this.pubsub = new PubSub({
this.pubSub = new PubSub({
projectId: this.configuration.projectId,
keyFile: this.configuration.keyFile
});

this.topic = this.pubsub.topic(this.configuration.topicName);
this.topic = this.pubSub.topic(this.configuration.topicName);
this.logger.info("Checking if topic exists...");

const topicExists = (await this.topic.exists())[0];
Expand All @@ -49,6 +49,6 @@ export default class PubsubPublisherModule extends ConnectorRuntimeModule<Pubsub
public async stop(): Promise<void> {
this.unsubscribeFromAllEvents();

await this.pubsub.close().catch((e) => this.logger.error("Could not close the pubsub", e));
await this.pubSub.close().catch((e) => this.logger.error("Could not close the PubSub object", e));
}
}

0 comments on commit a79cf85

Please sign in to comment.