Update dependencies, api/lua: Fix log source

This commit is contained in:
Ottatop 2024-07-16 14:53:52 -05:00
parent 353d345e90
commit bff2e12987
9 changed files with 379 additions and 127 deletions

368
Cargo.lock generated
View file

@ -291,13 +291,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum-core", "axum-core 0.3.4",
"bitflags 1.3.2", "bitflags 1.3.2",
"bytes", "bytes",
"futures-util", "futures-util",
"http", "http 0.2.12",
"http-body", "http-body 0.4.6",
"hyper", "hyper 0.14.30",
"itoa", "itoa",
"matchit", "matchit",
"memchr", "memchr",
@ -306,7 +306,34 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"rustversion", "rustversion",
"serde", "serde",
"sync_wrapper", "sync_wrapper 0.1.2",
"tower",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf"
dependencies = [
"async-trait",
"axum-core 0.4.3",
"bytes",
"futures-util",
"http 1.1.0",
"http-body 1.0.1",
"http-body-util",
"itoa",
"matchit",
"memchr",
"mime",
"percent-encoding",
"pin-project-lite",
"rustversion",
"serde",
"sync_wrapper 1.0.1",
"tower", "tower",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
@ -321,14 +348,34 @@ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"futures-util", "futures-util",
"http", "http 0.2.12",
"http-body", "http-body 0.4.6",
"mime", "mime",
"rustversion", "rustversion",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
] ]
[[package]]
name = "axum-core"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3"
dependencies = [
"async-trait",
"bytes",
"futures-util",
"http 1.1.0",
"http-body 1.0.1",
"http-body-util",
"mime",
"pin-project-lite",
"rustversion",
"sync_wrapper 0.1.2",
"tower-layer",
"tower-service",
]
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.73" version = "0.3.73"
@ -350,6 +397,12 @@ version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.5.3" version = "0.5.3"
@ -1595,7 +1648,26 @@ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"futures-util", "futures-util",
"http", "http 0.2.12",
"indexmap 2.2.6",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "h2"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab"
dependencies = [
"atomic-waker",
"bytes",
"fnv",
"futures-core",
"futures-sink",
"http 1.1.0",
"indexmap 2.2.6", "indexmap 2.2.6",
"slab", "slab",
"tokio", "tokio",
@ -1679,6 +1751,17 @@ dependencies = [
"itoa", "itoa",
] ]
[[package]]
name = "http"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "0.4.6" version = "0.4.6"
@ -1686,7 +1769,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [ dependencies = [
"bytes", "bytes",
"http", "http 0.2.12",
"pin-project-lite",
]
[[package]]
name = "http-body"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [
"bytes",
"http 1.1.0",
]
[[package]]
name = "http-body-util"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f"
dependencies = [
"bytes",
"futures-util",
"http 1.1.0",
"http-body 1.0.1",
"pin-project-lite", "pin-project-lite",
] ]
@ -1712,9 +1818,9 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2", "h2 0.3.26",
"http", "http 0.2.12",
"http-body", "http-body 0.4.6",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
@ -1726,18 +1832,72 @@ dependencies = [
"want", "want",
] ]
[[package]]
name = "hyper"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"h2 0.4.5",
"http 1.1.0",
"http-body 1.0.1",
"httparse",
"httpdate",
"itoa",
"pin-project-lite",
"smallvec",
"tokio",
"want",
]
[[package]] [[package]]
name = "hyper-timeout" name = "hyper-timeout"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
dependencies = [ dependencies = [
"hyper", "hyper 0.14.30",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
"tokio-io-timeout", "tokio-io-timeout",
] ]
[[package]]
name = "hyper-timeout"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793"
dependencies = [
"hyper 1.4.1",
"hyper-util",
"pin-project-lite",
"tokio",
"tower-service",
]
[[package]]
name = "hyper-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http 1.1.0",
"http-body 1.0.1",
"hyper 1.4.1",
"pin-project-lite",
"socket2",
"tokio",
"tower",
"tower-service",
"tracing",
]
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.60" version = "0.1.60"
@ -2271,9 +2431,9 @@ name = "lua-build"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"indexmap 2.2.6", "indexmap 2.2.6",
"prost", "prost 0.12.6",
"prost-build", "prost-build 0.12.6",
"prost-types", "prost-types 0.12.6",
"walkdir", "walkdir",
] ]
@ -3056,7 +3216,7 @@ dependencies = [
"pinnacle", "pinnacle",
"pinnacle-api", "pinnacle-api",
"pinnacle-api-defs", "pinnacle-api-defs",
"prost", "prost 0.13.1",
"serde", "serde",
"shellexpand", "shellexpand",
"smithay", "smithay",
@ -3071,8 +3231,8 @@ dependencies = [
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"toml", "toml",
"tonic", "tonic 0.12.0",
"tonic-reflection", "tonic-reflection 0.12.0",
"tracing", "tracing",
"tracing-appender", "tracing-appender",
"tracing-subscriber", "tracing-subscriber",
@ -3089,6 +3249,7 @@ version = "0.0.2"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"futures", "futures",
"hyper-util",
"indexmap 2.2.6", "indexmap 2.2.6",
"num_enum", "num_enum",
"pinnacle-api-defs", "pinnacle-api-defs",
@ -3097,7 +3258,7 @@ dependencies = [
"snowcap-api", "snowcap-api",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tonic", "tonic 0.12.0",
"tower", "tower",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
@ -3109,9 +3270,9 @@ name = "pinnacle-api-defs"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"const_format", "const_format",
"prost", "prost 0.13.1",
"tonic", "tonic 0.12.0",
"tonic-build", "tonic-build 0.12.0",
] ]
[[package]] [[package]]
@ -3235,7 +3396,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29"
dependencies = [ dependencies = [
"bytes", "bytes",
"prost-derive", "prost-derive 0.12.6",
]
[[package]]
name = "prost"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc"
dependencies = [
"bytes",
"prost-derive 0.13.1",
] ]
[[package]] [[package]]
@ -3252,8 +3423,29 @@ dependencies = [
"once_cell", "once_cell",
"petgraph", "petgraph",
"prettyplease", "prettyplease",
"prost", "prost 0.12.6",
"prost-types", "prost-types 0.12.6",
"regex",
"syn 2.0.71",
"tempfile",
]
[[package]]
name = "prost-build"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bb182580f71dd070f88d01ce3de9f4da5021db7115d2e1c3605a754153b77c1"
dependencies = [
"bytes",
"heck",
"itertools",
"log",
"multimap",
"once_cell",
"petgraph",
"prettyplease",
"prost 0.13.1",
"prost-types 0.13.1",
"regex", "regex",
"syn 2.0.71", "syn 2.0.71",
"tempfile", "tempfile",
@ -3272,13 +3464,35 @@ dependencies = [
"syn 2.0.71", "syn 2.0.71",
] ]
[[package]]
name = "prost-derive"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca"
dependencies = [
"anyhow",
"itertools",
"proc-macro2",
"quote",
"syn 2.0.71",
]
[[package]] [[package]]
name = "prost-types" name = "prost-types"
version = "0.12.6" version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0"
dependencies = [ dependencies = [
"prost", "prost 0.12.6",
]
[[package]]
name = "prost-types"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2"
dependencies = [
"prost 0.13.1",
] ]
[[package]] [[package]]
@ -3862,15 +4076,15 @@ dependencies = [
"iced_futures", "iced_futures",
"iced_runtime", "iced_runtime",
"iced_wgpu", "iced_wgpu",
"prost", "prost 0.12.6",
"raw-window-handle", "raw-window-handle",
"smithay-client-toolkit 0.19.2", "smithay-client-toolkit 0.19.2",
"smithay-clipboard", "smithay-clipboard",
"snowcap-api-defs", "snowcap-api-defs",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tonic", "tonic 0.11.0",
"tonic-reflection", "tonic-reflection 0.11.0",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"xdg", "xdg",
@ -3887,7 +4101,7 @@ dependencies = [
"thiserror", "thiserror",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tonic", "tonic 0.11.0",
"tower", "tower",
"tracing", "tracing",
"xdg", "xdg",
@ -3898,9 +4112,9 @@ dependencies = [
name = "snowcap-api-defs" name = "snowcap-api-defs"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"prost", "prost 0.12.6",
"tonic", "tonic 0.11.0",
"tonic-build", "tonic-build 0.11.0",
"walkdir", "walkdir",
] ]
@ -4025,6 +4239,12 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "sync_wrapper"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
[[package]] [[package]]
name = "sys-locale" name = "sys-locale"
version = "0.3.1" version = "0.3.1"
@ -4344,17 +4564,47 @@ checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"axum", "axum 0.6.20",
"base64", "base64 0.21.7",
"bytes", "bytes",
"h2", "h2 0.3.26",
"http", "http 0.2.12",
"http-body", "http-body 0.4.6",
"hyper", "hyper 0.14.30",
"hyper-timeout", "hyper-timeout 0.4.1",
"percent-encoding", "percent-encoding",
"pin-project", "pin-project",
"prost", "prost 0.12.6",
"tokio",
"tokio-stream",
"tower",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tonic"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f738b6a169a29bca4e39656db89c44a08e09c5b700b896ee9e7459f0652e81dd"
dependencies = [
"async-stream",
"async-trait",
"axum 0.7.5",
"base64 0.22.1",
"bytes",
"h2 0.4.5",
"http 1.1.0",
"http-body 1.0.1",
"http-body-util",
"hyper 1.4.1",
"hyper-timeout 0.5.1",
"hyper-util",
"percent-encoding",
"pin-project",
"prost 0.13.1",
"socket2",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tower", "tower",
@ -4371,7 +4621,20 @@ checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2"
dependencies = [ dependencies = [
"prettyplease", "prettyplease",
"proc-macro2", "proc-macro2",
"prost-build", "prost-build 0.12.6",
"quote",
"syn 2.0.71",
]
[[package]]
name = "tonic-build"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "690943cc223adcdd67bb597a2e573ead1b88e999ba37528fe8e6356bf44b29b6"
dependencies = [
"prettyplease",
"proc-macro2",
"prost-build 0.13.1",
"quote", "quote",
"syn 2.0.71", "syn 2.0.71",
] ]
@ -4382,11 +4645,24 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "548c227bd5c0fae5925812c4ec6c66ffcfced23ea370cb823f4d18f0fc1cb6a7" checksum = "548c227bd5c0fae5925812c4ec6c66ffcfced23ea370cb823f4d18f0fc1cb6a7"
dependencies = [ dependencies = [
"prost", "prost 0.12.6",
"prost-types", "prost-types 0.12.6",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tonic", "tonic 0.11.0",
]
[[package]]
name = "tonic-reflection"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e0d3c6688e3b0be22d877b9c6ba86a7c5409e6b505ec8f7c99f026ae09530a"
dependencies = [
"prost 0.13.1",
"prost-types 0.13.1",
"tokio",
"tokio-stream",
"tonic 0.12.0",
] ]
[[package]] [[package]]

View file

@ -18,10 +18,10 @@ repository = "https://github.com/pinnacle-comp/pinnacle/"
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"]} tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"]}
tokio-stream = { version = "0.1.15", features = ["net"] } tokio-stream = { version = "0.1.15", features = ["net"] }
# gRPC # gRPC
prost = "0.12.6" prost = "0.13.1"
tonic = "0.11.0" tonic = "0.12.0"
tonic-reflection = "0.11.0" tonic-reflection = "0.12.0"
tonic-build = "0.11.0" tonic-build = "0.12.0"
# Tracing # Tracing
tracing = "0.1.40" tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] }

