mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 22:16:08 +00:00

Use in-memory KV store (JetKV) for simple job queue. Build script generates an array of Zig modules in `src/app/jobs/` and stores their name + run function (`run(allocator, params, logger)`). View functions schedule jobs with arbitrary params. Thread pool spawns a (configurable) number of workers and pops jobs from the queue, then invokes the appropriate run function.
25 lines
716 B
Zig
25 lines
716 B
Zig
const std = @import("std");
|
|
|
|
/// Generate a secure random secret and output to stdout.
|
|
pub fn run(allocator: std.mem.Allocator, cwd: std.fs.Dir, args: [][]const u8, help: bool) !void {
|
|
if (help) {
|
|
std.debug.print(
|
|
\\Generate a secure random secret suitable for use as the `JETZIG_SECRET` environment variable.
|
|
\\
|
|
, .{});
|
|
return;
|
|
}
|
|
|
|
_ = allocator;
|
|
_ = args;
|
|
_ = cwd;
|
|
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
var secret: [128]u8 = undefined;
|
|
|
|
for (0..128) |index| {
|
|
secret[index] = chars[std.crypto.random.intRangeAtMost(u8, 0, chars.len)];
|
|
}
|
|
|
|
std.debug.print("{s}\n", .{secret});
|
|
}
|