Add local in-memory pubsub
This commit is contained in:
parent
d072843cac
commit
6c85a341b8
13 changed files with 246 additions and 14 deletions
|
|
@ -454,9 +454,9 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
KvCommand::Set { name, key, value } => ControlRequest::KvSet { name, key, value },
|
||||
KvCommand::Get { name, key } => ControlRequest::KvGet { name, key },
|
||||
},
|
||||
Command::Pubsub { command } => ControlRequest::ModuleStub {
|
||||
module: "pubsub".to_owned(),
|
||||
command: format!("{command:?}"),
|
||||
Command::Pubsub { command } => match command {
|
||||
PubsubCommand::Pub { topic, message } => ControlRequest::PubsubPub { topic, message },
|
||||
PubsubCommand::Sub { topic } => ControlRequest::PubsubSub { topic },
|
||||
},
|
||||
Command::Pipe { command } => ControlRequest::ModuleStub {
|
||||
module: "pipe".to_owned(),
|
||||
|
|
@ -893,6 +893,22 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
println!("sync_status: {}", document.sync_status);
|
||||
println!("state_bytes: {}", document.state_bytes);
|
||||
}
|
||||
ControlResponse::PubsubPublished { message } => {
|
||||
println!("published: {}", message.topic);
|
||||
println!("published_at_ms: {}", message.published_at.0);
|
||||
}
|
||||
ControlResponse::PubsubMessages {
|
||||
topic,
|
||||
messages,
|
||||
note,
|
||||
} => {
|
||||
println!("topic: {topic}");
|
||||
println!("messages: {}", messages.len());
|
||||
for message in messages {
|
||||
println!("{}\t{}", message.published_at.0, message.message);
|
||||
}
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::NotImplemented { module, command } => {
|
||||
println!("{module} {command}: not implemented yet");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue