-
-
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
19 changed files
with
231 additions
and
96 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
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
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
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,4 +1,4 @@ | ||
FROM denoland/deno:debian-1.31.1 | ||
FROM denoland/deno:debian-1.42.4 | ||
|
||
# Copy application | ||
RUN mkdir /app | ||
|
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
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,20 +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 | ||
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) |
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { PluginConfiguration, PluginImplementation } from "@pup/plugin" | ||
|
||
/** | ||
* Internal representation of a plugin | ||
* - Used by @pup/pup internally! | ||
*/ | ||
export class Plugin { | ||
private config: PluginConfiguration | ||
private apiUrl: string | ||
private apiToken: string | ||
public impl?: PluginImplementation | ||
constructor(config: PluginConfiguration, apiUrl: string, apiToken: string) { | ||
this.config = config | ||
this.apiUrl = apiUrl | ||
this.apiToken = apiToken | ||
} | ||
/** | ||
* Will throw on any error | ||
*/ | ||
public async load() { | ||
const { PupPlugin } = await import(this.config.url) | ||
this.impl = new PupPlugin(this.config, this.apiUrl, this.apiToken) as PluginImplementation | ||
} | ||
public verify() { | ||
if (!this.impl || this.impl.meta.name === "unset") { | ||
throw new Error("Plugin missing meta.name") | ||
} | ||
if (!this.impl || this.impl.meta.repository === "unset") { | ||
throw new Error("Plugin missing meta.repository") | ||
} | ||
if (!this.impl || this.impl.meta.version === "unset") { | ||
throw new Error("Plugin missing meta.version") | ||
} | ||
if (!this.impl || this.impl.meta.api === "unset") { | ||
throw new Error("Plugin missing meta.api") | ||
} | ||
} | ||
async terminate() { | ||
if (this.impl?.cleanup) await this.impl?.cleanup() | ||
} | ||
} |
Oops, something went wrong.