Publish pubsub messages over Iroh
This commit is contained in:
parent
f85039367c
commit
e294965833
8 changed files with 357 additions and 28 deletions
|
|
@ -312,8 +312,15 @@ pub enum KvCommand {
|
|||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum PubsubCommand {
|
||||
Pub { topic: String, message: String },
|
||||
Sub { topic: String },
|
||||
Pub {
|
||||
topic: String,
|
||||
message: String,
|
||||
#[arg(long)]
|
||||
node: Option<String>,
|
||||
},
|
||||
Sub {
|
||||
topic: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
|
|
@ -624,7 +631,15 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
KvCommand::Sync { node, name } => ControlRequest::KvSync { node, name },
|
||||
},
|
||||
Command::Pubsub { command } => match command {
|
||||
PubsubCommand::Pub { topic, message } => ControlRequest::PubsubPub { topic, message },
|
||||
PubsubCommand::Pub {
|
||||
topic,
|
||||
message,
|
||||
node,
|
||||
} => ControlRequest::PubsubPub {
|
||||
topic,
|
||||
message,
|
||||
node,
|
||||
},
|
||||
PubsubCommand::Sub { topic } => ControlRequest::PubsubSub { topic },
|
||||
},
|
||||
Command::Pipe { command } => match command {
|
||||
|
|
@ -1361,6 +1376,28 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
println!("published: {}", message.topic);
|
||||
println!("published_at_ms: {}", message.published_at.0);
|
||||
}
|
||||
ControlResponse::PubsubRemotePublished {
|
||||
peer_node_id,
|
||||
peer_agent_id,
|
||||
endpoint_id,
|
||||
message,
|
||||
allowed,
|
||||
reason,
|
||||
note,
|
||||
} => {
|
||||
if allowed {
|
||||
println!("published: {}", message.topic);
|
||||
println!("peer: {peer_node_id}");
|
||||
println!("published_at_ms: {}", message.published_at.0);
|
||||
} else {
|
||||
println!("pubsub publish denied by {peer_node_id}");
|
||||
}
|
||||
println!("agent: {peer_agent_id}");
|
||||
println!("endpoint: {endpoint_id}");
|
||||
println!("allowed: {allowed}");
|
||||
println!("reason: {reason}");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::PubsubMessages {
|
||||
topic,
|
||||
messages,
|
||||
|
|
|
|||
Loading…
Reference in a new issue