13 Commits

Author SHA1 Message Date
3ced6db69d
message: play around with unit testing
I think I am probably going to move unit tests to a separate
directory/file structure. This will allow me to add a bunch of utility
functions that don't get analyzed for the library compilation and also
avoid testing-only imports in the main modules.
2023-08-15 22:23:35 -07:00
970d274593
nats: fix typo'd C api call 2023-08-15 22:23:35 -07:00
55690ced02
subscription: wrap all basic API calls
Hopefully I am not missing anything here. Will need to comb through the
public API to make sure no calls are missing.
2023-08-15 22:23:35 -07:00
94a428139d
message: wrap all basic API calls
The streaming API is not wrapped because we do not build nats.c with
the necessary libraries. The jetstream API is not wrapped because I am
extremely lazy and it's outside of the minimum viable scope at the
moment. It can happen after the other basic APIs have been wrapped.
2023-08-15 22:23:35 -07:00
b55dfe0732
subscription: remove dangling old implementation
Missed this before the commit train left the station.
2023-08-15 20:11:57 -07:00
79a45fd2e3
git subrepo clone (merge) --branch=v3.6.1 https://github.com/nats-io/nats.c.git deps/nats.c
subrepo:
  subdir:   "deps/nats.c"
  merged:   "66cec7f"
upstream:
  origin:   "https://github.com/nats-io/nats.c.git"
  branch:   "v3.6.1"
  commit:   "66cec7f"
git-subrepo:
  version:  "0.4.6"
  commit:   "b8b46501e"
2023-08-15 00:21:33 -07:00
5bc936a09f
deps: remove nats.c submodule
I'm going to try out git-subrepo. The main reason for this is that
github's autogenerated tarballs do not include submodules. And
github's autogenerated tarballs are the easiest way to integrate into
the zig package manager. Since git-subrepo checks the files into the
tree directly, new tarballs should include this dependency code.
2023-08-15 00:16:05 -07:00
b78033f818
build: move cross-compilation shim into nats-c.build.zig
It makes more sense for it to be here. I'm really not sure why I put it
in the main build in the first place.
2023-08-15 00:04:44 -07:00
fbb45f1567
readme: add some notes about zig version support 2023-08-14 22:46:44 -07:00
aea64fb625
all: start wrapping API
This is pretty much just the API surface that is used in the demo code
for now, with a couple of minor things I tacked on while getting a
feel for how I was going to go about it. Unfortunately, the diff is
too messy to show the improvement provided by the wrapped API, but I'm
pretty pleased with how it is turning out so far. In general, there
have been no major hiccups.

Most of the time working on this was spent noodling about how to create
the subscription callback thunk to provide type safety and pointer
nullability guarantees for the subscription zig API. I'm satisfied
with the solution in place now: it seems to have good default
ergonomics and very few downsides except that the callback function
must be known at compile time. An earlier iteration of this code
supported runtime function pointers but had a showstopping problem
with memory management. In order to store the runtime callback
pointer, the thunk would need to be allocated, but there was no way of
attaching our allocated memory to the c-library subscription object.
No attachment meant that there were a number of error scenarios where
the allocated thunk couldn't be freed correctly.

Ultimately, if the user needs to use runtime callback pointers they can
write a comptime known callback that calls a runtime known callback.
This way all of the object lifetime and ownership is in the user's
hands, which is really where it needs to belong anyway for this.
2023-08-14 22:40:41 -07:00
c4fb6c6579
Add a readme
look ma, I'm a real project now
2023-08-14 01:38:21 -07:00
e935df3060
Add license info
It's easy to pick the apache license because that's what nats.c uses.
It's a permissive license, and there's no need to get fancy here.
2023-08-14 00:29:34 -07:00
d957a4605a
init
This builds a very basic version of the nats.c client (no TLS, no
streaming/jetstream/whatever, since those bring in complex
dependencies and I do not need them at the moment). Right now it
contains a simple test program that demonstrates the functionality
(cool!), but the plan is for the nats.zig to bind the API into a
nicer, zig-like shape and re-export it. Then this becomes a package.
The current function could become a test, though it's a bit complex
for a unit test (and requires connecting to an externally-running NATS
server in order to work).
2023-08-13 23:35:42 -07:00