mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
3f7a5496dc
- FFI: add RVM/Program APIs, execution state accessors, HostAwait handling, and buffer/result helpers in rvm.rs, common.rs, engine.rs. - Compiler: emit HostAwait for __builtin_host_await in function_calls.rs. - RVM tests: add HostAwait regression cases and extend harness for suspend/resume responses in host_await.yaml and mod.rs. - C/C++: add RVM tests/examples and wrapper updates in rvm_tests.c, rvm_tests.cpp, regorus.hpp, plus CMake wiring. - C#: add Program/Rvm bindings, SafeHandle/PInvoke, tests, and example usage in Regorus, RvmProgramTests.cs, Program.cs, and README updates. - Go: add Program/Rvm bindings, tests, and examples in rvm.go, rvm_test.go, main.go. - Java: add Program/Rvm bindings, JNI glue, and examples in lib.rs, regorus, Test.java. - Python: add Program/Rvm bindings and examples in lib.rs, test.py. - WASM: add Program/Rvm bindings and examples in lib.rs, test.js. - Tooling: wire binding tests in xtask and ignore generated Java artifacts in .gitignore. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
104 lines
2.3 KiB
YAML
104 lines
2.3 KiB
YAML
cases:
|
|
- note: host_await_run_to_completion
|
|
data: {}
|
|
input:
|
|
enabled: true
|
|
skip_interpreter: true
|
|
execution_mode: run-to-completion
|
|
modules:
|
|
- |
|
|
package demo
|
|
import rego.v1
|
|
|
|
allow := [
|
|
__builtin_host_await("ping", "id-1"),
|
|
__builtin_host_await("pong", "id-2")
|
|
] if {
|
|
input.enabled
|
|
}
|
|
query: data.demo.allow
|
|
host_await_responses:
|
|
- id: "id-1"
|
|
value: "response-1"
|
|
- id: "id-2"
|
|
value: "response-2"
|
|
want_result: ["response-1", "response-2"]
|
|
|
|
- note: host_await_suspendable_queue
|
|
data: {}
|
|
input:
|
|
enabled: true
|
|
payloads: ["a", "b"]
|
|
skip_interpreter: true
|
|
execution_mode: suspendable
|
|
modules:
|
|
- |
|
|
package demo
|
|
import rego.v1
|
|
|
|
allow := [result |
|
|
input.enabled
|
|
payload := input.payloads[_]
|
|
result := __builtin_host_await(payload, "queue")
|
|
]
|
|
query: data.demo.allow
|
|
host_await_responses_suspendable:
|
|
- id: "queue"
|
|
value: "first"
|
|
- id: "queue"
|
|
value: "second"
|
|
want_result: ["first", "second"]
|
|
|
|
- note: host_await_nested_rule
|
|
data: {}
|
|
input:
|
|
enabled: true
|
|
token: "alpha"
|
|
skip_interpreter: true
|
|
execution_mode: suspendable
|
|
modules:
|
|
- |
|
|
package demo
|
|
import rego.v1
|
|
|
|
allow if {
|
|
input.enabled
|
|
result := nested_result
|
|
result == "ok"
|
|
}
|
|
|
|
nested_result := __builtin_host_await(input.token, "nested")
|
|
query: data.demo.allow
|
|
host_await_responses_suspendable:
|
|
- id: "nested"
|
|
value: "ok"
|
|
want_result: true
|
|
|
|
- note: host_await_nested_comprehension
|
|
data: {}
|
|
input:
|
|
enabled: true
|
|
items: ["x", "y"]
|
|
skip_interpreter: true
|
|
execution_mode: suspendable
|
|
modules:
|
|
- |
|
|
package demo
|
|
import rego.v1
|
|
|
|
allow := [outer |
|
|
input.enabled
|
|
inner := [r |
|
|
item := input.items[_]
|
|
r := __builtin_host_await(item, "nested-comp")
|
|
]
|
|
outer := inner
|
|
]
|
|
query: data.demo.allow
|
|
host_await_responses_suspendable:
|
|
- id: "nested-comp"
|
|
value: "first"
|
|
- id: "nested-comp"
|
|
value: "second"
|
|
want_result: [["first", "second"]]
|