The engine comes with the client - #6
Merged
Merged
Conversation
A Java client is Java and the engine is a shared library, so until now using this meant installing a libzu by hand and telling the JVM where it went. One more dependency now does it: zudb-native carries a build for every platform this client supports, Library.find looks for one on the class path, and a resource is copied to a temp file because no loader on any platform can map a resource. Eight artifacts come out of one module and one staged directory, so they cannot disagree about what is in them. The one with no classifier holds all seven platforms and is what a program developed on a laptop and deployed to a cluster wants, and the only one that survives being shaded. The seven classified ones hold one platform each, which is what a container image that knows what it runs on wants. Alpine is a platform rather than a smaller Linux: a shared object built against glibc does not load on musl, and says so in a message about an interpreter rather than about a database. Library.flavour picks between the two by looking for musl's own loader, which is the one path the ABI fixes rather than a distribution. Two things a user meets go with it. On the module path nothing requires this artifact, because there is no code in it to require, so a jar that is on the path is never resolved and its library is invisible; the search notices it is on a module path and names --add-modules dev.zudb.natives rather than leaving a user to work out why a class path run worked. And the derived automatic module name would be zudb.native, which is not a legal module name because native is a keyword, so every jar carries Automatic-Module-Name in its manifest. The search now also carries the places it ruled out, and Zu.source says which of the four answered, because a path on its own does not explain why the wrong engine is loaded and a property somebody set three shells ago is exactly the thing that explains it. Nothing in the test suite could check the claim this makes, since the suite is told where the library is so that it tests the binding rather than the search. So CI checks it the way a user meets it, on Linux and macOS: a class path, no property, no environment variable, and a statement that has to answer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using this client meant installing a libzu by hand and telling the JVM where it went. One more dependency now does it.
zudb-nativecarries a build for every platform this client supports,Library.findlooks for one on the class path between the environment variable and the platform's own search, and the resource is copied to a temp file once per JVM because no loader on any platform can map a resource.Eight artifacts come out of one module and one staged directory, so they cannot disagree about what is in them. The one with no classifier holds all seven platforms at about twenty megabytes, which is what a program developed on a laptop and deployed to a cluster wants, and the only one that survives being shaded into an uber-jar. The seven classified ones hold one platform each at about three, which is what a container image that knows what it runs on wants.
Alpine is a platform here rather than a smaller Linux, because a shared object built against glibc does not load on musl and the failure talks about an interpreter rather than about a database.
Library.flavourpicks between the two by looking for musl's own loader, which is the one path the ABI fixes rather than a distribution.Two things a user actually meets go with it. On the module path nothing requires this artifact, since there is no code in it to require, so a jar sitting on the path is never resolved and its library is invisible: the search notices it is on a module path and names
--add-modules dev.zudb.nativesinstead of leaving a user to work out why the same run on a class path worked. And the automatic module name derived from the file name would bezudb.native, which is not a legal module name becausenativeis a keyword, so every jar carriesAutomatic-Module-Namein its manifest.The search also carries the places it ruled out now, and
Zu.source()says which of the four answered, because a path on its own does not explain why the wrong engine got loaded and a property somebody set three shells ago is exactly the thing that does.scripts/stage-natives.shfillslib/from a release tag withgh, or from a directory that already holds the archives. It stays outsidetarget/so a clean does not throw away a download, and the module is behind-Pnativesso an ordinary build never needs it.Nothing in the test suite could check the claim this makes, because the suite is told where the library is so that it tests the binding rather than the search. So CI checks it the way a user meets it, on Linux and macOS: a class path, no property, no environment variable, and a statement that has to answer. Locally that run prints
found /var/folders/.../libzu.dylib through the zudb-native artifact, darwin-arm64and thenthe engine came out of the jar and answered, on the class path and on the module path both.Four tests in
LibraryTestcover the parts that do not need an engine: that musl only ever appears on Linux, that unpacking a resource produces the same bytes in a fresh directory each time, that a platform with no artifact is a search that carries on rather than a failure, and that the ruled-out list is in the documented order and never contains the place that answered.