pub struct QoSServiceBuilder<C: HeartbeatConsumer + Send + Sync + 'static> { /* private fields */ }
Expand description
Fluent builder for assembling a QoSService
.
Use this builder to enable and configure optional sub-systems such as heartbeat
reporting, metrics (Prometheus/OpenTelemetry), log aggregation (Loki) and
Grafana dashboards. All features are off by default and can be enabled with the
corresponding with_*
methods.
Implementations§
Source§impl<C: HeartbeatConsumer + Send + Sync + 'static> QoSServiceBuilder<C>
impl<C: HeartbeatConsumer + Send + Sync + 'static> QoSServiceBuilder<C>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new QoS
service builder with default settings.
Initializes a builder with an empty configuration. All components (heartbeat, metrics,
logging, etc.) are disabled by default and must be explicitly configured using the
builder methods. This provides a clean starting point for building a custom QoS
observability setup.
Sourcepub fn with_config(self, config: QoSConfig) -> Self
pub fn with_config(self, config: QoSConfig) -> Self
Sets the complete QoS
configuration at once.
This method allows you to provide a pre-configured QoSConfig
instance,
which can be useful when loading configuration from external sources or
when you want to reuse an existing configuration. This will override any
previous component-specific configurations that were set on the builder.
§Parameters
config
- A completeQoSConfig
containing settings for allQoS
components
Sourcepub fn with_heartbeat_config(self, config: HeartbeatConfig) -> Self
pub fn with_heartbeat_config(self, config: HeartbeatConfig) -> Self
Configures the heartbeat service component.
The heartbeat service sends periodic signals to the Tangle blockchain to indicate that the service is alive and functioning properly. This helps prevent slashing of staked tokens and provides operational visibility.
§Parameters
config
- Configuration for the heartbeat service including service ID, blueprint ID, and heartbeat parameters such as interval and jitter
Sourcepub fn with_metrics_config(self, config: MetricsConfig) -> Self
pub fn with_metrics_config(self, config: MetricsConfig) -> Self
Configures the metrics collection component.
Metrics collection captures system resource usage (CPU, memory, disk, network) and application-specific metrics (job execution statistics, custom metrics). These metrics can be exported to Prometheus and visualized in Grafana dashboards.
§Parameters
config
- Configuration for metrics collection including retention settings, collection intervals, and export options
Sourcepub fn with_loki_config(self, config: LokiConfig) -> Self
pub fn with_loki_config(self, config: LokiConfig) -> Self
Configures the Loki logging integration.
Loki is a log aggregation system that works well with Grafana for visualization. This integration sends application logs to a Loki server, allowing centralized log storage, querying, and correlation with metrics.
§Parameters
config
- Configuration for Loki integration including server URL, authentication, labels, and batch settings
Sourcepub fn with_grafana_config(self, config: GrafanaConfig) -> Self
pub fn with_grafana_config(self, config: GrafanaConfig) -> Self
Configures the Grafana integration for dashboard visualization.
Grafana provides powerful visualization capabilities for metrics and logs. This
configuration allows the QoS
service to automatically create and update dashboards
that display service health, resource usage, and operational metrics.
§Parameters
config
- Configuration for Grafana integration including server URL, authentication, and organization settings
Sourcepub fn with_heartbeat_consumer(self, consumer: Arc<C>) -> Self
pub fn with_heartbeat_consumer(self, consumer: Arc<C>) -> Self
Sets the heartbeat consumer implementation.
The heartbeat consumer is responsible for processing and submitting heartbeat messages to the Tangle blockchain. It handles the cryptographic signing of heartbeat messages and submits them to the appropriate chain endpoint.
This is required if heartbeat functionality is enabled.
§Parameters
consumer
- Implementation of theHeartbeatConsumer
trait that will process and submit heartbeats to the blockchain
Sourcepub fn with_otel_config(self, config: OpenTelemetryConfig) -> Self
pub fn with_otel_config(self, config: OpenTelemetryConfig) -> Self
Configures OpenTelemetry integration for distributed tracing and advanced metrics.
OpenTelemetry provides a standardized way to collect and export telemetry data (traces, metrics, logs) across services. This integration enables correlation of traces with logs and metrics for comprehensive observability.
§Parameters
config
- OpenTelemetry configuration including exporter settings, sampling, and resource attribution
Sourcepub fn with_prometheus_datasource(self, datasource_uid: &str) -> Self
pub fn with_prometheus_datasource(self, datasource_uid: &str) -> Self
Configures automatic Grafana dashboard creation with a specific Prometheus datasource.
This method enables the automatic creation or updating of a Grafana dashboard
during QoS
service initialization. The dashboard will include panels for system
metrics, resource usage, and application-specific metrics sourced from the
specified Prometheus datasource.
§Parameters
datasource_uid
- The Grafana UID of the Prometheus datasource to use for metrics visualization
Sourcepub fn with_loki_datasource(self, datasource_uid: &str) -> Self
pub fn with_loki_datasource(self, datasource_uid: &str) -> Self
Configures Grafana dashboard to include logs from a specific Loki datasource.
When used in combination with with_prometheus_datasource
, this enables the creation
of comprehensive dashboards that include both metrics and logs. The dashboard will
include panels that allow for correlation between metrics and logs using the same
timestamps.
§Parameters
datasource_uid
- The Grafana UID of the Loki datasource to use for log visualization
Sourcepub fn with_grafana_server_config(self, config: GrafanaServerConfig) -> Self
pub fn with_grafana_server_config(self, config: GrafanaServerConfig) -> Self
Configures the managed Grafana server instance.
If server management is enabled, this configuration will be used to start and manage a Grafana server instance automatically. The server can be run as a Docker container or embedded server depending on the configuration.
§Parameters
config
- Configuration for the Grafana server including host, port, and authentication settings
Sourcepub fn with_loki_server_config(self, config: LokiServerConfig) -> Self
pub fn with_loki_server_config(self, config: LokiServerConfig) -> Self
Configures the managed Loki log aggregation server instance.
If server management is enabled, this configuration will be used to start and manage a Loki server instance automatically. This server will collect and store logs from the application for later querying and visualization in Grafana.
§Parameters
config
- Configuration for the Loki server including host, port, retention, and storage settings
Sourcepub fn with_prometheus_server_config(
self,
config: PrometheusServerConfig,
) -> Self
pub fn with_prometheus_server_config( self, config: PrometheusServerConfig, ) -> Self
Set the Prometheus server configuration
Sourcepub fn manage_servers(self, manage: bool) -> Self
pub fn manage_servers(self, manage: bool) -> Self
Enable or disable server management
Sourcepub fn with_http_rpc_endpoint(self, endpoint: String) -> Self
pub fn with_http_rpc_endpoint(self, endpoint: String) -> Self
Build the QoS
service
§Errors
Returns an error if the heartbeat consumer is not provided or if the service initialization fails
Set the HTTP RPC endpoint for HeartbeatService
Sourcepub fn with_ws_rpc_endpoint(self, endpoint: String) -> Self
pub fn with_ws_rpc_endpoint(self, endpoint: String) -> Self
Set the WebSocket RPC endpoint for HeartbeatService
Sourcepub fn with_keystore_uri(self, uri: String) -> Self
pub fn with_keystore_uri(self, uri: String) -> Self
Set the Keystore URI for HeartbeatService
Sourcepub async fn build(self) -> Result<QoSService<C>>
pub async fn build(self) -> Result<QoSService<C>>
Build the QoS
service
§Errors
Returns an error if the heartbeat consumer is not provided or if the service initialization fails
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for QoSServiceBuilder<C>
impl<C> RefUnwindSafe for QoSServiceBuilder<C>where
C: RefUnwindSafe,
impl<C> Send for QoSServiceBuilder<C>
impl<C> Sync for QoSServiceBuilder<C>
impl<C> Unpin for QoSServiceBuilder<C>where
C: Unpin,
impl<C> UnwindSafe for QoSServiceBuilder<C>where
C: UnwindSafe + RefUnwindSafe,
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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moreSource§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.