View file

@ -12,40 +12,24 @@ local logging = require("logging")
---@field fatal function ---@field fatal function
local log = {} local log = {}
local console_logger = require("logging.console")({ local log_patterns = logging.buildLogPatterns({
logPattern = "%level %message\n", [logging.ERROR] = "%level %message (at %source)",
logPatterns = { }, "%level %message")
[logging.ERROR] = "%level %message (at %source)\n",
}, local console_logger = logging.new(function(self, level, message)
}) print(
logging.prepareLogMsg(
log_patterns[level],
logging.date(logging.defaultTimestampPattern()),
level,
message
)
)
return true
end, logging.defaultLevel())
setmetatable(log, { setmetatable(log, {
__index = console_logger, __index = console_logger,
}) })
log.debug = function(_, ...)
console_logger:debug(...)
io.flush()
end
log.info = function(_, ...)
console_logger:info(...)
io.flush()
end
log.warn = function(_, ...)
console_logger:warn(...)
io.flush()
end
log.error = function(_, ...)
console_logger:error(...)
io.flush()
end
log.fatal = function(_, ...)
console_logger:fatal(...)
io.flush()
end
return log return log

View file

@ -16,6 +16,7 @@ tokio = { workspace = true, features = ["net"] }
tokio-stream = { workspace = true } tokio-stream = { workspace = true }
tonic = { workspace = true } tonic = { workspace = true }
tower = { version = "0.4.13", features = ["util"] } tower = { version = "0.4.13", features = ["util"] }
hyper-util = { version = "0.1.6", features = ["tokio"] }
futures = "0.3.30" futures = "0.3.30"
num_enum = "0.7.2" num_enum = "0.7.2"
xkbcommon = { workspace = true } xkbcommon = { workspace = true }

