This commit is contained in:
Suresh, Kamlesh 2021-03-10 13:03:44 -05:00
parent 075ad53953
commit ecac8ede70
3 changed files with 8 additions and 9 deletions

View File

@ -15,20 +15,20 @@ public protocol ClientParameterProtocol {
var clientParameterModel: ClientParameterModelProtocol { get set }
func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ())
func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping ([String: AnyHashable]?) -> ())
/// Default parameter for timeout scenarios. It will use the protocol extension method bydefault. Can override to send custom values.
func valueOnTimeout() -> AnyHashable
func valueOnTimeout() -> [String: AnyHashable]
}
public extension ClientParameterProtocol {
func valueOnTimeout() -> AnyHashable {
func valueOnTimeout() -> [String: AnyHashable] {
return [Self.name: "failed_to_collect"]
}
/// The handler should call this method to pass the parameter back to the caller.
func returnParameters(_ isFlatMap: Bool, _ parameter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) {
func returnParameters(_ isFlatMap: Bool, _ parameter: [String: AnyHashable]?, completionHandler: @escaping ([String: AnyHashable]?) -> ()) {
guard let parameter = parameter else {
return completionHandler(nil)
}

View File

@ -78,7 +78,8 @@ import Foundation
for (index, item) in returnedList.enumerated() {
if let item = item {
parametersList = parametersList.merging(item) { (_, new) in new }
} else if let defaultValue = parameterHandlerList[index].valueOnTimeout() as? [String: AnyHashable] {
} else {
let defaultValue = parameterHandlerList[index].valueOnTimeout()
parametersList = parametersList.merging(defaultValue) { (_, new) in new }
}
}
@ -109,9 +110,7 @@ import Foundation
timingOutIn: timeout) { (receivedParameter) in
// Queue the results for merge.
parametersWorkQueue.async {
if let receivedParameter = receivedParameter as? [String: AnyHashable] {
returnedList[index] = receivedParameter
}
returnedList[index] = receivedParameter
group.leave() // Leaving is only done after setup (barriered).
}
}

View File

@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import "MVMCoreRequestParameters.h"
#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG
#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG
#if ENABLE_HARD_CODED_RESPONSE