mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 07:14:50 +01:00
chore: better logging of workers stopping
This commit is contained in:
parent
ebf25fee44
commit
6fe92b9e8e
2 changed files with 12 additions and 7 deletions
|
@ -147,7 +147,7 @@ impl Handler for NeovimHandler {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
if !_controller.run() { break }
|
if !_controller.run() { break debug!("buffer updater clean exit") }
|
||||||
let _span = _controller.wait().await;
|
let _span = _controller.wait().await;
|
||||||
// TODO only change lines affected!
|
// TODO only change lines affected!
|
||||||
let lines : Vec<String> = _controller.content().split("\n").map(|x| x.to_string()).collect();
|
let lines : Vec<String> = _controller.content().split("\n").map(|x| x.to_string()).collect();
|
||||||
|
@ -199,9 +199,9 @@ impl Handler for NeovimHandler {
|
||||||
debug!("spawning cursor processing worker");
|
debug!("spawning cursor processing worker");
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
if !controller.run() { break }
|
if !controller.run() { break debug!("cursor worker clean exit") }
|
||||||
match sub.recv().await {
|
match sub.recv().await {
|
||||||
Err(e) => return error!("error receiving cursor update from controller: {}", e),
|
Err(e) => break error!("error receiving cursor update from controller: {}", e),
|
||||||
Ok((_usr, cur)) => {
|
Ok((_usr, cur)) => {
|
||||||
if let Err(e) = buf.clear_namespace(ns, 0, -1).await {
|
if let Err(e) = buf.clear_namespace(ns, 0, -1).await {
|
||||||
error!("could not clear previous cursor highlight: {}", e);
|
error!("could not clear previous cursor highlight: {}", e);
|
||||||
|
@ -212,6 +212,9 @@ impl Handler for NeovimHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Err(e) = buf.clear_namespace(ns, 0, -1).await {
|
||||||
|
error!("could not clear previous cursor highlight: {}", e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Ok(Value::Nil)
|
Ok(Value::Nil)
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use operational_transform::OperationSeq;
|
use operational_transform::OperationSeq;
|
||||||
use tonic::{transport::Channel, Status};
|
use tonic::{transport::Channel, Status};
|
||||||
use tracing::{error, warn, info};
|
use tracing::{error, warn, debug};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -51,7 +51,7 @@ impl CodempClient {
|
||||||
loop {
|
loop {
|
||||||
match stream.message().await {
|
match stream.message().await {
|
||||||
Err(e) => break error!("error receiving cursor: {}", e),
|
Err(e) => break error!("error receiving cursor: {}", e),
|
||||||
Ok(None) => break,
|
Ok(None) => break debug!("cursor worker clean exit"),
|
||||||
Ok(Some(x)) => { _controller.update(x); },
|
Ok(Some(x)) => { _controller.update(x); },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,12 +77,13 @@ impl CodempClient {
|
||||||
let factory = Arc::new(OperationController::new(content.unwrap_or("".into())));
|
let factory = Arc::new(OperationController::new(content.unwrap_or("".into())));
|
||||||
|
|
||||||
let _factory = factory.clone();
|
let _factory = factory.clone();
|
||||||
|
let _path = path.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
if !_factory.run() { break }
|
if !_factory.run() { break debug!("downstream worker clean exit") }
|
||||||
match stream.message().await {
|
match stream.message().await {
|
||||||
Err(e) => break error!("error receiving update: {}", e),
|
Err(e) => break error!("error receiving update: {}", e),
|
||||||
Ok(None) => break, // clean exit
|
Ok(None) => break warn!("stream closed for buffer {}", _path),
|
||||||
Ok(Some(x)) => match serde_json::from_str::<OperationSeq>(&x.opseq) {
|
Ok(Some(x)) => match serde_json::from_str::<OperationSeq>(&x.opseq) {
|
||||||
Err(e) => error!("error deserializing opseq: {}", e),
|
Err(e) => error!("error deserializing opseq: {}", e),
|
||||||
Ok(v) => match _factory.process(v).await {
|
Ok(v) => match _factory.process(v).await {
|
||||||
|
@ -118,6 +119,7 @@ impl CodempClient {
|
||||||
Err(e) => error!("could not send edit: {}", e),
|
Err(e) => error!("could not send edit: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debug!("upstream worker clean exit");
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(factory)
|
Ok(factory)
|
||||||
|
|
Loading…
Reference in a new issue