Skip to content

Commit

Permalink
Feature/pubsub publisher (#120)
Browse files Browse the repository at this point in the history
* feat: implement pubsub

* feat: add the module

* chore: simplify

* chore: bump libs

* chore: remove emulator host

* chore: remove falsy this.

* chore: lowercase ro

* chore: update default config

* chore: remove options

* chore: version bump

* refactor: update docs links

* chore: bump libs

* chore: PubSub naming

* chore: update messages

* chore: filenames

* chore: lowercase anchor

* chore: remove publisher dev script

* chore: 's

* chore: 's
  • Loading branch information
jkoenig134 authored Nov 21, 2023
1 parent 8472f84 commit 7ce4748
Show file tree
Hide file tree
Showing 14 changed files with 1,079 additions and 15,010 deletions.
4 changes: 2 additions & 2 deletions .dev/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- transportLibrary__platformClientSecret
volumes:
- ..:/usr/app
- ./config.json:/config.json:RO
- ./config.json:/config.json:ro
depends_on:
- mongo
- mongo-express
Expand All @@ -41,7 +41,7 @@ services:
- transportLibrary__platformClientSecret
volumes:
- ..:/usr/app
- ./config.json:/config.json:RO
- ./config.json:/config.json:ro
depends_on:
- mongo
- mongo-express
Expand Down
2 changes: 1 addition & 1 deletion .dev/mq/sampleMQReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ async function run() {
const connection = await rabbit.connect("amqp://localhost");
const channel = await connection.createChannel();

await this.channel.assertExchange("nmshd", "fanout");
await channel.assertExchange("nmshd", "fanout");

const queueName = "myQueue";

Expand Down
29 changes: 29 additions & 0 deletions .dev/pubSub/samplePubSubReader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { PubSub } from "@google-cloud/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 topicExists = (await topic.exists())[0];
if (!topicExists) throw new Error(`Topic '${topicName}' does not exist.`);

const subscriptionName = process.env.PUBSUB_SUBSCRIPTION_NAME!;
const subscription = topic.subscription(subscriptionName);
const subscriptionExists = (await subscription.exists())[0];
if (!subscriptionExists) throw new Error(`Subscription '${subscriptionName}' does not exist.`);

subscription.on("message", (message) => {
console.log(message.id);
console.log(message.data.toString());
console.log(message.attributes);

message.ack();
});
}

run();
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.6.0

- 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

-> SDK 2.2.4
Expand Down Expand Up @@ -42,8 +47,8 @@
-> SDK 2.2.2

- upgrade the runtime version to 2.6.1
- support for the new [FreeTextRequestItem](https://enmeshed.eu/integrate/data-model-request-items#freetextrequestitem)
- support for the AttributeValue [Statement](https://enmeshed.eu/integrate/data-model-attribute-values#statement)
- support for the new [FreeTextRequestItem](https://enmeshed.eu/integrate/requests-and-requestitems#freetextrequestitem)
- support for the AttributeValue [Statement](https://enmeshed.eu/integrate/attribute-values#statement)

## 3.4.0

Expand Down Expand Up @@ -179,7 +184,7 @@

## 3.0.4

- upgrade the runtime to version 2.0.1 ([`ProprietaryJSON`](https://enmeshed.eu/integrate/data-model-attribute-values#proprietaryjson) AttributeValueType)
- upgrade the runtime to version 2.0.1 ([`ProprietaryJSON`](https://enmeshed.eu/integrate/attribute-values#proprietaryjson) AttributeValueType)

## 3.0.3

Expand Down Expand Up @@ -252,7 +257,7 @@

## 2.3.0

- new module: 'webhooksV2' (see https://enmeshed.eu/integrate/connector-configuration#webhooksV2 for more details on how to configure it)
- new module: 'webhooksV2' (see https://enmeshed.eu/operate/configuration#webhooksV2 for more details on how to configure it)
- the 'webhooks' module is now deprecated

## 2.2.1
Expand Down
8 changes: 8 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
"enabled": false,
"displayName": "AMQP Publisher",
"location": "amqpPublisher/AMQPPublisherModule"
},
"PubSubPublisher": {
"enabled": false,
"displayName": "PubSub Publisher",
"location": "pubSubPublisher/PubSubPublisherModule",
"projectId": "",
"topic": "",
"keyFile": ""
}
}
}
2 changes: 1 addition & 1 deletion helmChart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Documentation

You can find a more detailed documentation [in the enmeshed docs](https://enmeshed.eu/integrate/helm-chart).
You can find a more detailed documentation [in the enmeshed docs](https://enmeshed.eu/operate/setup-with-helm-charts).

## Usage

Expand Down
4 changes: 2 additions & 2 deletions helmChart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ image:
tag: ""

# a json or yaml config
# see https://enmeshed.eu/integrate/connector-configuration for configuration options
# see https://enmeshed.eu/operate/configuration for configuration options
config:
logging:
appenders:
Expand All @@ -30,7 +30,7 @@ pod:

connector:
# a list of environment variables
# see https://enmeshed.eu/integrate/connector-configuration for configuration options
# see https://enmeshed.eu/operate/configuration for configuration options
# can be used for secrets
# see https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#environment-variables
environment: []
Expand Down
Loading

0 comments on commit 7ce4748

Please sign in to comment.