Swift Service Discovery
Article Summary
Yim Lee from Apple's Swift team just open-sourced a game-changer for server-side Swift. If you're building microservices, this standardized approach to service discovery could save you from vendor lock-in.
Apple released Swift Service Discovery, a new open-source package that defines a standard API for service discovery in Swift server applications. Similar to SwiftLog and SwiftMetrics, it provides the interface while backend implementations (DNS-based, key-value stores, etc.) handle the actual functionality.
Key Takeaways
- Defines standard API for service discovery, not tied to specific backends
- Two core methods: lookup for one-time queries, subscribe for real-time updates
- Subscribe returns CancellationToken for managing long-lived service instance monitoring
- Backend implementations must conform to ServiceDiscovery protocol with deadline support
- Community-driven project actively seeking backend implementation contributions
Critical Insight
Swift Service Discovery establishes a vendor-neutral standard for service discovery in Swift server apps, letting teams swap backends without rewriting application code.