Hive Discovery
Hive Discovery is a lightweight service discovery library written in Rust, providing cross-platform network service discovery functionality with support for mDNS/DNS-SD protocols.
Features
- Zero-configuration network service discovery using mDNS/DNS-SD
- Support for service registration and discovery
- Asynchronous event notification system
- Automatic filtering to avoid self-discovery
- Service lifecycle management and timeout control
- Cross-platform support (Linux, macOS, Windows)
Basic Usage Example
use HashMap;
use ;
async
Check the examples directory for more examples.
Detailed Usage Instructions
Service Configuration
The LocalServiceConfig struct provides rich configuration options:
service_type: Service type, e.g. "_my-service._tcp.local."port: Port the service listens oninstance_name: Service instance nameproperties: Service properties (key-value pairs)- Other custom properties...
service_ttl: Service Time To Live (seconds)mdns_response_delay_ms: mDNS response delay range, for network congestion controlrefresh_interval: Discovery refresh interval
Service Discovery Events
Listen to DiscoveryEvent events to receive service discovery notifications:
ServiceFound: New service discovered or service information updatedServiceLost: Service is no longer availableDiscoveryStarted: Service discovery process has startedDiscoveryStopped: Service discovery process has stopped
Filtering Functionality
Use the add_filter and remove_filter methods to filter unwanted services:
// Add filter to ignore specific service instance
discovery.add_filter;
// Remove filter
discovery.remove_filter;