Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pubsub publisher #120

Merged
merged 24 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 19 additions & 0 deletions .dev/pubsub/samplePubsubPublisher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { PubSub } from "@google-cloud/pubsub";
jkoenig134 marked this conversation as resolved.
Show resolved Hide resolved

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 x = await topic.publishMessage({ json: { foo: "bar" }, attributes: { namespace: "test" } });
console.log(x);
}

run();
28 changes: 28 additions & 0 deletions .dev/pubsub/samplePubsubReader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { PubSub } from "@google-cloud/pubsub";
jkoenig134 marked this conversation as resolved.
Show resolved Hide resolved

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 subscription = topic.subscription(process.env.PUBSUB_SUBSCRIPTION_NAME!);
const subscriptionExists = (await subscription.exists())[0];
if (!subscriptionExists) throw new Error(`Subscription ${topicName} 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
Loading