Skip to content

Commit 5a82370

Browse files
authored
Rename ConfigSnapshotProtocol -> ConfigSnapshot (#67)
### Motivation Fixes #65. ### Modifications Renamed `ConfigSnapshotProtocol` to `ConfigSnapshot` and leave around a deprecated typealias for easier migration to the next 0.x version (will be removed for 1.0). ### Result Better name. ### Test Plan Adapted tests.
1 parent 8076a44 commit 5a82370

25 files changed

+61
-58
lines changed

Sources/Configuration/ConfigProvider.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public protocol ConfigProvider: Sendable {
115115
/// significant performance impact.
116116
///
117117
/// - Returns: An immutable snapshot that represents the current provider state.
118-
func snapshot() -> any ConfigSnapshotProtocol
118+
func snapshot() -> any ConfigSnapshot
119119

120120
/// Monitors the provider's state for changes by emitting snapshots.
121121
///
@@ -129,7 +129,7 @@ public protocol ConfigProvider: Sendable {
129129
/// - Throws: Provider-specific errors or errors thrown by the handler closure.
130130
/// - Returns: The value returned by the closure.
131131
func watchSnapshot<Return>(
132-
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshotProtocol, Never>) async throws -> Return
132+
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
133133
) async throws -> Return
134134
}
135135

@@ -139,7 +139,7 @@ public protocol ConfigProvider: Sendable {
139139
/// capturing the provider's state at a specific moment. This prevents the underlying
140140
/// data from changing between individual key lookups.
141141
@available(Configuration 1.0, *)
142-
public protocol ConfigSnapshotProtocol: Sendable {
142+
public protocol ConfigSnapshot: Sendable {
143143

144144
/// The human-readable name of the configuration provider that created this snapshot.
145145
///

Sources/Configuration/ConfigProviderHelpers.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ extension ConfigProvider {
7676
///
7777
/// ```swift
7878
/// func watchSnapshot(
79-
/// updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshotProtocol, Never>) async throws -> Void
79+
/// updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Void
8080
/// ) async throws {
8181
/// try await watchSnapshotFromSnapshot(updatesHandler)
8282
/// }
@@ -85,12 +85,10 @@ extension ConfigProvider {
8585
/// - Parameter updatesHandler: The closure that processes the async sequence of snapshot updates.
8686
/// - Returns: The value returned by the handler closure.
8787
/// - Throws: Provider-specific errors or errors thrown by the handler.
88-
nonisolated(nonsending)
89-
public func watchSnapshotFromSnapshot<Return>(
90-
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshotProtocol, Never>) async throws -> Return
91-
) async throws -> Return
92-
{
93-
let (stream, continuation) = AsyncStream<any ConfigSnapshotProtocol>
88+
nonisolated(nonsending) public func watchSnapshotFromSnapshot<Return>(
89+
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
90+
) async throws -> Return {
91+
let (stream, continuation) = AsyncStream<any ConfigSnapshot>
9492
.makeStream(bufferingPolicy: .bufferingNewest(1))
9593
let initialValue = snapshot()
9694
continuation.yield(initialValue)

Sources/Configuration/Deprecations.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ public typealias ReloadingYAMLProvider = ReloadingFileProvider<YAMLSnapshot>
4343
#endif
4444

4545
#endif
46+
47+
/// An immutable snapshot of a configuration provider's state.
48+
@available(Configuration 1.0, *)
49+
@available(*, deprecated, renamed: "ConfigSnapshot")
50+
public typealias ConfigSnapshotProtocol = ConfigSnapshot

Sources/Configuration/Documentation.docc/Documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ Any package can implement a ``ConfigProvider``, making the ecosystem extensible
426426
- ``KeyMappingProvider``
427427

428428
### Creating a custom provider
429-
- ``ConfigSnapshotProtocol``
429+
- ``ConfigSnapshot``
430430
- ``FileParsingOptions``
431431
- ``ConfigProvider``
432432
- ``ConfigContent``
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ``Configuration/ConfigSnapshot``
2+
3+
## Topics
4+
5+
### Required methods
6+
7+
- ``ConfigSnapshot/providerName``
8+
- ``ConfigSnapshot/value(forKey:type:)``

Sources/Configuration/Documentation.docc/Reference/ConfigSnapshotProtocol.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

Sources/Configuration/Documentation.docc/Reference/FileConfigSnapshot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
### Protocol requirements
1111

12-
- ``ConfigSnapshotProtocol``
12+
- ``ConfigSnapshot``

Sources/Configuration/Documentation.docc/Reference/JSONSnapshot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
### Snapshot configuration
1111

1212
- ``FileConfigSnapshot``
13-
- ``ConfigSnapshotProtocol``
13+
- ``ConfigSnapshot``

Sources/Configuration/Documentation.docc/Reference/YAMLSnapshot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
### Snapshot configuration
1111

1212
- ``FileConfigSnapshot``
13-
- ``ConfigSnapshotProtocol``
13+
- ``ConfigSnapshot``

Sources/Configuration/MultiProvider.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ extension MultiProvider: CustomStringConvertible {
8989
struct MultiSnapshot {
9090

9191
/// The individual snapshots from each nested provider, maintained in precedence order.
92-
var snapshots: [any ConfigSnapshotProtocol]
92+
var snapshots: [any ConfigSnapshot]
9393

9494
/// Resolves a configuration value by querying nested provider snapshots in precedence order.
9595
/// - Parameters:
@@ -201,7 +201,7 @@ extension MultiProvider {
201201
) async throws -> Return
202202
{
203203
let providers = storage.providers
204-
typealias UpdatesSequence = any (AsyncSequence<any ConfigSnapshotProtocol, Never> & Sendable)
204+
typealias UpdatesSequence = any (AsyncSequence<any ConfigSnapshot, Never> & Sendable)
205205
var updateSequences: [UpdatesSequence] = []
206206
updateSequences.reserveCapacity(providers.count)
207207
return try await withProvidersWatchingSnapshot(

0 commit comments

Comments
 (0)