garage/src/proto.rs
Alex 3477864142 Fix the Sync issue. Details:
So the HTTP client future of Hyper is not Sync, thus the stream
that read blocks wasn't either. However Hyper's default Body type
requires a stream to be Sync for wrap_stream. Solution: reimplement
a custom HTTP body type.
2020-04-10 22:01:48 +02:00

48 lines
898 B
Rust

use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
use std::time::Duration;
use crate::data::*;
pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);
#[derive(Debug, Serialize, Deserialize)]
pub enum Message {
Ok,
Error(String),
Ping(PingMessage),
PullStatus,
PullConfig,
AdvertiseNodesUp(Vec<AdvertisedNode>),
AdvertiseConfig(NetworkConfig),
GetBlock(Hash),
PutBlock(PutBlockMessage),
TableRPC(String, #[serde(with = "serde_bytes")] Vec<u8>),
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PingMessage {
pub id: UUID,
pub rpc_port: u16,
pub status_hash: Hash,
pub config_version: u64,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct AdvertisedNode {
pub id: UUID,
pub addr: SocketAddr,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PutBlockMessage {
pub hash: Hash,
#[serde(with = "serde_bytes")]
pub data: Vec<u8>,
}