View file

@ -85,6 +85,7 @@
//! You can peruse the documentation for things to configure. //! You can peruse the documentation for things to configure.
use futures::{Future, StreamExt}; use futures::{Future, StreamExt};
use hyper_util::rt::TokioIo;
use input::Input; use input::Input;
use layout::Layout; use layout::Layout;
use output::Output; use output::Output;
@ -263,11 +264,11 @@ impl ApiModules {
pub async fn connect() -> Result<(), Box<dyn std::error::Error>> { pub async fn connect() -> Result<(), Box<dyn std::error::Error>> {
// port doesn't matter, we use a unix socket // port doesn't matter, we use a unix socket
let channel = Endpoint::try_from("http://[::]:50051")? let channel = Endpoint::try_from("http://[::]:50051")?
.connect_with_connector(service_fn(|_: Uri| { .connect_with_connector(service_fn(|_: Uri| async {
tokio::net::UnixStream::connect( let path = std::env::var("PINNACLE_GRPC_SOCKET")
std::env::var("PINNACLE_GRPC_SOCKET") .expect("PINNACLE_GRPC_SOCKET was not set; is Pinnacle running?");
.expect("PINNACLE_GRPC_SOCKET was not set; is Pinnacle running?"),
) Ok::<_, std::io::Error>(TokioIo::new(tokio::net::UnixStream::connect(path).await?))
})) }))
.await .await
.unwrap(); .unwrap();

@ -1 +1 @@
Subproject commit 7baca8e4299780723f21ea696b19f8998207dc1f Subproject commit 3dc265976aa1e715db483e1c69d1c84ce897e4a0

View file

@ -144,7 +144,7 @@ fn run_bidirectional_streaming<F1, F2, I, O>(
with_out_stream_and_in_stream_join_handle: F2, with_out_stream_and_in_stream_join_handle: F2,
) -> Result<Response<ResponseStream<O>>, Status> ) -> Result<Response<ResponseStream<O>>, Status>
where where
F1: Fn(&mut State, Result<I, Status>) + Clone + Send + 'static, F1: Fn(&mut State, I) + Clone + Send + 'static,
F2: FnOnce(&mut State, UnboundedSender<Result<O, Status>>, JoinHandle<()>) + Send + 'static, F2: FnOnce(&mut State, UnboundedSender<Result<O, Status>>, JoinHandle<()>) + Send + 'static,
I: Send + 'static, I: Send + 'static,
O: Send + 'static, O: Send + 'static,
@ -155,15 +155,24 @@ where
let with_in_stream = async move { let with_in_stream = async move {
while let Some(request) = in_stream.next().await { while let Some(request) = in_stream.next().await {
let on_client_request = on_client_request.clone(); match request {
// TODO: handle error Ok(request) => {
let _ = fn_sender_clone.send(Box::new(move |state: &mut State| { let on_client_request = on_client_request.clone();
on_client_request(state, request); // TODO: handle error
})); let _ = fn_sender_clone.send(Box::new(move |state: &mut State| {
on_client_request(state, request);
}));
}
Err(err) => {
debug!("bidirectional stream error: {err}");
break;
}
}
} }
}; };
let join_handle = tokio::spawn(with_in_stream); let join_handle = tokio::spawn(with_in_stream);
// let join_handle = tokio::spawn(async {});
let with_out_stream_and_in_stream_join_handle = Box::new(|state: &mut State| { let with_out_stream_and_in_stream_join_handle = Box::new(|state: &mut State| {
with_out_stream_and_in_stream_join_handle(state, sender, join_handle); with_out_stream_and_in_stream_join_handle(state, sender, join_handle);

View file

@ -32,34 +32,23 @@ impl layout_service_server::LayoutService for LayoutService {
run_bidirectional_streaming( run_bidirectional_streaming(
self.sender.clone(), self.sender.clone(),
in_stream, in_stream,
|state, request| match request { |state, request| {
Ok(request) => { if let Some(body) = request.body {
if let Some(body) = request.body { match body {
match body { layout_request::Body::Geometries(geos) => {
layout_request::Body::Geometries(geos) => { if let Err(err) = state.apply_layout(geos) {
if let Err(err) = state.apply_layout(geos) { debug!("{err}")
debug!("{err}") }
} }
} layout_request::Body::Layout(ExplicitLayout { output_name }) => {
layout_request::Body::Layout(ExplicitLayout { output_name }) => { if let Some(output) = output_name
if let Some(output) = output_name .map(OutputName)
.map(OutputName) .and_then(|name| name.output(&state.pinnacle))
.and_then(|name| name.output(&state.pinnacle)) .or_else(|| state.pinnacle.focused_output().cloned())
.or_else(|| state.pinnacle.focused_output().cloned()) {
{ state.pinnacle.request_layout(&output);
state.pinnacle.request_layout(&output);
}
} }
} }
}
}
Err(err) => {
// Ignore broken pipes here, they have a code of `Unknown`
//
// Silences errors when reloading the config, unfortunately also ignores other
// `Unknown` errors
if err.code() != tonic::Code::Unknown {
tracing::error!("{err}")
} }
} }
}, },

View file

@ -157,14 +157,6 @@ where
sender, sender,
in_stream, in_stream,
move |state, request| { move |state, request| {
let request = match request {
Ok(request) => request,
Err(status) => {
debug!("Error in output_connect signal in stream: {status}");
return;
}
};
debug!("Got {request:?} from client stream"); debug!("Got {request:?} from client stream");
let signal = signal_data_selector(state); let signal = signal_data_selector(state);