Merge branch 'bugfix/marketingCloudVisitorId_client_param_timeouts' into 'develop'
Address ClientParameter timeout logging issues ### Summary Update timeout signature to use standard TimeInterval for split second handling. See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core/-/merge_requests/289
This commit is contained in:
commit
77ab27d79d
@ -104,13 +104,17 @@
|
|||||||
timingOutIn: timeout) { (receivedParameter) in
|
timingOutIn: timeout) { (receivedParameter) in
|
||||||
// Queue the results for merge.
|
// Queue the results for merge.
|
||||||
parametersWorkQueue.async {
|
parametersWorkQueue.async {
|
||||||
if (returnedList[index] != nil) {
|
guard !complete else {
|
||||||
MVMCoreLoggingHandler.addError(toLog: MVMCoreErrorObject(title: nil, message: "Client parameter \(parameterType) has already executed. The completion handler should only be called once!", code: ErrorCode.default.rawValue, domain: ErrorDomainNative, location: String(describing: ClientParameterHandler.self))!)
|
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Client \(parameterType) responded after task completion.")
|
||||||
} else {
|
return
|
||||||
MVMCoreLoggingHandler.shared()?.logCoreEvent(.clientParameterFetchComplete(name: parameterType, uuid: requestUUID[index], actionId: actionId))
|
|
||||||
returnedList[index] = receivedParameter
|
|
||||||
group.leave() // Leaving is only done after setup (barriered).
|
|
||||||
}
|
}
|
||||||
|
guard returnedList[index] == nil else {
|
||||||
|
MVMCoreLoggingHandler.addError(toLog: MVMCoreErrorObject(title: nil, message: "Client parameter \(parameterType) has already executed. The completion handler should only be called once!", code: ErrorCode.default.rawValue, domain: ErrorDomainNative, location: String(describing: ClientParameterHandler.self))!)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
MVMCoreLoggingHandler.shared()?.logCoreEvent(.clientParameterFetchComplete(name: parameterType, uuid: requestUUID[index], actionId: actionId))
|
||||||
|
returnedList[index] = receivedParameter
|
||||||
|
group.leave() // Leaving is only done after setup (barriered).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public protocol ClientParameterProtocol: ModelHandlerProtocol {
|
|||||||
|
|
||||||
var clientParameterModel: ClientParameterModelProtocol { get set }
|
var clientParameterModel: ClientParameterModelProtocol { get set }
|
||||||
|
|
||||||
func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping ([String: AnyHashable]?) -> ())
|
func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: TimeInterval, completionHandler:@escaping ([String: AnyHashable]?) -> ())
|
||||||
|
|
||||||
/// Default parameter for timeout scenarios. It will use the protocol extension method bydefault. Can override to send custom values.
|
/// Default parameter for timeout scenarios. It will use the protocol extension method bydefault. Can override to send custom values.
|
||||||
func valueOnTimeout() -> [String: AnyHashable]
|
func valueOnTimeout() -> [String: AnyHashable]
|
||||||
@ -28,10 +28,8 @@ public extension ClientParameterProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The handler should call this method to pass the parameter back to the caller.
|
/// The handler should call this method to pass the parameter back to the caller.
|
||||||
func returnParameters(_ isFlatMap: Bool, _ parameter: [String: AnyHashable]?, completionHandler: @escaping ([String: AnyHashable]?) -> ()) {
|
/// If using isFlatMap, you must provide at least 1 element in parameters or it will result in triggering a timeout.
|
||||||
guard let parameter = parameter else {
|
func returnParameters(_ isFlatMap: Bool, _ parameter: [String: AnyHashable], completionHandler: @escaping ([String: AnyHashable]?) -> ()) {
|
||||||
return completionHandler(nil)
|
|
||||||
}
|
|
||||||
if isFlatMap {
|
if isFlatMap {
|
||||||
completionHandler(parameter)
|
completionHandler(parameter)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public extension MVMCoreActionUtility {
|
|||||||
- Parameter timemout: the time the operation has to finish before throwing a timeout error.
|
- Parameter timemout: the time the operation has to finish before throwing a timeout error.
|
||||||
- Parameter operation: the operation to perform.
|
- Parameter operation: the operation to perform.
|
||||||
*/
|
*/
|
||||||
static func perform<T>(with timeout: Int = 1, operation: @escaping @Sendable () async throws -> T) async throws -> T {
|
static func perform<T>(withTimeout timeout: TimeInterval, operation: @escaping @Sendable () async throws -> T) async throws -> T {
|
||||||
return try await withCheckedThrowingContinuation { continuation in
|
return try await withCheckedThrowingContinuation { continuation in
|
||||||
Task {
|
Task {
|
||||||
await withThrowingTaskGroup(of: T.self) { group in
|
await withThrowingTaskGroup(of: T.self) { group in
|
||||||
@ -40,7 +40,7 @@ public extension MVMCoreActionUtility {
|
|||||||
// Task for time out.
|
// Task for time out.
|
||||||
group.addTask {
|
group.addTask {
|
||||||
try Task.checkCancellation()
|
try Task.checkCancellation()
|
||||||
try await Task.sleep(nanoseconds: UInt64(timeout) * NSEC_PER_SEC)
|
try await Task.sleep(nanoseconds: UInt64(timeout * TimeInterval(NSEC_PER_SEC)))
|
||||||
throw MVMCoreActionUtilityError.timeOut
|
throw MVMCoreActionUtilityError.timeOut
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user