Skip to content

Commit

Permalink
Logger Eventloop parameter ordering (#399)
Browse files Browse the repository at this point in the history
* Reorder public function parameters Logger and EventLoop

Place Logger before EventLoop. Will make moving to BaggageContext easier

* Re-order parameters in paginate command closure
  • Loading branch information
adam-fowler authored Nov 3, 2020
1 parent 56e93c5 commit 1638da0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
36 changes: 18 additions & 18 deletions Sources/SotoCore/AWSClient+Paginate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ extension AWSClient {
public func paginate<Input: AWSPaginateToken, Output: AWSShape, Result>(
input: Input,
initialValue: Result,
command: @escaping (Input, EventLoop?, Logger) -> EventLoopFuture<Output>,
command: @escaping (Input, Logger, EventLoop?) -> EventLoopFuture<Output>,
tokenKey: KeyPath<Output, Input.Token?>,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil,
onPage: @escaping (Result, Output, EventLoop) -> EventLoopFuture<(Bool, Result)>
) -> EventLoopFuture<Result> {
let eventLoop = eventLoop ?? eventLoopGroup.next()
let promise = eventLoop.makePromise(of: Result.self)

func paginatePart(input: Input, currentValue: Result) {
let responseFuture = command(input, eventLoop, logger)
let responseFuture = command(input, logger, eventLoop)
.flatMap { response in
return onPage(currentValue, response, eventLoop)
.map { continuePaginate, result -> Void in
Expand Down Expand Up @@ -85,13 +85,13 @@ extension AWSClient {
/// - onPage: closure called with each block of entries. Returns boolean indicating whether we should continue.
public func paginate<Input: AWSPaginateToken, Output: AWSShape>(
input: Input,
command: @escaping (Input, EventLoop?, Logger) -> EventLoopFuture<Output>,
command: @escaping (Input, Logger, EventLoop?) -> EventLoopFuture<Output>,
tokenKey: KeyPath<Output, Input.Token?>,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil,
onPage: @escaping (Output, EventLoop) -> EventLoopFuture<Bool>
) -> EventLoopFuture<Void> {
self.paginate(input: input, initialValue: (), command: command, tokenKey: tokenKey, on: eventLoop, logger: logger) { _, output, eventLoop in
self.paginate(input: input, initialValue: (), command: command, tokenKey: tokenKey, logger: logger, on: eventLoop) { _, output, eventLoop in
return onPage(output, eventLoop).map { rt in (rt, ()) }
}
}
Expand All @@ -114,18 +114,18 @@ extension AWSClient {
public func paginate<Input: AWSPaginateToken, Output: AWSShape, Result>(
input: Input,
initialValue: Result,
command: @escaping (Input, EventLoop?, Logger) -> EventLoopFuture<Output>,
command: @escaping (Input, Logger, EventLoop?) -> EventLoopFuture<Output>,
tokenKey: KeyPath<Output, Input.Token?>,
moreResultsKey: KeyPath<Output, Bool>,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil,
onPage: @escaping (Result, Output, EventLoop) -> EventLoopFuture<(Bool, Result)>
) -> EventLoopFuture<Result> {
let eventLoop = eventLoop ?? eventLoopGroup.next()
let promise = eventLoop.makePromise(of: Result.self)

func paginatePart(input: Input, currentValue: Result) {
let responseFuture = command(input, eventLoop, logger)
let responseFuture = command(input, logger, eventLoop)
.flatMap { response in
return onPage(currentValue, response, eventLoop)
.map { continuePaginate, result -> Void in
Expand Down Expand Up @@ -162,14 +162,14 @@ extension AWSClient {
/// - onPage: closure called with each block of entries. Returns boolean indicating whether we should continue.
public func paginate<Input: AWSPaginateToken, Output: AWSShape>(
input: Input,
command: @escaping (Input, EventLoop?, Logger) -> EventLoopFuture<Output>,
command: @escaping (Input, Logger, EventLoop?) -> EventLoopFuture<Output>,
tokenKey: KeyPath<Output, Input.Token?>,
moreResultsKey: KeyPath<Output, Bool>,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil,
onPage: @escaping (Output, EventLoop) -> EventLoopFuture<Bool>
) -> EventLoopFuture<Void> {
self.paginate(input: input, initialValue: (), command: command, tokenKey: tokenKey, moreResultsKey: moreResultsKey, on: eventLoop, logger: logger) { _, output, eventLoop in
self.paginate(input: input, initialValue: (), command: command, tokenKey: tokenKey, moreResultsKey: moreResultsKey, logger: logger, on: eventLoop) { _, output, eventLoop in
return onPage(output, eventLoop).map { rt in (rt, ()) }
}
}
Expand All @@ -192,18 +192,18 @@ extension AWSClient {
public func paginate<Input: AWSPaginateToken, Output: AWSShape, Result>(
input: Input,
initialValue: Result,
command: @escaping (Input, EventLoop?, Logger) -> EventLoopFuture<Output>,
command: @escaping (Input, Logger, EventLoop?) -> EventLoopFuture<Output>,
tokenKey: KeyPath<Output, Input.Token?>,
moreResultsKey: KeyPath<Output, Bool?>,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil,
onPage: @escaping (Result, Output, EventLoop) -> EventLoopFuture<(Bool, Result)>
) -> EventLoopFuture<Result> {
let eventLoop = eventLoop ?? eventLoopGroup.next()
let promise = eventLoop.makePromise(of: Result.self)

func paginatePart(input: Input, currentValue: Result) {
let responseFuture = command(input, eventLoop, logger)
let responseFuture = command(input, logger, eventLoop)
.flatMap { response in
return onPage(currentValue, response, eventLoop)
.map { continuePaginate, result -> Void in
Expand Down Expand Up @@ -240,14 +240,14 @@ extension AWSClient {
/// - onPage: closure called with each block of entries. Returns boolean indicating whether we should continue.
public func paginate<Input: AWSPaginateToken, Output: AWSShape>(
input: Input,
command: @escaping (Input, EventLoop?, Logger) -> EventLoopFuture<Output>,
command: @escaping (Input, Logger, EventLoop?) -> EventLoopFuture<Output>,
tokenKey: KeyPath<Output, Input.Token?>,
moreResultsKey: KeyPath<Output, Bool?>,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil,
onPage: @escaping (Output, EventLoop) -> EventLoopFuture<Bool>
) -> EventLoopFuture<Void> {
self.paginate(input: input, initialValue: (), command: command, tokenKey: tokenKey, moreResultsKey: moreResultsKey, on: eventLoop, logger: logger) { _, output, eventLoop in
self.paginate(input: input, initialValue: (), command: command, tokenKey: tokenKey, moreResultsKey: moreResultsKey, logger: logger, on: eventLoop) { _, output, eventLoop in
return onPage(output, eventLoop).map { rt in (rt, ()) }
}
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/SotoCore/AWSClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ extension AWSClient {
httpMethod: HTTPMethod,
serviceConfig: AWSServiceConfig,
input: Input,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil
) -> EventLoopFuture<Void> {
return execute(
operation: operationName,
Expand Down Expand Up @@ -283,8 +283,8 @@ extension AWSClient {
path: String,
httpMethod: HTTPMethod,
serviceConfig: AWSServiceConfig,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil
) -> EventLoopFuture<Void> {
return execute(
operation: operationName,
Expand Down Expand Up @@ -322,8 +322,8 @@ extension AWSClient {
path: String,
httpMethod: HTTPMethod,
serviceConfig: AWSServiceConfig,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil
) -> EventLoopFuture<Output> {
return execute(
operation: operationName,
Expand Down Expand Up @@ -363,8 +363,8 @@ extension AWSClient {
httpMethod: HTTPMethod,
serviceConfig: AWSServiceConfig,
input: Input,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil
) -> EventLoopFuture<Output> {
return execute(
operation: operationName,
Expand Down Expand Up @@ -405,8 +405,8 @@ extension AWSClient {
httpMethod: HTTPMethod,
serviceConfig: AWSServiceConfig,
input: Input,
on eventLoop: EventLoop? = nil,
logger: Logger = AWSClient.loggingDisabled,
on eventLoop: EventLoop? = nil,
stream: @escaping AWSHTTPClient.ResponseStream
) -> EventLoopFuture<Output> {
return execute(
Expand Down
4 changes: 2 additions & 2 deletions Tests/SotoCoreTests/AWSClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ class AWSClientTests: XCTestCase {
path: "/",
httpMethod: .POST,
serviceConfig: config,
on: eventLoop,
logger: TestEnvironment.logger
logger: TestEnvironment.logger,
on: eventLoop
)

try awsServer.processRaw { _ in
Expand Down
22 changes: 11 additions & 11 deletions Tests/SotoCoreTests/PaginateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ class PaginateTests: XCTestCase {
let outputToken: Int?
}

func counter(_ input: CounterInput, on eventLoop: EventLoop?, logger: Logger) -> EventLoopFuture<CounterOutput> {
func counter(_ input: CounterInput, logger: Logger, on eventLoop: EventLoop?) -> EventLoopFuture<CounterOutput> {
return self.client.execute(
operation: "TestOperation",
path: "/",
httpMethod: .POST,
serviceConfig: self.config,
input: input,
on: eventLoop,
logger: logger
logger: logger,
on: eventLoop
)
}

Expand Down Expand Up @@ -152,15 +152,15 @@ class PaginateTests: XCTestCase {
let moreResults: Bool
}

func stringList(_ input: StringListInput, on eventLoop: EventLoop? = nil, logger: Logger) -> EventLoopFuture<StringListOutput> {
func stringList(_ input: StringListInput, logger: Logger, on eventLoop: EventLoop? = nil) -> EventLoopFuture<StringListOutput> {
return self.client.execute(
operation: "TestOperation",
path: "/",
httpMethod: .POST,
serviceConfig: self.config,
input: input,
on: eventLoop,
logger: logger
logger: logger,
on: eventLoop
)
}

Expand All @@ -170,21 +170,21 @@ class PaginateTests: XCTestCase {
command: self.stringList,
tokenKey: \StringListOutput.outputToken,
moreResultsKey: \StringListOutput.moreResults,
on: eventLoop,
logger: TestEnvironment.logger,
on: eventLoop,
onPage: onPage
)
}

func stringList2(_ input: StringListInput, on eventLoop: EventLoop? = nil, logger: Logger) -> EventLoopFuture<StringList2Output> {
func stringList2(_ input: StringListInput, logger: Logger, on eventLoop: EventLoop? = nil) -> EventLoopFuture<StringList2Output> {
return self.client.execute(
operation: "TestOperation",
path: "/",
httpMethod: .POST,
serviceConfig: self.config,
input: input,
on: eventLoop,
logger: logger
logger: logger,
on: eventLoop
)
}

Expand All @@ -195,8 +195,8 @@ class PaginateTests: XCTestCase {
command: self.stringList2,
tokenKey: \StringList2Output.outputToken,
moreResultsKey: \StringList2Output.moreResults,
on: eventLoop,
logger: TestEnvironment.logger,
on: eventLoop,
onPage: onPage
)
}
Expand Down

0 comments on commit 1638da0

Please sign in to comment.