Crates.io | ax_sdk |
lib.rs | ax_sdk |
version | 0.2.0 |
source | src |
created_at | 2023-12-18 15:23:37.361197 |
updated_at | 2023-12-18 15:23:37.361197 |
description | Tools for interacting with the services of an ax node |
homepage | https://developer.actyx.com/ |
repository | https://github.com/Actyx/Actyx |
max_upload_size | |
id | 1073445 |
size | 145,951 |
AX is a decentralized event database, streaming and processing engine that allows you to easily build local-first cooperative apps. It makes it easy to run distributed applications on multiple nodes. It is a piece of software that allows you to run your own apps on one or more edge devices and have these apps seamlessly communicate and share data with each other.
Note: AX has been created by the company Actyx AG and predates the unrelated Actix framework (although AX wasn’t open-sourced until Oct’23). While we have changed crate names to avoid confusion, the company name remains Actyx AG and appears in some places.
This crate defines the data types needed for communicating with Actyx and provides Rust bindings for the AX APIs.
Below you find a full example using the Ax
client that retrieves some events. Please adapt the queried tags to match your stored events
in order to see output.
use ax_sdk::{
Ax, AxOpts,
types::{
app_id, AppManifest,
service::{Order, QueryRequest, QueryResponse},
}
};
use futures::stream::StreamExt;
use url::Url;
#[tokio::main]
pub async fn main() -> anyhow::Result<()> {
// Add your app manifest, for brevity we will use one in trial mode
let manifest = AppManifest::trial(
app_id!("com.example.my-awesome-app"),
"display name".into(),
"0.1.0".into(),
).unwrap();
// Url of the locally running Actyx node
let url = Url::parse("http://localhost:4454")?;
// Create client for it
let service = Ax::new(AxOpts { url, manifest }).await?;
// all events matching the given subscription
// sorted backwards, i.e. youngest to oldest
let mut events = service
.query("FROM 'MyTag'")
.with_order(Order::Desc)
.await?;
// print out the payload of each event
// (cf. `Payload::extract` for more options)
while let Some(QueryResponse::Event(event)) = events.next().await {
println!("{}", event.payload.json_value());
}
Ok(())
}
arb
: provide
quickcheck::Arbitrary
instances for common data types. This is useful for testing.