A library that makes it VERY easy to run Holochain as a library, from your own binary, with great defaults

Overview

embedded-holochain-runner

A library that makes it VERY easy to run Holochain as a library, from your own binary, with great defaults

How it will work

datastore_path is most important. If existing persisted Holochain conductor files are found in the given directory, it will simply re-use the admin_ws_port app_ws_port app_id and dnas from that configuration. Otherwise, it will create that directory, and setup your configuration as specified.

It will pair nicely with structopt to make a configurable service. See a simple demo. For a more advanced application using the exported async_main function, shutdown signal, and StateSignal listeners, you can see it in use in the Acorn Holochain application.

In either case,

  • first run/installation
  • second run/reboot

it will log this to the console when the interfaces are all ready and the app installed or running:

EMBEDDED_HOLOCHAIN_IS_READY

Usage

Cargo.toml

[dependencies]
embedded_holochain_runner = { git = "https://github.com/Sprillow/embedded-holochain-runner.git" }

[patch.crates-io]
rkv = { git = "https://github.com/holochain/rkv.git", branch = "master" }
lmdb-rkv = { git = "https://github.com/holochain/lmdb-rs.git" }

Assuming you have a compiled Holochain DNA file sitting around at ../dna/sample/sample.dna...

main.rs

use embedded_holochain_runner::*;
const SAMPLE_DNA: &'static [u8] = include_bytes!("../dna/sample/sample.dna");
fn main() {
    // String is like "CellNick"/"SlotId"
    let dnas: Vec<(Vec<u8>, String)> = vec![(SAMPLE_DNA.into(), "sample".into())];
    blocking_main(HcConfig {
        datastore_path: String::from("databases"),
        keystore_path: String::from("keystore"),
        app_id: String::from("my-app-id"),
        dnas,
        admin_ws_port: 1234,
        app_ws_port: 8888,
        proxy_url: String::from("kitsune-proxy://SYVd4CF3BdJ4DS7KwLLgeU3_DbHoZ34Y-qroZ79DOs8/kitsune-quic/h/165.22.32.11/p/5779/--"),
        event_channel: None,
    })
}

It will clearly log its configuration to the console.

RUST_LOG environment variable can be set to get details logs from Holochain. Those logs are by default suppressed.

Events

if you pass an event_channel, which should be of type: Option<tokio::sync::mpsc::Sender<StateSignal>> where StateSignal can be imported via use embedded_holochain_runner::StateSignal, you can listen for the following events, to trigger external actions.

It looks like:

pub enum StateSignal {
    // will be only one or the other of these
    IsFirstRun,
    IsNotFirstRun,
    // are sub events after IsFirstRun
    CreatingKeys,
    RegisteringDna,
    InstallingApp,
    ActivatingApp,
    SettingUpCells,
    AddingAppInterface,
    // Done/Ready Event, called when websocket interfaces and
    // everything else is ready
    IsReady,
}

Bootstrap Networking Service

This library is currently pointed at the https://bootstrap-staging.holo.host node discovery service.

Holochain Version

The HDK used for your DNA should match the version used in this library, which is listed below. Such as:

Zome Cargo.toml

[dependencies]
# use whatever hdk uses
serde = "*"
hdk = {git = "https://github.com/holochain/holochain.git", rev = "a6ac0439670ba367c723a80d3b8bc7c419aa5f6e", package = "hdk"}

Currently bundles Holochain version: a6ac0439670ba367c723a80d3b8bc7c419aa5f6e (Apr 23, 2021).

You might also like...
The new, performant, and simplified version of Holochain on Rust (sometimes called Holochain RSM for Refactored State Model)

Holochain License: This repository contains the core Holochain libraries and binaries. This is the most recent and well maintained version of Holochai

The new, performant, and simplified version of Holochain on Rust (sometimes called Holochain RSM for Refactored State Model)

Holochain License: This repository contains the core Holochain libraries and binaries. This is the most recent and well maintained version of Holochai

My own image file format created for fun! Install the "hif_opener.exe" to open hif files. clone the repo and compile to make your own hif file

Why am i creating this? I wanted to create my own image format since I was 12 years old using Windows 7, tryna modify GTA San Andreas. That day, when

A template for developing Rust projects, with sensible defaults

Rust Template A template for developing Rust projects, with sensible defaults. Getting Started Click the Use this template button at the top of the pa

The lightest distributed consensus library. Run your own replicated state machine! ❤️

Little Raft The lightest distributed consensus library. Run your own replicated state machine! ❤️ Installing Simply import the crate. In your Cargo.to

A simple self-contained CLI tool that makes it easy to efficiently encrypt/decrypt your files.

cryptic A simple self-contained CLI tool that makes it easy to efficiently encrypt/decrypt your files. Contents Features Building Usage License Featur

Very simple Rust binary that can turn on/off a TP-Link L920 led light strip in your local network
Very simple Rust binary that can turn on/off a TP-Link L920 led light strip in your local network

TP-Link L920 on/off script This is a (very) simple Rust binary that can turn on/off a TP-Link L920 led light strip in your local network. Installation

A very-very simple url shortener for Rust

urlshortener-rs A very simple urlshortener for Rust. This library aims to implement as much URL shortener services as possible and to provide an inter

ruby-build is a command-line utility that makes it easy to install virtually any version of Ruby, from source.

ruby-build ruby-build is a command-line utility that makes it easy to install virtually any version of Ruby, from source. It is available as a plugin

Mjml - the only framework that makes responsive-email easy
Mjml - the only framework that makes responsive-email easy

MJML 4 If you're looking for MJML 3.3.X check this branch | Translated documentation | Introduction | Installation | Usage | Translated documentation

Tangram - makes it easy for programmers to train, deploy, and monitor machine learning models.
Tangram - makes it easy for programmers to train, deploy, and monitor machine learning models.

Tangram is the all-in-one machine learning toolkit for programmers. Train a model from a CSV file on the command line. Make predictions from Elixir, G

procs makes it easy to find and manage system processes

procs procs makes it easy to find and manage system processes. Right now, the main usage is finding processes by the ports it is listening on, but mor

Simple to use CLI tool that makes encryption easy! Written in Rust.

🔒 eme: Encryption Made Easy an extremely simple AES-256 encryption tool written in Rust Usage: # To encrypt: eme --encrypt secret.png # To decrypt: e

A simple-to-use input manager for the Bevy game engine that empowers players and makes accessibility easy.

Bevy Ineffable A simple-to-use input manager for the Bevy game engine that empowers players and makes accessibility easy. Core tenets Make accessibili

Grsql is a great tool to allow you set up your remote sqlite database as service and CRUD(create/read/update/delete) it using gRPC.

Grsql is a great tool to allow you set up your remote sqlite database as service and CRUD (create/ read/ update/ delete) it using gRPC. Why Create Thi

A CRUD library for Holochain zomes that implements the CAPS pattern (Chained, Action ID, Permalink, State-based)

Holochain CRUD Library (CAPS pattern) A CRUD library for Holochain zomes that implement the CAPS pattern (Chained, Action, Permalink, State-based) Hol

DEPRECATED. The Holochain framework implemented in rust with a redux style internal state-model.
DEPRECATED. The Holochain framework implemented in rust with a redux style internal state-model.

Holochain-rust Travis: Circle CI: Codecov: License: This code is loosely based on the previous Golang prototype. Code Status: This Rust version is alp

Desktop launcher to install and use Holochain apps locally

Holochain Launcher A cross-platform executable that launches a local Holochain conductor, and installs and opens apps. Feedback is immensely welcome i

A simple configuration-based module for inter-network RPC in Holochain hApps.

DNA Auth Resolver A simple configuration-based module for inter-network RPC in Holochain hApps. About Usage In the origin zome In the destination DNA

Owner
Sprillow
Design, Development and Digital Consultation Studio
Sprillow
A language-based OS to run Rust on bare metal

RustOS A simple, language-based OS. Current features: Simple VGA for seeing output Some Rust libraries (core, alloc, collections) already in Working (

null 402 Dec 8, 2022
A language-based OS to run Rust on bare metal

RustOS A simple, language-based OS. Current features: Simple VGA for seeing output Some Rust libraries (core, alloc, collections) already in Working (

null 79 Dec 3, 2022
Distrod is a meta-distro for WSL 2 which runs Systemd as init process. You can run Ubuntu, Arch, and et.c with systemd in a minute. Distrod also has built-in auto-start feature on Windows startup and port forwarding abiltiy.

Distrod - WSL2 Distros with Systemd! Distrod is a systemd-based meta-distro for WSL2 that allows you to install Ubuntu, Arch Linux, Gentoo and many ot

Takaya Saeki 1.6k Jan 9, 2023
RCore-Tutorial-v3 - Let's write an OS which can run on RISC-V in Rust from zero!

rCore-Tutorial-v3 rCore-Tutorial version 3.5. See the Documentation in Chinese. Official QQ group number: 735045051 news 2021.11.20: Now we are updati

rCore OS 786 Jan 2, 2023
Let's write an OS which can run on ARM in Rust from scratch

rCore-Tutorial-v3 rCore-Tutorial version 3.5. See the Documentation in Chinese. news 2021.11.20: Now we are updating our labs. Please checkout chX-dev

rCore OS 10 Dec 17, 2022
Let's write an OS which can run on x86_64 in Rust from scratch

rCore-Tutorial-v3 rCore-Tutorial version 3.5. See the Documentation in Chinese. news 2021.11.20: Now we are updating our labs. Please checkout chX-dev

rCore OS 6 Apr 1, 2022
A new operating system kernel with Linux binary compatibility written in Rust.

Kerla Kerla is a monolithic operating system kernel from scratch in Rust which aims to be compatible with the Linux ABI, that is, runs Linux binaries

Seiya Nuta 3.1k Jan 1, 2023
suidsnoop is a tool based on eBPF LSM programs that logs whenever a suid binary is executed and implements custom allow/deny lists.

suidsnoop Log suid binaries and enforce per-uid suid policy. suidsnoop is a tool for logging whenever a suid binary is executed on your system and opt

William Findlay 11 Dec 22, 2022
Library for loading Linux kernel modules.

liblmod - Library for loading Linux kernel modules Features: modprobe rmmod Example code: extern crate liblmod; fn main() -> std::io::Result<()> {

Zapomnij 2 Aug 2, 2022
An all-environment scripting library for interacting with CosmWasm smart-contracts.

BOOT Smart contract scripting library to ease CosmWasm smart contract deployment and testing. BOOT is inspired by terra-rust-api and uses cosmos-rust

Abstract 18 Dec 28, 2022