218 个版本 (2 个稳定版)

新增 1.1.0 2024 年 8 月 16 日
1.0.0 2024 年 7 月 3 日
0.90.1 2024 年 6 月 13 日
0.88.12 2024 年 3 月 29 日
0.80.23 2023 年 7 月 31 日

#111 in 硬件支持

Download history 131/week @ 2024-04-20 720/week @ 2024-04-27 716/week @ 2024-05-04 222/week @ 2024-05-11 100/week @ 2024-05-18 345/week @ 2024-05-25 430/week @ 2024-06-01 416/week @ 2024-06-08 71/week @ 2024-06-15 7/week @ 2024-06-22 121/week @ 2024-06-29 11/week @ 2024-07-06

每月 13,146 次下载

BUSL-1.1

185KB
3.5K SLoC

Kurtosis Rust SDK

这是一个基于此处可用的 protobuf 的 Kurtosis SDK;

示例

确保引擎正在运行

kurtosis engine start

然后您可以使用 Kurtosis+Rust 运行 Starlark 脚本

use kurtosis_sdk::{engine_api::{engine_service_client::{EngineServiceClient}, CreateEnclaveArgs}, enclave_api::{api_container_service_client::ApiContainerServiceClient, RunStarlarkScriptArgs}};
use kurtosis_sdk::enclave_api::starlark_run_response_line::RunResponseLine::InstructionResult;

const STARLARK_SCRIPT : &str = "
def main(plan):
    plan.print('Hello World!')
";

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // CREATE ENCLAVE
    let mut engine = EngineServiceClient::connect("https://[::1]:9710").await?;
    let create_enclave_response = engine.create_enclave(CreateEnclaveArgs{
        enclave_name: "my-rust-test".to_string(),
        api_container_log_level: "info".to_string(),
        // Default
        api_container_version_tag: "".to_string(),
        is_partitioning_enabled: false,
    }).await?.into_inner();
    
    // CONNECT TO ENCLAVE
    let enclave_port = create_enclave_response.enclave_info.expect("Enclave info must be present").api_container_host_machine_info.expect("Enclave host machine info must be present").grpc_port_on_host_machine;
    let mut enclave = ApiContainerServiceClient::connect(format!("https://[::1]:{}", enclave_port)).await?;
    
    // RUN STARLARK SCRIPT
    let mut run_result = enclave.run_starlark_script(RunStarlarkScriptArgs{
        serialized_script: STARLARK_SCRIPT.to_string(),
        serialized_params: "{}".to_string(),
        dry_run: Option::Some(false),
        parallelism: Option::None,
        main_function_name: "main".to_string(),
    }).await?.into_inner();
    
    // GET OUTPUT LINES
    while let Some(next_message) = run_result.message().await? {
        next_message.run_response_line.map(|line| match line {
            InstructionResult(result) => {
                println!("{}", result.serialized_instruction_result)
            }
            _ => (),
        });
    }
    Ok(())
}

更多详细信息请参阅 文档

依赖项

~8MB
~142K SLoC