Lua: initial implementation of a service based approach#295
Merged
Conversation
f4z3r
commented
May 8, 2026
Contributor
Author
There was a problem hiding this comment.
Note that I generate the binary protobuf directly into Lua to facilitate how it can be shipped with Luarocks.
| self.pb.encode(arg_type, args), | ||
| "failed to encode argument into " .. arg_type | ||
| ) | ||
| local res = assert( |
Contributor
Author
There was a problem hiding this comment.
Note that I use very defensive programming here. This might not be desired if you want to propagate errors to the users. I currently implemented this so that the errors are easier to pin-point.
| add_method("KclService.ExecProgram", "ExecProgramArgs", "ExecProgramResult") | ||
|
|
||
| RawAPI.format_path = | ||
| add_method("KclService.FormatPath", "FormatPathArgs", "FormatPathResult") |
Contributor
Author
There was a problem hiding this comment.
Additional functions can be added by a single line like this in the future. I will do this in a second PR if this is accepted to support all the functions in the SDK.
This exposes a low level raw API to the native service running over protobuf. Another highler level API is provided with more ergonomic functions based on the low level API for simpler use of the SDK. Signed-off-by: Jakob Beckmann <f4z3r-github@pm.me>
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.
This exposes a low level raw API to the native service running over protobuf. Another highler level API is provided with more ergonomic functions based on the low level API for simpler use of the SDK.
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
kcl-lang/kcl#388
2. What is the scope of this PR (e.g. component or file name):
The Lua SDK.
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
It modifies the structure of the SDK to minimize the amount of Rust code needed and uses a native service call interface over protobuf similar to the implementation in Python and Go.
The raw native API is not yet extended to support all methods. On top of the raw native API, an ergonomic Lua API provides convenience methods to work with KCL.
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
The API changes.
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: