aws lambda support
This commit is contained in:
parent
0cbc80d417
commit
e4195103a2
|
@ -1,7 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
const HandlerFn = *const fn (std.mem.Allocator, []const u8) anyerror![]const u8;
|
const HandlerFn = @import("universal_lambda.zig").HandlerFn;
|
||||||
|
|
||||||
const log = std.log.scoped(.lambda);
|
const log = std.log.scoped(.lambda);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ pub fn run(allocator: ?std.mem.Allocator, event_handler: HandlerFn) !void { // T
|
||||||
// reasonable to report back
|
// reasonable to report back
|
||||||
const event = ev.?;
|
const event = ev.?;
|
||||||
defer ev.?.deinit();
|
defer ev.?.deinit();
|
||||||
const event_response = event_handler(req_allocator, event.event_data) catch |err| {
|
const event_response = event_handler(req_allocator, event.event_data, .{}) catch |err| {
|
||||||
event.reportError(@errorReturnTrace(), err, lambda_runtime_uri) catch unreachable;
|
event.reportError(@errorReturnTrace(), err, lambda_runtime_uri) catch unreachable;
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
|
@ -126,6 +126,7 @@ pub fn configureBuild(b: *std.build.Builder, exe: *std.Build.Step.Compile) !void
|
||||||
// The architectures option was introduced in 2.2.43 released 2021-10-01
|
// The architectures option was introduced in 2.2.43 released 2021-10-01
|
||||||
// We want to use arm64 here because it is both faster and cheaper for most
|
// We want to use arm64 here because it is both faster and cheaper for most
|
||||||
// Amazon Linux 2 is the only arm64 supported option
|
// Amazon Linux 2 is the only arm64 supported option
|
||||||
|
// TODO: This should determine compilation target and use x86_64 if needed
|
||||||
const not_found = "aws lambda create-function --architectures arm64 --runtime provided.al2 --function-name {s} --zip-file fileb://{s} --handler not_applicable {s} && touch {s}";
|
const not_found = "aws lambda create-function --architectures arm64 --runtime provided.al2 --function-name {s} --zip-file fileb://{s} --handler not_applicable {s} && touch {s}";
|
||||||
const not_found_fmt = try std.fmt.allocPrint(b.allocator, not_found, .{ function_name, function_zip, iam_role, function_name_file });
|
const not_found_fmt = try std.fmt.allocPrint(b.allocator, not_found, .{ function_name, function_zip, iam_role, function_name_file });
|
||||||
defer b.allocator.free(not_found_fmt);
|
defer b.allocator.free(not_found_fmt);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const build_options = @import("build_options");
|
const build_options = @import("build_options");
|
||||||
|
|
||||||
const HandlerFn = *const fn (std.mem.Allocator, []const u8, Context) anyerror![]const u8;
|
pub const HandlerFn = *const fn (std.mem.Allocator, []const u8, Context) anyerror![]const u8;
|
||||||
|
|
||||||
const log = std.log.scoped(.universal_lambda);
|
const log = std.log.scoped(.universal_lambda);
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ pub const Context = struct {};
|
||||||
|
|
||||||
const runFn = blk: {
|
const runFn = blk: {
|
||||||
switch (build_options.build_type) {
|
switch (build_options.build_type) {
|
||||||
|
.awslambda => break :blk @import("lambda.zig").run,
|
||||||
.standalone_server => break :blk runStandaloneServer,
|
.standalone_server => break :blk runStandaloneServer,
|
||||||
.exe_run => break :blk runExe,
|
.exe_run => break :blk runExe,
|
||||||
else => @compileError("Provider interface for " ++ @tagName(build_options.build_type) ++ " has not yet been implemented"),
|
else => @compileError("Provider interface for " ++ @tagName(build_options.build_type) ++ " has not yet been implemented"),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user