Skip to content

Commit 7f96793

Browse files
Allow multi-app connections (#851)
## Summary <!-- Succinctly describe your change, providing context, what you've changed, and why. --> ## Checklist <!-- Tick these items off as you progress. --> <!-- If an item isn't applicable, ideally please strikeout the item by wrapping it in "~~"" and suffix it with "N/A My reason for skipping this." --> <!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" --> - [x] Added a [docs PR](https://github.com/inngest/website) that references this PR - [x] Added unit/integration tests - [x] Added changesets if applicable ## Related <!-- A space for any related links, issues, or PRs. --> <!-- Linear issues are autolinked. --> <!-- e.g. - INN-123 --> <!-- GitHub issues/PRs can be linked using shorthand. --> <!-- e.g. "- inngest/inngest#123" --> <!-- Feel free to remove this section if there are no applicable related links.--> - INN-
1 parent b50793c commit 7f96793

File tree

6 files changed

+855
-493
lines changed

6 files changed

+855
-493
lines changed

.changeset/seven-students-remember.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"inngest": patch
3+
---
4+
5+
Connect: Allow multi-app connections

examples/connect-example/index.ts

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,63 @@ import { connect } from "inngest/connect";
33

44
console.log("Starting up worker with pid", process.pid);
55

6-
const inngest = new Inngest({
7-
id: "my-connect-js-app",
6+
const app1 = new Inngest({
7+
id: "my-connect-js-app-1",
8+
eventKey: "abc123",
9+
appVersion: "v1.0",
10+
});
11+
12+
const app2 = new Inngest({
13+
id: "my-connect-js-app-2",
814
eventKey: "abc123",
915
appVersion: "v1.0",
1016
});
1117

1218
console.log("Connecting...");
1319

1420
connect({
15-
inngest,
16-
functions: [
17-
inngest.createFunction(
18-
{ id: "test-function" },
19-
{ event: "connect-demo/test" },
20-
async ({ step }) => {
21-
await step.run("test", async () => {
22-
console.log("via connect!");
23-
await new Promise((resolve) => setTimeout(resolve, 10000));
24-
console.log("function done");
25-
return "this works";
26-
});
27-
}
28-
),
21+
apps: [
22+
{
23+
client: app1,
24+
functions: [
25+
app1.createFunction(
26+
{ id: "test-function" },
27+
{ event: "connect-demo/test" },
28+
async ({ step }) => {
29+
await step.run("test", async () => {
30+
console.log("via connect!");
31+
await new Promise((resolve) => setTimeout(resolve, 10000));
32+
console.log("function done");
33+
return "this works";
34+
});
35+
}
36+
),
37+
app1.createFunction(
38+
{ id: "hello-world" },
39+
{ event: "connect-demo/hello-world" },
40+
async ({ step }) => {
41+
return { success: true };
42+
}
43+
),
44+
],
45+
},
46+
{
47+
client: app2,
48+
functions: [
49+
app2.createFunction(
50+
{ id: "hello-world" },
51+
{ event: "connect-demo/hello-world" },
52+
async ({ step }) => {
53+
return { success: true };
54+
}
55+
),
56+
],
57+
},
2958
],
3059
instanceId: "my-worker",
31-
signingKey: "signkey-test-12345678",
32-
signingKeyFallback: "signkey-test-00000000",
33-
// baseUrl: "http://127.0.0.1:8288",
60+
rewriteGatewayEndpoint: (endpoint) => {
61+
return endpoint.replace("connect-gateway:8080", "localhost:8100");
62+
},
3463
}).then(async (conn) => {
3564
console.log("Connected!");
3665

0 commit comments

Comments
 (0)