|
12 | 12 | // |
13 | 13 | //===----------------------------------------------------------------------===// |
14 | 14 |
|
15 | | -#if JSONSupport |
16 | | -/// A provider of configuration in JSON files. |
17 | | -@available(Configuration 1.0, *) |
18 | | -@available(*, deprecated, message: "Renamed to FileProvider<JSONSnapshot>") |
19 | | -public typealias JSONProvider = FileProvider<JSONSnapshot> |
20 | | -#endif |
21 | | - |
22 | | -#if YAMLSupport |
23 | | -/// A provider of configuration in YAML files. |
24 | | -@available(Configuration 1.0, *) |
25 | | -@available(*, deprecated, message: "Renamed to FileProvider<YAMLSnapshot>") |
26 | | -public typealias YAMLProvider = FileProvider<YAMLSnapshot> |
27 | | -#endif |
28 | | - |
29 | | -#if ReloadingSupport |
30 | | - |
31 | | -#if JSONSupport |
32 | | -/// A reloading provider of configuration in JSON files. |
33 | | -@available(Configuration 1.0, *) |
34 | | -@available(*, deprecated, message: "Renamed to ReloadingFileProvider<JSONSnapshot>") |
35 | | -public typealias ReloadingJSONProvider = ReloadingFileProvider<JSONSnapshot> |
36 | | -#endif |
37 | | - |
38 | | -#if YAMLSupport |
39 | | -/// A reloading provider of configuration in JSON files. |
40 | | -@available(Configuration 1.0, *) |
41 | | -@available(*, deprecated, message: "Renamed to ReloadingFileProvider<YAMLSnapshot>") |
42 | | -public typealias ReloadingYAMLProvider = ReloadingFileProvider<YAMLSnapshot> |
43 | | -#endif |
44 | | - |
45 | | -#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 |
51 | | - |
52 | | -@available(Configuration 1.0, *) |
53 | | -extension ConfigReader { |
54 | | - /// Provides a snapshot of the current configuration state and passes it to the provided closure. |
55 | | - /// |
56 | | - /// This method creates a snapshot of the current configuration state and passes it to the |
57 | | - /// provided closure. The snapshot reader provides read-only access to the configuration's state |
58 | | - /// at the time the method was called. |
59 | | - /// |
60 | | - /// ```swift |
61 | | - /// let result = config.withSnapshot { snapshot in |
62 | | - /// // Use snapshot to read config values |
63 | | - /// let cert = snapshot.string(forKey: "cert") |
64 | | - /// let privateKey = snapshot.string(forKey: "privateKey") |
65 | | - /// // Ensures that both values are coming from the same underlying snapshot and that a provider |
66 | | - /// // didn't change its internal state between the two `string(...)` calls. |
67 | | - /// return MyCert(cert: cert, privateKey: privateKey) |
68 | | - /// } |
69 | | - /// ``` |
70 | | - /// |
71 | | - /// - Parameter body: A closure that takes a `ConfigSnapshotReader` and returns a value. |
72 | | - /// - Returns: The value returned by the closure. |
73 | | - /// - Throws: Rethrows any errors thrown by the provided closure. |
74 | | - @available(*, deprecated, message: "Renamed to snapshot().") |
75 | | - public func withSnapshot<Failure: Error, Return: ~Copyable>( |
76 | | - _ body: (ConfigSnapshotReader) throws(Failure) -> Return |
77 | | - ) throws(Failure) -> Return { |
78 | | - let multiSnapshot = provider.snapshot() |
79 | | - let snapshotReader = ConfigSnapshotReader( |
80 | | - keyPrefix: keyPrefix, |
81 | | - storage: .init( |
82 | | - snapshot: multiSnapshot, |
83 | | - accessReporter: accessReporter |
84 | | - ) |
85 | | - ) |
86 | | - return try body(snapshotReader) |
87 | | - } |
88 | | -} |
| 15 | +// Put deprecated symbols here and they will be removed during the next API-break. |
0 commit comments