Expand description
Workers for asset data collection and information updates.
This module defines traits and implementations for workers that monitor and update asset information. Workers are responsible for collecting data from various sources and updating asset information in the store.
The module provides:
- The
AssetWorkertrait which defines the common interface for all asset workers - Specialized worker implementations for different protocols and data sources
- Error handling specific to asset workers
§Worker Types
The module includes various worker implementations:
- REST-based workers in the
restmodule for HTTP/HTTPS API polling - WebSocket-based workers in the
websocketmodule for real-time data streaming
§Worker Lifecycle
Workers follow a typical lifecycle pattern:
- Initialization: Workers are built using their
buildmethod and configured with options - Running: Workers run continuously, collecting data from sources and updating the store
- Error Handling: Workers should handle temporary failures gracefully with retries
- Shutdown: Workers should support graceful shutdown when requested
§Worker Storage
Workers should use the WorkerStore wrapper to interact with the main store.
This wrapper provides namespace isolation for each worker, ensuring that different workers
can operate without conflicts. Each worker should use the WorkerStore to update asset
information through the set_asset_info and set_batch_asset_info methods.
§Extensibility
While this module provides general-purpose implementations that cover common use cases,
the AssetWorker trait is designed for extensibility. Users can create custom worker
implementations by implementing this trait to support specialized data sources, protocols,
or business logic beyond what’s provided in the standard implementations.
§Implementation
When implementing a new worker type:
- Implement the
AssetWorkertrait - Define appropriate configuration options via the associated
Optstype - Implement the
buildmethod to create worker instances from configuration - Implement any protocol-specific functionality in the worker
- Use
WorkerStoreto store asset information
Workers are typically registered with a worker registry and managed by the system to handle data collection and updates in a coordinated way.
Modules§
- error
- This module provides error handling functionality for asset workers. It defines a custom error type that can wrap other errors and provide additional context.
- rest
- REST-based asset information providers and polling mechanisms.
- websocket
- WebSocket-based asset information providers and streaming mechanisms.
Traits§
- Asset
Worker - The universal trait for all workers that collect and update asset info.