Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace zap with http.zig for simpler code #16

Merged
merged 3 commits into from
Dec 24, 2023
Merged

Conversation

gballet
Copy link
Collaborator

@gballet gballet commented Dec 19, 2023

I found out that using http.zig allowed for much simpler code as it handles errors by itself and also has a ton of nice helpers. It also doesn't rely on an external C library, which de-clutters the build.zig a tad.

This is a preparatory step before l start implementing more engine API method.

@gballet gballet requested a review from jsign December 19, 2023 12:48
build.zig.zon Outdated
.url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz",
.hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
.httpz = .{
.url = "https://github.com/karlseguin/http.zig/archive/refs/heads/master.tar.gz",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a potential issue in case master contains breaking changes, but they don't have tags so it's a bit annoying to handle.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of link also seems to work and would pin to a specific commit: https://codeload.github.com/karlseguin/http.zig/tar.gz/1a82beb0dfc22e6fc38e9918e323f8fbd3cb78a3

Copy link
Owner

@jsign jsign Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an extra (and maybe obvious) comment: there's an HTTP server (and client) in the stdlib.

Not saying we should use it, but I think it was a recent addition in v0.11, if we want to even further remove deps.

Note: I see in the httpz readme that says that impl "is slow". Not sure that's entirely relevant for our expectations -- but also sharing that (apparent) "fact".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I looked into it before settling on httpz. More importantly it's more low-level than this lib, and so we would have to write more boiler-plate code. We should wait for it to mature and expand before we consider it.

Copy link
Owner

@jsign jsign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a comment on something that can avoid using master for the dependency.

build.zig.zon Outdated
.url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz",
.hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
.httpz = .{
.url = "https://github.com/karlseguin/http.zig/archive/refs/heads/master.tar.gz",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of link also seems to work and would pin to a specific commit: https://codeload.github.com/karlseguin/http.zig/tar.gz/1a82beb0dfc22e6fc38e9918e323f8fbd3cb78a3

const engine_api = @import("engine_api/engine_api.zig");
const json = std.json;

var allocator: std.mem.Allocator = undefined;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this removal of a global allocator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, that was the other reason to do this :D

@jsign
Copy link
Owner

jsign commented Dec 23, 2023

@gballet, just in case, consider this PR approved.
Feel free to merge it whenever you think is a good idea.

@gballet gballet merged commit 277c762 into jsign:main Dec 24, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants