Skip to content

Commit

Permalink
Make no capacity logs less verbose and have capacity configurable via…
Browse files Browse the repository at this point in the history
… env var
  • Loading branch information
TheiLLeniumStudios committed Jan 18, 2024
1 parent 611037b commit 9977fc9
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 7 deletions.
51 changes: 50 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zumble"
version = "0.2.1"
version = "0.3.0"
edition = "2021"

[dependencies]
Expand Down Expand Up @@ -34,6 +34,7 @@ tokio-rustls = "0.23.4"
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
prometheus = { version = "0.13.3", features = ["process"] }
konst = "0.3.8"

[profile.release]
codegen-units = 1
Expand Down
4 changes: 2 additions & 2 deletions charts/zumble/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: zumble
type: application
version: 1.1.0
appVersion: v0.1.3
version: 1.2.0
appVersion: v0.3.0
2 changes: 2 additions & 0 deletions charts/zumble/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ spec:
env:
- name: RUST_LOG
value: {{ .Values.logLevel }}
- name: CLIENT_CAPACITY
value: "{{ .Values.config.clientCapacity }}"
envFrom:
- secretRef:
name: {{ include "zumble.fullname" . }}
Expand Down
3 changes: 3 additions & 0 deletions charts/zumble/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ logLevel: info
api:
username: admin
password: changeme

config:
clientCapacity: 2048
3 changes: 2 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use tokio::net::{TcpStream, UdpSocket};
use tokio::sync::mpsc::Sender;
use tokio::time::timeout;
use tokio_rustls::server::TlsStream;
use konst::{primitive::parse_usize, result::unwrap_ctx};

pub struct Client {
pub version: Version,
Expand Down Expand Up @@ -71,7 +72,7 @@ impl Client {
publisher: Sender<ClientMessage>,
) -> Self {
let tokens = authenticate.get_tokens().iter().map(|token| token.to_string()).collect();
let capacity = 4096;
let capacity = unwrap_ctx!(parse_usize(&std::env::var("CLIENT_CAPACITY").unwrap_or("2048".to_string())));
let mut targets = Vec::with_capacity(capacity);
targets.resize_with(capacity, Default::default);

Expand Down
2 changes: 1 addition & 1 deletion src/handler/voice_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Handler for VoicePacket<Clientbound> {
match client_read.publisher.try_send(ClientMessage::SendVoicePacket(self.clone())) {
Ok(_) => {}
Err(err) => {
if err.to_string() == "channel closed" {
if err.to_string() == "channel closed" || err.to_string() == "no available capacity" {
tracing::debug!(
"error sending voice packet message to {}: {}",
client_read.authenticate.get_username(),
Expand Down
2 changes: 1 addition & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl ServerState {
}) {
Ok(_) => {}
Err(err) => {
if err.to_string() == "channel closed" {
if err.to_string() == "channel closed" || err.to_string() == "no available capacity" {
tracing::debug!("failed to send message to {}: {}", client_read.authenticate.get_username(), err);
} else {
tracing::error!("failed to send message to {}: {}", client_read.authenticate.get_username(), err);
Expand Down

0 comments on commit 9977fc9

Please sign in to comment.