pub struct WebDashboard { /* private fields */ }Expand description
Main web dashboard server.
The WebDashboard provides a complete web interface for monitoring and managing
Hammerwork job queues. It includes REST API endpoints, WebSocket support for
real-time updates, authentication, and a modern HTML/CSS/JS frontend.
§Examples
use hammerwork_web::{WebDashboard, DashboardConfig};
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = DashboardConfig::new()
.with_bind_address("127.0.0.1", 8080)
.with_database_url("postgresql://localhost/hammerwork")
.with_static_dir(PathBuf::from("./assets"))
.with_cors(false);
let dashboard = WebDashboard::new(config).await?;
dashboard.start().await?;
Ok(())
}Implementations§
Source§impl WebDashboard
impl WebDashboard
Sourcepub async fn new(config: DashboardConfig) -> Result<Self>
pub async fn new(config: DashboardConfig) -> Result<Self>
Create a new web dashboard instance.
This initializes the dashboard with the provided configuration but does not
start the web server. Call start() to begin serving requests.
§Examples
use hammerwork_web::{WebDashboard, DashboardConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = DashboardConfig::new()
.with_database_url("postgresql://localhost/hammerwork");
let dashboard = WebDashboard::new(config).await?;
// Dashboard is created but not yet started
Ok(())
}§Errors
Returns an error if the configuration is invalid or if initialization fails.
Sourcepub fn with_event_manager(self, event_manager: Arc<EventManager>) -> Self
pub fn with_event_manager(self, event_manager: Arc<EventManager>) -> Self
Also forward the job lifecycle events of event_manager to connected clients as
they happen.
For a dashboard embedded in the same process as the workers that publish to
event_manager. Without it (and in the standalone binary) the dashboard still
pushes job and queue changes, by polling the database every
websocket.live_update_interval; see crate::live.
Auto Trait Implementations§
impl !RefUnwindSafe for WebDashboard
impl !UnwindSafe for WebDashboard
impl Freeze for WebDashboard
impl Send for WebDashboard
impl Sync for WebDashboard
impl Unpin for WebDashboard
impl UnsafeUnpin for WebDashboard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more