#wasmcloud #graph-database #graph #graphdb #api-bindings

wasmcloud-redisgraph

RedisGraph implementation of the wasmCloud Graph Database capability provider contract

4 releases

0.3.3 May 18, 2021
0.3.2 Mar 18, 2021
0.3.1 Feb 11, 2021
0.3.0 Feb 11, 2021

#2944 in Database interfaces

Apache-2.0

15KB
258 lines

crates.io Rust license documentation

wasmCloud Graph Database Provider (Redis Graph)

This repository contains a sample actor, and the main capability provider library.

While the actor and common libraries should be usable across different types of graph databases, this provider is build on top of Redis Graph.

The following sample shows just how few lines of code are required to build an actor that responds to HTTP requests, reads and writes graph data, and exposes results over HTTP as JSON:

actor_handlers! { codec::http::OP_HANDLE_REQUEST => handle_http_request,
                  codec::core::OP_HEALTH_REQUEST => health }

fn handle_http_request(req: codec::http::Request) -> HandlerResult<codec::http::Response> {    
    if req.method.to_uppercase() == "POST" {
        create_data()
    } else {
        query_data()
    }
}

// Execute a Cypher query to return data values
fn query_data() -> HandlerResult<codec::http::Response> {
    let (name, birth_year): (String, u32) =
        graph::default().graph("MotoGP")
            .query("MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r.name, r.birth_year")?;

    let result = json!({
        "name": name,
        "birth_year": birth_year
    });
    Ok(codec::http::Response::json(result, 200, "OK"))
}

fn health(_req: codec::core::HealthRequest) -> HandlerResult<()> {
    Ok(())
}

Dependencies

~8–17MB
~225K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy