Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment: two stage builder approach for custom protocols #2367

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion iroh-blobs/src/store/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use bao_tree::{
BaoTree, ChunkRanges,
};
use bytes::Bytes;
use derive_more::Debug;
use futures_lite::{Stream, StreamExt};
use genawaiter::rc::{Co, Gen};
use iroh_base::rpc::RpcError;
Expand Down Expand Up @@ -295,7 +296,7 @@ pub trait ReadableStore: Map {
}

/// The mutable part of a Bao store.
pub trait Store: ReadableStore + MapMut {
pub trait Store: ReadableStore + MapMut + Debug {
/// This trait method imports a file from a local path.
///
/// `data` is the path to the file.
Expand Down
14 changes: 14 additions & 0 deletions iroh/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ use std::path::Path;
use std::sync::Arc;

use anyhow::{anyhow, Result};
use futures_lite::future::Boxed;
use futures_lite::StreamExt;
use iroh_base::key::PublicKey;
use iroh_blobs::downloader::Downloader;
use iroh_blobs::store::Store as BaoStore;
use iroh_docs::engine::Engine;
use iroh_net::endpoint::Connecting;
use iroh_net::util::AbortingJoinHandle;
use iroh_net::{endpoint::LocalEndpointsStream, key::SecretKey, Endpoint};
use quic_rpc::transport::flume::FlumeConnection;
Expand All @@ -26,6 +28,7 @@ use tracing::debug;
use crate::client::RpcService;

mod builder;
mod protocol;
mod rpc;
mod rpc_status;

Expand All @@ -49,6 +52,17 @@ pub struct Node<D> {
client: crate::client::MemIroh,
}

/// A protocol
pub trait Protocol: Send + Sync + Debug + 'static {
/// Accept a connection
fn accept(&self, conn: Connecting) -> Boxed<Result<()>>;

/// Shutdown
fn shutdown(&self) -> Boxed<()> {
Box::pin(async move {})
}
}

#[derive(derive_more::Debug)]
struct NodeInner<D> {
db: D,
Expand Down
Loading
Loading