mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 14:06:08 +00:00
Merge pull request #124 from jetzig-framework/database-in-jobs
Make database repo available in background jobs
This commit is contained in:
commit
a3e3cb6dfe
@ -15,8 +15,8 @@
|
||||
.hash = "12201d75d73aad5e1c996de4d5ae87a00e58479c8d469bc2eeb5fdeeac8857bc09af",
|
||||
},
|
||||
.jetquery = .{
|
||||
.url = "https://github.com/jetzig-framework/jetquery/archive/147e20907e10f2ae8a373ab202e63cf7ddcec1f3.tar.gz",
|
||||
.hash = "1220ce19ff91a1ac7f83fae3b7f13d670ba528df3ccdee1931cc475f7d3975dcca66",
|
||||
.url = "https://github.com/jetzig-framework/jetquery/archive/f48133462e054febe540c8c2864ab2704368d2fa.tar.gz",
|
||||
.hash = "1220877e86bb70c982ba296d2989cd87e4d95437651f5c4bb20de485aa55e4be3499",
|
||||
},
|
||||
.jetcommon = .{
|
||||
.url = "https://github.com/jetzig-framework/jetcommon/archive/86f24cfdf2aaa0e8ada4539a6edef882708ced2b.tar.gz",
|
||||
@ -26,7 +26,10 @@
|
||||
.url = "https://github.com/ikskuh/zig-args/archive/0abdd6947a70e6d8cc83b66228cea614aa856206.tar.gz",
|
||||
.hash = "1220411a8c46d95bbf3b6e2059854bcb3c5159d428814099df5294232b9980517e9c",
|
||||
},
|
||||
.pg = .{ .url = "https://github.com/karlseguin/pg.zig/archive/f376f4b30c63f1fdf90bc3afe246d3bc4175cd46.tar.gz", .hash = "12200a55304988e942015b6244570b2dc0e87e5764719c9e7d5c812cd7ad34f6b138" },
|
||||
.pg = .{
|
||||
.url = "https://github.com/karlseguin/pg.zig/archive/f376f4b30c63f1fdf90bc3afe246d3bc4175cd46.tar.gz",
|
||||
.hash = "12200a55304988e942015b6244570b2dc0e87e5764719c9e7d5c812cd7ad34f6b138",
|
||||
},
|
||||
.smtp_client = .{
|
||||
.url = "https://github.com/karlseguin/smtp_client.zig/archive/3cbe8f269e4c3a6bce407e7ae48b2c76307c559f.tar.gz",
|
||||
.hash = "1220de146446d0cae4396e346cb8283dd5e086491f8577ddbd5e03ad0928111d8bc6",
|
||||
|
@ -120,6 +120,7 @@ pub fn start(self: *const App, routes_module: type, options: AppOptions) !void {
|
||||
.mailers = &routes_module.mailers,
|
||||
.store = &store,
|
||||
.cache = &cache,
|
||||
.repo = &repo,
|
||||
.mutex = &mutex,
|
||||
},
|
||||
);
|
||||
|
@ -610,6 +610,7 @@ const RequestMail = struct {
|
||||
.store = self.request.server.store,
|
||||
.cache = self.request.server.cache,
|
||||
.mutex = undefined,
|
||||
.repo = self.request.repo,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
@ -73,17 +73,20 @@ const Dispatcher = struct {
|
||||
pub fn listen(self: *Server) !void {
|
||||
try self.decodeStaticParams();
|
||||
|
||||
const worker_count = jetzig.config.get(u16, "worker_count");
|
||||
const thread_count: u16 = jetzig.config.get(?u16, "thread_count") orelse @intCast(try std.Thread.getCpuCount());
|
||||
|
||||
var httpz_server = try httpz.Server(Dispatcher).init(
|
||||
self.allocator,
|
||||
.{
|
||||
.port = self.env.port,
|
||||
.address = self.env.bind,
|
||||
.thread_pool = .{
|
||||
.count = jetzig.config.get(?u16, "thread_count") orelse @intCast(try std.Thread.getCpuCount()),
|
||||
.count = thread_count,
|
||||
.buffer_size = jetzig.config.get(usize, "buffer_size"),
|
||||
},
|
||||
.workers = .{
|
||||
.count = jetzig.config.get(u16, "worker_count"),
|
||||
.count = worker_count,
|
||||
.max_conn = jetzig.config.get(u16, "max_connections"),
|
||||
.retain_allocated_bytes = jetzig.config.get(usize, "arena_size"),
|
||||
},
|
||||
@ -95,10 +98,12 @@ pub fn listen(self: *Server) !void {
|
||||
);
|
||||
defer httpz_server.deinit();
|
||||
|
||||
try self.logger.INFO("Listening on http://{s}:{} [{s}]", .{
|
||||
try self.logger.INFO("Listening on http://{s}:{d} [{s}] [workers:{d} threads:{d}]", .{
|
||||
self.env.bind,
|
||||
self.env.port,
|
||||
@tagName(self.env.environment),
|
||||
worker_count,
|
||||
thread_count,
|
||||
});
|
||||
|
||||
self.initialized = true;
|
||||
|
@ -25,6 +25,8 @@ pub const JobEnv = struct {
|
||||
store: *jetzig.kv.Store,
|
||||
/// Global cache
|
||||
cache: *jetzig.kv.Store,
|
||||
/// Database repo
|
||||
repo: *jetzig.database.Repo,
|
||||
/// Global mutex - use with caution if it is necessary to guarantee thread safety/consistency
|
||||
/// between concurrent job workers
|
||||
mutex: *std.Thread.Mutex,
|
||||
|
Loading…
x
Reference in New Issue
Block a user