scopedb-client 0.3.3

A Rust client for ScopeDB
Documentation
// Copyright 2024 ScopeDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

mod common;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = common::client()?;
    let table = common::write_table(&client)?;
    let stream = table.append_stream().build()?;

    let admitted = stream
        .send_all([
            serde_json::json!({
                "id": 1,
                "occurred_at": jiff::Timestamp::now(),
                "name": "first",
            }),
            serde_json::json!({
                "id": 2,
                "occurred_at": jiff::Timestamp::now(),
                "name": "second",
            }),
        ])
        .await?;
    println!("accepted locally: {} rows", admitted.accepted_rows);

    // send_all() confirms only local admission. With the default strict policy,
    // successful shutdown is the remote commit barrier for that accepted prefix.
    let report = stream.shutdown().await?;
    println!("committed remotely: {} rows", report.committed_rows);

    Ok(())
}