mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 04:35:03 +01:00
improvements
This commit is contained in:
parent
13deef42fd
commit
c5d83fe776
7 changed files with 15 additions and 15 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#![allow(dead_code)]
|
||||
// This file has been generated by `amqp_codegen`. Do not edit it manually.
|
||||
|
||||
pub type ClassId = u16;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ pub fn longstr<W: Write>(value: Longstr, writer: &mut W) -> Result<(), TransErro
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// this appears to be unused right now, but it could be used in `Basic` things?
|
||||
#[allow(dead_code)]
|
||||
pub fn timestamp<W: Write>(value: Timestamp, writer: &mut W) -> Result<(), TransError> {
|
||||
writer.write_all(&value.to_be_bytes())?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use std::net::SocketAddr;
|
|||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::net::TcpStream;
|
||||
use tracing::{debug, error, info};
|
||||
use uuid::Uuid;
|
||||
|
||||
fn ensure_conn(condition: bool) -> Result<()> {
|
||||
if condition {
|
||||
|
|
@ -27,17 +26,15 @@ pub struct Connection {
|
|||
max_frame_size: usize,
|
||||
heartbeat_delay: u16,
|
||||
channel_max: u16,
|
||||
id: Uuid,
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
pub fn new(stream: TcpStream, id: Uuid) -> Self {
|
||||
pub fn new(stream: TcpStream) -> Self {
|
||||
Self {
|
||||
stream,
|
||||
max_frame_size: FRAME_SIZE_MIN_MAX,
|
||||
heartbeat_delay: HEARTBEAT_DELAY,
|
||||
channel_max: CHANNEL_MAX,
|
||||
id,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +193,7 @@ impl Connection {
|
|||
Ok(())
|
||||
} else {
|
||||
debug!(?version, expected_version = ?SUPPORTED_PROTOCOL_VERSION, "Version negotiation failed, unsupported version");
|
||||
Err(ProtocolError::OtherCloseConnection.into())
|
||||
Err(ProtocolError::CloseNow.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use std::io::Error;
|
||||
|
||||
pub type StdResult<T, E> = std::result::Result<T, E>;
|
||||
|
|
@ -26,8 +28,10 @@ pub enum ProtocolError {
|
|||
ConException(#[from] ConException),
|
||||
#[error("{0}")]
|
||||
ChannelException(#[from] ChannelException),
|
||||
#[error("closing connection")]
|
||||
OtherCloseConnection,
|
||||
#[error("Connection must be closed")]
|
||||
CloseNow,
|
||||
#[error("Graceful connection closing requested")]
|
||||
GracefulClose,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
|
@ -37,7 +41,7 @@ pub enum ConException {
|
|||
#[error("503 Command invalid")]
|
||||
CommandInvalid,
|
||||
#[error("503 Syntax error | {0:?}")]
|
||||
/// A method was received but there was a syntax error. The string stores where it occured.
|
||||
/// A method was received but there was a syntax error. The string stores where it occurred.
|
||||
SyntaxError(Vec<String>),
|
||||
#[error("504 Channel error")]
|
||||
ChannelError,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
extern crate core;
|
||||
|
||||
mod classes;
|
||||
|
|
@ -29,7 +27,7 @@ pub async fn do_thing_i_guess() -> Result<()> {
|
|||
info!(local_addr = ?stream.local_addr(), %id, "Accepted new connection");
|
||||
let span = info_span!("client-connection", %id);
|
||||
|
||||
let connection = Connection::new(stream, id);
|
||||
let connection = Connection::new(stream);
|
||||
|
||||
tokio::spawn(connection.start_connection_processing().instrument(span));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue