-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
// See docs/examples/telemetry/README.md for full documentation on telemetry, including using the IPC | ||
// - Pin this to the latest version of pup, or include in import map | ||
import { PupTelemetry } from "jsr:@pup/pup-telemetry" | ||
const telemetry = new PupTelemetry(1) | ||
import { PupTelemetry } from "jsr:@pup/telemetry"; | ||
const telemetry = new PupTelemetry(1); | ||
|
||
// The task | ||
let i = 0 | ||
console.log("Task running") | ||
let i = 0; | ||
console.log("Task running"); | ||
|
||
// Send data every 5th second | ||
setInterval(() => { | ||
i += 1 | ||
i += 1; | ||
telemetry.emit( | ||
"task-2", | ||
"message", | ||
`${Deno.env.get("PUP_PROCESS_ID")} sending "Hello" to 'task-2', iteration ${i}`, | ||
) | ||
}, 2000) | ||
`${ | ||
Deno.env.get("PUP_PROCESS_ID") | ||
} sending "Hello" to 'task-2', iteration ${i}`, | ||
); | ||
}, 2000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// See docs/examples/telemetry/README.md for full documentation on telemetry, including using the IPC | ||
// - Pin this to the latest version of pup, or include in import map | ||
import { PupTelemetry } from "jsr:@pup/telemetry" | ||
const telemetry = new PupTelemetry(1) | ||
import { PupTelemetry } from "jsr:@pup/telemetry"; | ||
const telemetry = new PupTelemetry(1); | ||
|
||
// The task | ||
console.log("Process running") | ||
console.log("Process running"); | ||
|
||
// Receive data | ||
// deno-lint-ignore no-explicit-any | ||
telemetry.on("message", (data: any) => { | ||
console.log(`task-2 received: ${data}`) | ||
}) | ||
console.log(`task-2 received: ${data}`); | ||
}); | ||
|
||
// Wait 5 minutes | ||
setTimeout(() => { | ||
console.log("Done!") | ||
}, 300_000) | ||
console.log("Done!"); | ||
}, 300_000); |