Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .drstring.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include = [
"library/swift/**/*.swift",
"library/swift/**.swift",
]
column-limit = 110
column-limit = 100
ignore-throws = true
first-letter = "lowercase"
vertical-align = true
Expand Down
2 changes: 1 addition & 1 deletion library/swift/Engine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public protocol Engine: AnyObject {
/// - returns: A client for opening and managing HTTP streams.
func streamClient() -> StreamClient

/// A client for recording time series metrics.
/// - returns: A client for recording time series metrics.
func pulseClient() -> PulseClient

/// Flush the stats sinks outside of a flushing interval.
Expand Down
20 changes: 15 additions & 5 deletions library/swift/EngineBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ open class EngineBuilder: NSObject {
/// Add a rate at which to refresh DNS in case of DNS failure.
///
/// - parameter base: Base rate in seconds.
/// - parameter max: Max rate in seconds.
/// - parameter max: Max rate in seconds.
///
/// - returns: This builder.
@discardableResult
Expand Down Expand Up @@ -304,7 +304,7 @@ open class EngineBuilder: NSObject {

/// Add a custom idle timeout for HTTP streams. Defaults to 15 seconds.
///
/// - parameter streamIdleSeconds: Idle timeout for HTTP streams.
/// - parameter streamIdleTimeoutSeconds: Idle timeout for HTTP streams.
///
/// - returns: This builder.
@discardableResult
Expand All @@ -315,7 +315,7 @@ open class EngineBuilder: NSObject {

/// Add a custom per try idle timeout for HTTP streams. Defaults to 15 seconds.
///
/// - parameter perTryIdleSeconds: Idle timeout for HTTP streams.
/// - parameter perTryIdleTimeoutSeconds: Idle timeout for HTTP streams.
///
/// - returns: This builder.
@discardableResult
Expand Down Expand Up @@ -370,7 +370,7 @@ open class EngineBuilder: NSObject {

/// Add a string accessor to this Envoy Client.
///
/// - parameter name: the name of the accessor.
/// - parameter name: the name of the accessor.
/// - parameter accessor: lambda to access a string from the platform layer.
///
/// - returns: This builder.
Expand All @@ -382,7 +382,7 @@ open class EngineBuilder: NSObject {

/// Register a key-value store implementation for internal use.
///
/// - parameter name: the name of the KV store.
/// - parameter name: the name of the KV store.
/// - parameter keyValueStore: the KV store implementation.
///
/// - returns: This builder.
Expand Down Expand Up @@ -428,6 +428,8 @@ open class EngineBuilder: NSObject {
/// Configure how the engine observes network reachability state changes.
/// Defaults to `.pathMonitor`.
///
/// - parameter mode: The mode to use.
///
/// - returns: This builder.
@discardableResult
public func setNetworkMonitoringMode(_ mode: NetworkMonitoringMode) -> Self {
Expand Down Expand Up @@ -481,6 +483,9 @@ open class EngineBuilder: NSObject {

/// Builds and runs a new `Engine` instance with the provided configuration.
///
/// - note: Must be strongly retained in order for network requests to be performed correctly.
///
/// - returns: The built `Engine`.
public func build() -> Engine {
let engine = self.engineType.init(runningCallback: self.onEngineRunning, logger: self.logger,
eventTracker: self.eventTracker,
Expand Down Expand Up @@ -539,6 +544,11 @@ open class EngineBuilder: NSObject {
/// A new instance of this engine will be created when `build()` is called.
/// Used for testing, as initializing with `EnvoyEngine.Type` results in a
/// segfault: https://github.com/envoyproxy/envoy-mobile/issues/334
///
/// - parameter engineType: The specific implementation of `EnvoyEngine` to use for starting
/// Envoy.
///
/// - returns: This builder.
@discardableResult
func addEngineType(_ engineType: EnvoyEngine.Type) -> Self {
self.engineType = engineType
Expand Down
14 changes: 7 additions & 7 deletions library/swift/EngineImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ final class EngineImpl: NSObject {

/// Initialize a new Envoy instance using a typed configuration.
///
/// - parameter config: Configuration to use for starting Envoy.
/// - parameter logLevel: Log level to use for this instance.
/// - parameter engine: The underlying engine to use for starting Envoy.
/// - parameter config: Configuration to use for starting Envoy.
/// - parameter logLevel: Log level to use for this instance.
/// - parameter engine: The underlying engine to use for starting Envoy.
convenience init(config: EnvoyConfiguration, logLevel: LogLevel = .info, engine: EnvoyEngine) {
self.init(configType: .standard(config: config), logLevel: logLevel, engine: engine)
}

/// Initialize a new Envoy instance using a string configuration.
///
/// - parameter yaml: Template yaml to use as basis for configuration.
/// - parameter config: Configuration to use for starting Envoy.
/// - parameter logLevel: Log level to use for this instance.
/// - parameter engine: The underlying engine to use for starting Envoy.
/// - parameter yaml: Template yaml to use as basis for configuration.
/// - parameter config: Configuration to use for starting Envoy.
/// - parameter logLevel: Log level to use for this instance.
/// - parameter engine: The underlying engine to use for starting Envoy.
convenience init(yaml: String, config: EnvoyConfiguration, logLevel: LogLevel = .info,
engine: EnvoyEngine)
{
Expand Down
4 changes: 2 additions & 2 deletions library/swift/HeadersBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class HeadersBuilder: NSObject {

/// Replace all values at the provided name with a new set of header values.
///
/// - parameter name: The header name.
/// - parameter name: The header name.
/// - parameter value: The value associated to the header name.
///
/// - returns: This builder.
Expand Down Expand Up @@ -63,7 +63,7 @@ public class HeadersBuilder: NSObject {

/// Allows for setting headers that are not publicly mutable (i.e., restricted headers).
///
/// - parameter name: The header name.
/// - parameter name: The header name.
/// - parameter value: The value associated to the header name.
///
/// - returns: This builder.
Expand Down
9 changes: 9 additions & 0 deletions library/swift/KeyValueStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ import Foundation
/// key-value store implementation that may be made accessible to native Envoy Mobile code.
public protocol KeyValueStore {
/// Read a value from the key value store implementation.
///
/// - parameter key: The key whose value should be read.
///
/// - returns: The value read for the key if it was found.
func readValue(forKey key: String) -> String?

/// Save a value to the key value store implementation.
///
/// - parameter value: The value to save.
/// - parameter key: The key to associate with the saved value.
func saveValue(_ value: String, toKey key: String)

/// Remove a value from the key value store implementation.
///
/// - parameter key: The key whose value should be removed.
func removeKey(_ key: String)
}

Expand Down
12 changes: 6 additions & 6 deletions library/swift/PulseClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public protocol PulseClient: AnyObject {
func counter(elements: [Element]) -> Counter

/// - parameter elements: Elements to identify a counter
/// - parameter tags: Tags of the counter
/// - parameter tags: Tags of the counter
///
/// - returns: A Counter based on the joined elements and along with tags
func counter(elements: [Element], tags: Tags) -> Counter
Expand All @@ -23,8 +23,8 @@ public protocol PulseClient: AnyObject {
func gauge(elements: [Element]) -> Gauge

/// - parameter elements: Elements to identify a gauge
/// - parameter tags: Tags of the gauge
/// -
/// - parameter tags: Tags of the gauge
///
/// - returns: A Gauge based on the joined elements and along with tags
func gauge(elements: [Element], tags: Tags) -> Gauge

Expand All @@ -34,10 +34,10 @@ public protocol PulseClient: AnyObject {
func timer(elements: [Element]) -> Timer

/// - parameter elements: Elements to identify a timer
/// - parameter tags: Tags of the timer
/// - parameter tags: Tags of the timer
///
/// - returns: A Timer based on the joined elements and with tags
/// to track a distribution of durations
/// to track a distribution of durations
func timer(elements: [Element], tags: Tags) -> Timer

/// - parameter elements: Elements to identify a distribution
Expand All @@ -46,7 +46,7 @@ public protocol PulseClient: AnyObject {
func distribution(elements: [Element]) -> Distribution

/// - parameter elements: Elements to identify a distribution
/// - parameter tags: Tags of the distribution
/// - parameter tags: Tags of the distribution
///
/// - returns: A Distribution based on the joined elements and along with tags
func distribution(elements: [Element], tags: Tags) -> Distribution
Expand Down
2 changes: 2 additions & 0 deletions library/swift/RetryPolicyMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ extension RetryPolicy {
/// Initialize the retry policy from a set of headers.
///
/// - parameter headers: The headers with which to initialize the retry policy.
///
/// - returns: The `RetryPolicy` if one was derived from the headers.
static func from(headers: Headers) -> RetryPolicy? {
guard let maxRetryCount = headers.value(forName: "x-envoy-max-retries")?
.first.flatMap(UInt.init) else
Expand Down
3 changes: 2 additions & 1 deletion library/swift/StreamPrototype.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public class StreamPrototype: NSObject {
/// reduced overall throughput, depending on usage.
///
/// - parameter enabled: Whether explicit flow control will be enabled for the stream.
/// - returns: This stream, for chaining syntax.
///
/// - returns: This stream, for chaining syntax.
public func setExplicitFlowControl(enabled: Bool) -> StreamPrototype {
self.explicitFlowControl = enabled
return self
Expand Down