Added ConfigureAwait to (hopefully) all awaits
Ugly as heck, but it's recommended for libraries
This commit is contained in:
parent
db9e957726
commit
a0c9d97694
@ -44,14 +44,14 @@ namespace Tapeti.Flow.SQL
|
|||||||
{
|
{
|
||||||
return await SqlRetryHelper.Execute(async () =>
|
return await SqlRetryHelper.Execute(async () =>
|
||||||
{
|
{
|
||||||
using (var connection = await GetConnection())
|
using var connection = await GetConnection().ConfigureAwait(false);
|
||||||
{
|
|
||||||
var flowQuery = new SqlCommand($"select FlowID, CreationTime, StateJson from {tableName}", connection);
|
var flowQuery = new SqlCommand($"select FlowID, CreationTime, StateJson from {tableName}", connection);
|
||||||
var flowReader = await flowQuery.ExecuteReaderAsync();
|
var flowReader = await flowQuery.ExecuteReaderAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
var result = new List<FlowRecord<T>>();
|
var result = new List<FlowRecord<T>>();
|
||||||
|
|
||||||
while (await flowReader.ReadAsync())
|
while (await flowReader.ReadAsync().ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
var flowID = flowReader.GetGuid(0);
|
var flowID = flowReader.GetGuid(0);
|
||||||
var creationTime = flowReader.GetDateTime(1);
|
var creationTime = flowReader.GetDateTime(1);
|
||||||
@ -63,8 +63,7 @@ namespace Tapeti.Flow.SQL
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}).ConfigureAwait(false);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -72,8 +71,8 @@ namespace Tapeti.Flow.SQL
|
|||||||
{
|
{
|
||||||
await SqlRetryHelper.Execute(async () =>
|
await SqlRetryHelper.Execute(async () =>
|
||||||
{
|
{
|
||||||
using (var connection = await GetConnection())
|
using var connection = await GetConnection().ConfigureAwait(false);
|
||||||
{
|
|
||||||
var query = new SqlCommand($"insert into {tableName} (FlowID, StateJson, CreationTime)" +
|
var query = new SqlCommand($"insert into {tableName} (FlowID, StateJson, CreationTime)" +
|
||||||
"values (@FlowID, @StateJson, @CreationTime)",
|
"values (@FlowID, @StateJson, @CreationTime)",
|
||||||
connection);
|
connection);
|
||||||
@ -86,9 +85,8 @@ namespace Tapeti.Flow.SQL
|
|||||||
stateJsonParam.Value = JsonConvert.SerializeObject(state);
|
stateJsonParam.Value = JsonConvert.SerializeObject(state);
|
||||||
creationTimeParam.Value = timestamp;
|
creationTimeParam.Value = timestamp;
|
||||||
|
|
||||||
await query.ExecuteNonQueryAsync();
|
await query.ExecuteNonQueryAsync().ConfigureAwait(false);
|
||||||
}
|
}).ConfigureAwait(false);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -96,8 +94,8 @@ namespace Tapeti.Flow.SQL
|
|||||||
{
|
{
|
||||||
await SqlRetryHelper.Execute(async () =>
|
await SqlRetryHelper.Execute(async () =>
|
||||||
{
|
{
|
||||||
using (var connection = await GetConnection())
|
using var connection = await GetConnection().ConfigureAwait(false);
|
||||||
{
|
|
||||||
var query = new SqlCommand($"update {tableName} set StateJson = @StateJson where FlowID = @FlowID", connection);
|
var query = new SqlCommand($"update {tableName} set StateJson = @StateJson where FlowID = @FlowID", connection);
|
||||||
|
|
||||||
var flowIDParam = query.Parameters.Add("@FlowID", SqlDbType.UniqueIdentifier);
|
var flowIDParam = query.Parameters.Add("@FlowID", SqlDbType.UniqueIdentifier);
|
||||||
@ -106,9 +104,8 @@ namespace Tapeti.Flow.SQL
|
|||||||
flowIDParam.Value = flowID;
|
flowIDParam.Value = flowID;
|
||||||
stateJsonParam.Value = JsonConvert.SerializeObject(state);
|
stateJsonParam.Value = JsonConvert.SerializeObject(state);
|
||||||
|
|
||||||
await query.ExecuteNonQueryAsync();
|
await query.ExecuteNonQueryAsync().ConfigureAwait(false);
|
||||||
}
|
}).ConfigureAwait(false);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -116,23 +113,22 @@ namespace Tapeti.Flow.SQL
|
|||||||
{
|
{
|
||||||
await SqlRetryHelper.Execute(async () =>
|
await SqlRetryHelper.Execute(async () =>
|
||||||
{
|
{
|
||||||
using (var connection = await GetConnection())
|
using var connection = await GetConnection().ConfigureAwait(false);
|
||||||
{
|
|
||||||
var query = new SqlCommand($"delete from {tableName} where FlowID = @FlowID", connection);
|
var query = new SqlCommand($"delete from {tableName} where FlowID = @FlowID", connection);
|
||||||
|
|
||||||
var flowIDParam = query.Parameters.Add("@FlowID", SqlDbType.UniqueIdentifier);
|
var flowIDParam = query.Parameters.Add("@FlowID", SqlDbType.UniqueIdentifier);
|
||||||
flowIDParam.Value = flowID;
|
flowIDParam.Value = flowID;
|
||||||
|
|
||||||
await query.ExecuteNonQueryAsync();
|
await query.ExecuteNonQueryAsync().ConfigureAwait(false);
|
||||||
}
|
}).ConfigureAwait(false);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task<SqlConnection> GetConnection()
|
private async Task<SqlConnection> GetConnection()
|
||||||
{
|
{
|
||||||
var connection = new SqlConnection(connectionString);
|
var connection = new SqlConnection(connectionString);
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
@ -27,14 +27,14 @@ namespace Tapeti.Flow.SQL
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await callback();
|
await callback().ConfigureAwait(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (SqlException e)
|
catch (SqlException e)
|
||||||
{
|
{
|
||||||
if (SqlExceptionHelper.IsTransientError(e))
|
if (SqlExceptionHelper.IsTransientError(e))
|
||||||
{
|
{
|
||||||
await Task.Delay(ExponentialBackoff[retryAttempt]);
|
await Task.Delay(ExponentialBackoff[retryAttempt]).ConfigureAwait(false);
|
||||||
if (retryAttempt < ExponentialBackoff.Length - 1)
|
if (retryAttempt < ExponentialBackoff.Length - 1)
|
||||||
retryAttempt++;
|
retryAttempt++;
|
||||||
}
|
}
|
||||||
@ -51,8 +51,8 @@ namespace Tapeti.Flow.SQL
|
|||||||
|
|
||||||
await Execute(async () =>
|
await Execute(async () =>
|
||||||
{
|
{
|
||||||
returnValue = await callback();
|
returnValue = await callback().ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
return returnValue!;
|
return returnValue!;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace Tapeti.Flow.Default
|
|||||||
|
|
||||||
public async Task Execute(FlowContext context)
|
public async Task Execute(FlowContext context)
|
||||||
{
|
{
|
||||||
await onExecute(context);
|
await onExecute(context).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,8 @@ namespace Tapeti.Flow.Default
|
|||||||
if (value == null)
|
if (value == null)
|
||||||
throw new InvalidOperationException("Return value should be a Task, not null");
|
throw new InvalidOperationException("Return value should be a Task, not null");
|
||||||
|
|
||||||
await (Task)value;
|
await ((Task)value).ConfigureAwait(false);
|
||||||
await HandleParallelResponse(messageContext);
|
await HandleParallelResponse(messageContext).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (context.Result.Info.ParameterType == typeof(ValueTask))
|
else if (context.Result.Info.ParameterType == typeof(ValueTask))
|
||||||
@ -73,8 +73,8 @@ namespace Tapeti.Flow.Default
|
|||||||
// ValueTask is a struct and should never be null
|
// ValueTask is a struct and should never be null
|
||||||
throw new UnreachableException("Return value should be a ValueTask, not null");
|
throw new UnreachableException("Return value should be a ValueTask, not null");
|
||||||
|
|
||||||
await (ValueTask)value;
|
await ((ValueTask)value).ConfigureAwait(false);
|
||||||
await HandleParallelResponse(messageContext);
|
await HandleParallelResponse(messageContext).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (context.Result.Info.ParameterType == typeof(void))
|
else if (context.Result.Info.ParameterType == typeof(void))
|
||||||
@ -116,8 +116,8 @@ namespace Tapeti.Flow.Default
|
|||||||
if (value == null)
|
if (value == null)
|
||||||
throw new InvalidOperationException("Return value should be a Task<IYieldPoint>, not null");
|
throw new InvalidOperationException("Return value should be a Task<IYieldPoint>, not null");
|
||||||
|
|
||||||
var yieldPoint = await (Task<IYieldPoint>)value;
|
var yieldPoint = await ((Task<IYieldPoint>)value).ConfigureAwait(false);
|
||||||
await HandleYieldPoint(messageContext, yieldPoint);
|
await HandleYieldPoint(messageContext, yieldPoint).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -128,8 +128,8 @@ namespace Tapeti.Flow.Default
|
|||||||
// ValueTask is a struct and should never be null
|
// ValueTask is a struct and should never be null
|
||||||
throw new UnreachableException("Return value should be a ValueTask<IYieldPoint>, not null");
|
throw new UnreachableException("Return value should be a ValueTask<IYieldPoint>, not null");
|
||||||
|
|
||||||
var yieldPoint = await (ValueTask<IYieldPoint>)value;
|
var yieldPoint = await ((ValueTask<IYieldPoint>)value).ConfigureAwait(false);
|
||||||
await HandleYieldPoint(messageContext, yieldPoint);
|
await HandleYieldPoint(messageContext, yieldPoint).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ namespace Tapeti.Flow.Default
|
|||||||
{
|
{
|
||||||
// IFlowParallelRequest.AddRequest will store the flow immediately
|
// IFlowParallelRequest.AddRequest will store the flow immediately
|
||||||
if (!flowPayload.FlowContext.IsStoredOrDeleted())
|
if (!flowPayload.FlowContext.IsStoredOrDeleted())
|
||||||
await flowContext.Store(context.Binding.QueueType == QueueType.Durable);
|
await flowContext.Store(context.Binding.QueueType == QueueType.Durable).ConfigureAwait(false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,14 +16,14 @@ namespace Tapeti.Flow.Default
|
|||||||
if (!context.TryGet<ControllerMessageContextPayload>(out var controllerPayload))
|
if (!context.TryGet<ControllerMessageContextPayload>(out var controllerPayload))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var flowContext = await EnrichWithFlowContext(context);
|
var flowContext = await EnrichWithFlowContext(context).ConfigureAwait(false);
|
||||||
if (flowContext?.ContinuationMetadata == null)
|
if (flowContext?.ContinuationMetadata == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (flowContext.ContinuationMetadata.MethodName != MethodSerializer.Serialize(controllerPayload.Binding.Method))
|
if (flowContext.ContinuationMetadata.MethodName != MethodSerializer.Serialize(controllerPayload.Binding.Method))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await next();
|
await next().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -44,22 +44,22 @@ namespace Tapeti.Flow.Default
|
|||||||
// Remove Continuation now because the IYieldPoint result handler will store the new state
|
// Remove Continuation now because the IYieldPoint result handler will store the new state
|
||||||
flowContext.FlowState.Continuations.Remove(flowContext.ContinuationID);
|
flowContext.FlowState.Continuations.Remove(flowContext.ContinuationID);
|
||||||
|
|
||||||
await next();
|
await next().ConfigureAwait(false);
|
||||||
|
|
||||||
if (flowPayload.FlowIsConverging)
|
if (flowPayload.FlowIsConverging)
|
||||||
{
|
{
|
||||||
var flowHandler = flowContext.HandlerContext.Config.DependencyResolver.Resolve<IFlowHandler>();
|
var flowHandler = flowContext.HandlerContext.Config.DependencyResolver.Resolve<IFlowHandler>();
|
||||||
await flowHandler.Converge(new FlowHandlerContext(context));
|
await flowHandler.Converge(new FlowHandlerContext(context)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await next();
|
await next().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async ValueTask Cleanup(IMessageContext context, ConsumeResult consumeResult, Func<ValueTask> next)
|
public async ValueTask Cleanup(IMessageContext context, ConsumeResult consumeResult, Func<ValueTask> next)
|
||||||
{
|
{
|
||||||
await next();
|
await next().ConfigureAwait(false);
|
||||||
|
|
||||||
if (!context.TryGet<ControllerMessageContextPayload>(out var controllerPayload))
|
if (!context.TryGet<ControllerMessageContextPayload>(out var controllerPayload))
|
||||||
return;
|
return;
|
||||||
@ -78,7 +78,7 @@ namespace Tapeti.Flow.Default
|
|||||||
if (!flowContext.IsStoredOrDeleted())
|
if (!flowContext.IsStoredOrDeleted())
|
||||||
// The exception strategy can set the consume result to Success. Instead, check if the yield point
|
// The exception strategy can set the consume result to Success. Instead, check if the yield point
|
||||||
// was handled. The flow provider ensures we only end up here in case of an exception.
|
// was handled. The flow provider ensures we only end up here in case of an exception.
|
||||||
await flowContext.FlowStateLock.DeleteFlowState();
|
await flowContext.FlowStateLock.DeleteFlowState().ConfigureAwait(false);
|
||||||
|
|
||||||
flowContext.FlowStateLock.Dispose();
|
flowContext.FlowStateLock.Dispose();
|
||||||
}
|
}
|
||||||
@ -100,13 +100,13 @@ namespace Tapeti.Flow.Default
|
|||||||
|
|
||||||
var flowStore = context.Config.DependencyResolver.Resolve<IFlowStore>();
|
var flowStore = context.Config.DependencyResolver.Resolve<IFlowStore>();
|
||||||
|
|
||||||
var flowID = await flowStore.FindFlowID(continuationID);
|
var flowID = await flowStore.FindFlowID(continuationID).ConfigureAwait(false);
|
||||||
if (!flowID.HasValue)
|
if (!flowID.HasValue)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var flowStateLock = await flowStore.LockFlowState(flowID.Value);
|
var flowStateLock = await flowStore.LockFlowState(flowID.Value).ConfigureAwait(false);
|
||||||
|
|
||||||
var flowState = await flowStateLock.GetFlowState();
|
var flowState = await flowStateLock.GetFlowState().ConfigureAwait(false);
|
||||||
if (flowState == null)
|
if (flowState == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace Tapeti.Flow.Default
|
|||||||
{
|
{
|
||||||
if (!context.HasFlowStateAndLock)
|
if (!context.HasFlowStateAndLock)
|
||||||
{
|
{
|
||||||
await CreateNewFlowState(context);
|
await CreateNewFlowState(context).ConfigureAwait(false);
|
||||||
Debug.Assert(context.FlowState != null, "context.FlowState != null");
|
Debug.Assert(context.FlowState != null, "context.FlowState != null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,10 +103,10 @@ namespace Tapeti.Flow.Default
|
|||||||
internal async Task SendRequest(FlowContext context, object message, ResponseHandlerInfo responseHandlerInfo,
|
internal async Task SendRequest(FlowContext context, object message, ResponseHandlerInfo responseHandlerInfo,
|
||||||
string? convergeMethodName = null, bool convergeMethodTaskSync = false)
|
string? convergeMethodName = null, bool convergeMethodTaskSync = false)
|
||||||
{
|
{
|
||||||
var properties = await PrepareRequest(context, responseHandlerInfo, convergeMethodName, convergeMethodTaskSync);
|
var properties = await PrepareRequest(context, responseHandlerInfo, convergeMethodName, convergeMethodTaskSync).ConfigureAwait(false);
|
||||||
await context.Store(responseHandlerInfo.IsDurableQueue);
|
await context.Store(responseHandlerInfo.IsDurableQueue).ConfigureAwait(false);
|
||||||
|
|
||||||
await publisher.Publish(message, properties, true);
|
await publisher.Publish(message, properties, true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,17 +129,17 @@ namespace Tapeti.Flow.Default
|
|||||||
|
|
||||||
// TODO disallow if replyto is not specified?
|
// TODO disallow if replyto is not specified?
|
||||||
if (reply.ReplyTo != null)
|
if (reply.ReplyTo != null)
|
||||||
await publisher.PublishDirect(message, reply.ReplyTo, properties, reply.Mandatory);
|
await publisher.PublishDirect(message, reply.ReplyTo, properties, reply.Mandatory).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await publisher.Publish(message, properties, reply.Mandatory);
|
await publisher.Publish(message, properties, reply.Mandatory).ConfigureAwait(false);
|
||||||
|
|
||||||
await context.Delete();
|
await context.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static async Task EndFlow(FlowContext context)
|
internal static async Task EndFlow(FlowContext context)
|
||||||
{
|
{
|
||||||
await context.Delete();
|
await context.Delete().ConfigureAwait(false);
|
||||||
|
|
||||||
if (context is { HasFlowStateAndLock: true, FlowState.Metadata.Reply: { } })
|
if (context is { HasFlowStateAndLock: true, FlowState.Metadata.Reply: { } })
|
||||||
throw new YieldPointException($"Flow must end with a response message of type {context.FlowState.Metadata.Reply.ResponseTypeName}");
|
throw new YieldPointException($"Flow must end with a response message of type {context.FlowState.Metadata.Reply.ResponseTypeName}");
|
||||||
@ -194,7 +194,7 @@ namespace Tapeti.Flow.Default
|
|||||||
var flowStore = flowContext.HandlerContext.Config.DependencyResolver.Resolve<IFlowStore>();
|
var flowStore = flowContext.HandlerContext.Config.DependencyResolver.Resolve<IFlowStore>();
|
||||||
|
|
||||||
var flowID = Guid.NewGuid();
|
var flowID = Guid.NewGuid();
|
||||||
var flowStateLock = await flowStore.LockFlowState(flowID);
|
var flowStateLock = await flowStore.LockFlowState(flowID).ConfigureAwait(false);
|
||||||
|
|
||||||
if (flowStateLock == null)
|
if (flowStateLock == null)
|
||||||
throw new InvalidOperationException("Unable to lock a new flow");
|
throw new InvalidOperationException("Unable to lock a new flow");
|
||||||
@ -232,7 +232,7 @@ namespace Tapeti.Flow.Default
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await executableYieldPoint.Execute(flowContext);
|
await executableYieldPoint.Execute(flowContext).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (YieldPointException e)
|
catch (YieldPointException e)
|
||||||
{
|
{
|
||||||
@ -272,7 +272,7 @@ namespace Tapeti.Flow.Default
|
|||||||
if (flowContext.ContinuationMetadata.ConvergeMethodName == null)
|
if (flowContext.ContinuationMetadata.ConvergeMethodName == null)
|
||||||
throw new InvalidOperationException("Missing ConvergeMethodName in FlowContext ContinuationMetadata");
|
throw new InvalidOperationException("Missing ConvergeMethodName in FlowContext ContinuationMetadata");
|
||||||
|
|
||||||
await Converge(flowContext, flowContext.ContinuationMetadata.ConvergeMethodName, flowContext.ContinuationMetadata.ConvergeMethodSync);
|
await Converge(flowContext, flowContext.ContinuationMetadata.ConvergeMethodName, flowContext.ContinuationMetadata.ConvergeMethodSync).ConfigureAwait(false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,13 +305,13 @@ namespace Tapeti.Flow.Default
|
|||||||
if (yieldPointTask == null)
|
if (yieldPointTask == null)
|
||||||
throw new YieldPointException($"Yield point is required in controller {controllerPayload.Controller.GetType().Name} for converge method {convergeMethodName}");
|
throw new YieldPointException($"Yield point is required in controller {controllerPayload.Controller.GetType().Name} for converge method {convergeMethodName}");
|
||||||
|
|
||||||
yieldPoint = await (Task<IYieldPoint>)yieldPointTask;
|
yieldPoint = await ((Task<IYieldPoint>)yieldPointTask).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yieldPoint == null)
|
if (yieldPoint == null)
|
||||||
throw new YieldPointException($"Yield point is required in controller {controllerPayload.Controller.GetType().Name} for converge method {convergeMethodName}");
|
throw new YieldPointException($"Yield point is required in controller {controllerPayload.Controller.GetType().Name} for converge method {convergeMethodName}");
|
||||||
|
|
||||||
await Execute(flowContext.HandlerContext, yieldPoint);
|
await Execute(flowContext.HandlerContext, yieldPoint).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -424,13 +424,13 @@ namespace Tapeti.Flow.Default
|
|||||||
context,
|
context,
|
||||||
requestInfo.ResponseHandlerInfo,
|
requestInfo.ResponseHandlerInfo,
|
||||||
convergeMethod.Method.Name,
|
convergeMethod.Method.Name,
|
||||||
convergeMethodSync);
|
convergeMethodSync).ConfigureAwait(false);
|
||||||
|
|
||||||
preparedRequests.Add(new PreparedRequest(requestInfo.Message, properties));
|
preparedRequests.Add(new PreparedRequest(requestInfo.Message, properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
await context.Store(requests.Any(i => i.ResponseHandlerInfo.IsDurableQueue));
|
await context.Store(requests.Any(i => i.ResponseHandlerInfo.IsDurableQueue)).ConfigureAwait(false);
|
||||||
await Task.WhenAll(preparedRequests.Select(r => publisher.Publish(r.Message, r.Properties, true)));
|
await Task.WhenAll(preparedRequests.Select(r => publisher.Publish(r.Message, r.Properties, true))).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,25 +25,25 @@ namespace Tapeti.Flow.Default
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task Start<TController>(Expression<Func<TController, Func<IYieldPoint>>> methodSelector) where TController : class
|
public async Task Start<TController>(Expression<Func<TController, Func<IYieldPoint>>> methodSelector) where TController : class
|
||||||
{
|
{
|
||||||
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), Array.Empty<object?>());
|
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), Array.Empty<object?>()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task Start<TController>(Expression<Func<TController, Func<Task<IYieldPoint>>>> methodSelector) where TController : class
|
public async Task Start<TController>(Expression<Func<TController, Func<Task<IYieldPoint>>>> methodSelector) where TController : class
|
||||||
{
|
{
|
||||||
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => (Task<IYieldPoint>)value, Array.Empty<object?>());
|
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => (Task<IYieldPoint>)value, Array.Empty<object?>()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task Start<TController, TParameter>(Expression<Func<TController, Func<TParameter, IYieldPoint>>> methodSelector, TParameter parameter) where TController : class
|
public async Task Start<TController, TParameter>(Expression<Func<TController, Func<TParameter, IYieldPoint>>> methodSelector, TParameter parameter) where TController : class
|
||||||
{
|
{
|
||||||
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), new object?[] {parameter});
|
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), new object?[] {parameter}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task Start<TController, TParameter>(Expression<Func<TController, Func<TParameter, Task<IYieldPoint>>>> methodSelector, TParameter parameter) where TController : class
|
public async Task Start<TController, TParameter>(Expression<Func<TController, Func<TParameter, Task<IYieldPoint>>>> methodSelector, TParameter parameter) where TController : class
|
||||||
{
|
{
|
||||||
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => (Task<IYieldPoint>)value, new object?[] {parameter});
|
await CallControllerMethod<TController>(GetExpressionMethod(methodSelector), value => (Task<IYieldPoint>)value, new object?[] {parameter}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,12 +54,12 @@ namespace Tapeti.Flow.Default
|
|||||||
if (result == null)
|
if (result == null)
|
||||||
throw new InvalidOperationException($"Method {method.Name} must return an IYieldPoint or Task<IYieldPoint>, got null");
|
throw new InvalidOperationException($"Method {method.Name} must return an IYieldPoint or Task<IYieldPoint>, got null");
|
||||||
|
|
||||||
var yieldPoint = await getYieldPointResult(result);
|
var yieldPoint = await getYieldPointResult(result).ConfigureAwait(false);
|
||||||
|
|
||||||
var context = new FlowHandlerContext(config, controller, method);
|
var context = new FlowHandlerContext(config, controller, method);
|
||||||
|
|
||||||
var flowHandler = config.DependencyResolver.Resolve<IFlowHandler>();
|
var flowHandler = config.DependencyResolver.Resolve<IFlowHandler>();
|
||||||
await flowHandler.Execute(context, yieldPoint);
|
await flowHandler.Execute(context, yieldPoint).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace Tapeti.Flow.Default
|
|||||||
validatedMethods = new HashSet<string>();
|
validatedMethods = new HashSet<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var flowStateRecord in await repository.GetStates<FlowState>())
|
foreach (var flowStateRecord in await repository.GetStates<FlowState>().ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
flowStates.TryAdd(flowStateRecord.FlowID, new CachedFlowState(flowStateRecord.FlowState, flowStateRecord.CreationTime, true));
|
flowStates.TryAdd(flowStateRecord.FlowID, new CachedFlowState(flowStateRecord.FlowState, flowStateRecord.CreationTime, true));
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ namespace Tapeti.Flow.Default
|
|||||||
|
|
||||||
inUse = true;
|
inUse = true;
|
||||||
|
|
||||||
var flowStatelock = new FlowStateLock(this, flowID, await locks.GetLock(flowID));
|
var flowStatelock = new FlowStateLock(this, flowID, await locks.GetLock(flowID).ConfigureAwait(false));
|
||||||
return flowStatelock;
|
return flowStatelock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,18 +215,18 @@ namespace Tapeti.Flow.Default
|
|||||||
// Storing the flowstate in the underlying repository
|
// Storing the flowstate in the underlying repository
|
||||||
if (isNew)
|
if (isNew)
|
||||||
{
|
{
|
||||||
await owner.repository.CreateState(FlowID, cachedFlowState.FlowState, cachedFlowState.CreationTime);
|
await owner.repository.CreateState(FlowID, cachedFlowState.FlowState, cachedFlowState.CreationTime).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await owner.repository.UpdateState(FlowID, cachedFlowState.FlowState);
|
await owner.repository.UpdateState(FlowID, cachedFlowState.FlowState).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (wasPersistent)
|
else if (wasPersistent)
|
||||||
{
|
{
|
||||||
// We transitioned from a durable queue to a dynamic queue,
|
// We transitioned from a durable queue to a dynamic queue,
|
||||||
// remove the persistent state but keep the in-memory version
|
// remove the persistent state but keep the in-memory version
|
||||||
await owner.repository.DeleteState(FlowID);
|
await owner.repository.DeleteState(FlowID).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ namespace Tapeti.Flow.Default
|
|||||||
cachedFlowState = null;
|
cachedFlowState = null;
|
||||||
|
|
||||||
if (removedFlowState is { IsPersistent: true })
|
if (removedFlowState is { IsPersistent: true })
|
||||||
await owner.repository.DeleteState(FlowID);
|
await owner.repository.DeleteState(FlowID).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ namespace Tapeti.Serilog.Middleware
|
|||||||
|
|
||||||
stopwatch.Start();
|
stopwatch.Start();
|
||||||
|
|
||||||
await next();
|
await next().ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
|
@ -32,7 +32,7 @@ namespace Tapeti.Transient
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async ValueTask Apply(IBindingTarget target)
|
public async ValueTask Apply(IBindingTarget target)
|
||||||
{
|
{
|
||||||
QueueName = await target.BindDynamicDirect(dynamicQueuePrefix, null);
|
QueueName = await target.BindDynamicDirect(dynamicQueuePrefix, null).ConfigureAwait(false);
|
||||||
router.TransientResponseQueueName = QueueName;
|
router.TransientResponseQueueName = QueueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace Tapeti.Transient
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<TResponse> RequestResponse<TRequest, TResponse>(TRequest request) where TRequest : class where TResponse : class
|
public async Task<TResponse> RequestResponse<TRequest, TResponse>(TRequest request) where TRequest : class where TResponse : class
|
||||||
{
|
{
|
||||||
return (TResponse)await router.RequestResponse(publisher, request);
|
return (TResponse)await router.RequestResponse(publisher, request).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace Tapeti.Transient
|
|||||||
Persistent = false
|
Persistent = false
|
||||||
};
|
};
|
||||||
|
|
||||||
await ((IInternalPublisher)publisher).Publish(request, properties, false);
|
await ((IInternalPublisher)publisher).Publish(request, properties, false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -84,7 +84,7 @@ namespace Tapeti.Transient
|
|||||||
|
|
||||||
await using (new Timer(TimeoutResponse, tcs, defaultTimeoutMs, -1))
|
await using (new Timer(TimeoutResponse, tcs, defaultTimeoutMs, -1))
|
||||||
{
|
{
|
||||||
return await tcs.Task;
|
return await tcs.Task.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace Tapeti.Connection
|
|||||||
if (capturedTaskQueue == null)
|
if (capturedTaskQueue == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await capturedTaskQueue.Add(() => { });
|
await capturedTaskQueue.Add(() => { }).ConfigureAwait(false);
|
||||||
capturedTaskQueue.Dispose();
|
capturedTaskQueue.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace Tapeti.Connection
|
|||||||
{
|
{
|
||||||
return GetTaskQueue().Add(async () =>
|
return GetTaskQueue().Add(async () =>
|
||||||
{
|
{
|
||||||
await operation(modelProvider);
|
await operation(modelProvider).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ namespace Tapeti.Connection
|
|||||||
var delayCancellationTokenSource = new CancellationTokenSource();
|
var delayCancellationTokenSource = new CancellationTokenSource();
|
||||||
var signalledTask = await Task.WhenAny(
|
var signalledTask = await Task.WhenAny(
|
||||||
publishResultTask,
|
publishResultTask,
|
||||||
Task.Delay(MandatoryReturnTimeout, delayCancellationTokenSource.Token));
|
Task.Delay(MandatoryReturnTimeout, delayCancellationTokenSource.Token)).ConfigureAwait(false);
|
||||||
|
|
||||||
if (signalledTask != publishResultTask)
|
if (signalledTask != publishResultTask)
|
||||||
throw new TimeoutException(
|
throw new TimeoutException(
|
||||||
@ -201,7 +201,7 @@ namespace Tapeti.Connection
|
|||||||
throw new NoRouteException(
|
throw new NoRouteException(
|
||||||
$"Mandatory message with exchange '{exchange}' and routing key '{routingKey}' could not be delivered, reply code: {replyCode}");
|
$"Mandatory message with exchange '{exchange}' and routing key '{routingKey}' could not be delivered, reply code: {replyCode}");
|
||||||
}
|
}
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ namespace Tapeti.Connection
|
|||||||
capturedConnectionReference = Interlocked.Read(ref connectionReference);
|
capturedConnectionReference = Interlocked.Read(ref connectionReference);
|
||||||
var basicConsumer = new TapetiBasicConsumer(consumer, capturedConnectionReference, Respond);
|
var basicConsumer = new TapetiBasicConsumer(consumer, capturedConnectionReference, Respond);
|
||||||
consumerTag = channel.BasicConsume(queueName, false, basicConsumer);
|
consumerTag = channel.BasicConsume(queueName, false, basicConsumer);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
return consumerTag == null
|
return consumerTag == null
|
||||||
? null
|
? null
|
||||||
@ -257,7 +257,7 @@ namespace Tapeti.Connection
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
channel.BasicCancel(consumerTag.ConsumerTag);
|
channel.BasicCancel(consumerTag.ConsumerTag);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -291,13 +291,13 @@ namespace Tapeti.Connection
|
|||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(result), result, null);
|
throw new ArgumentOutOfRangeException(nameof(result), result, null);
|
||||||
}
|
}
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task<bool> GetDurableQueueDeclareRequired(string queueName, IRabbitMQArguments? arguments)
|
private async Task<bool> GetDurableQueueDeclareRequired(string queueName, IRabbitMQArguments? arguments)
|
||||||
{
|
{
|
||||||
var existingQueue = await GetQueueInfo(queueName);
|
var existingQueue = await GetQueueInfo(queueName).ConfigureAwait(false);
|
||||||
if (existingQueue == null)
|
if (existingQueue == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -342,9 +342,9 @@ namespace Tapeti.Connection
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task DurableQueueDeclare(string queueName, IEnumerable<QueueBinding> bindings, IRabbitMQArguments? arguments, CancellationToken cancellationToken)
|
public async Task DurableQueueDeclare(string queueName, IEnumerable<QueueBinding> bindings, IRabbitMQArguments? arguments, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var declareRequired = await GetDurableQueueDeclareRequired(queueName, arguments);
|
var declareRequired = await GetDurableQueueDeclareRequired(queueName, arguments).ConfigureAwait(false);
|
||||||
|
|
||||||
var existingBindings = (await GetQueueBindings(queueName)).ToList();
|
var existingBindings = (await GetQueueBindings(queueName).ConfigureAwait(false)).ToList();
|
||||||
var currentBindings = bindings.ToList();
|
var currentBindings = bindings.ToList();
|
||||||
var bindingLogger = logger as IBindingLogger;
|
var bindingLogger = logger as IBindingLogger;
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ namespace Tapeti.Connection
|
|||||||
bindingLogger?.QueueUnbind(queueName, deletedBinding.Exchange, deletedBinding.RoutingKey);
|
bindingLogger?.QueueUnbind(queueName, deletedBinding.Exchange, deletedBinding.RoutingKey);
|
||||||
channel.QueueUnbind(queueName, deletedBinding.Exchange, deletedBinding.RoutingKey);
|
channel.QueueUnbind(queueName, deletedBinding.Exchange, deletedBinding.RoutingKey);
|
||||||
}
|
}
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ namespace Tapeti.Connection
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task DurableQueueVerify(string queueName, IRabbitMQArguments? arguments, CancellationToken cancellationToken)
|
public async Task DurableQueueVerify(string queueName, IRabbitMQArguments? arguments, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (!await GetDurableQueueDeclareRequired(queueName, arguments))
|
if (!await GetDurableQueueDeclareRequired(queueName, arguments).ConfigureAwait(false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await GetTapetiChannel(TapetiChannelType.Consume).Queue(channel =>
|
await GetTapetiChannel(TapetiChannelType.Consume).Queue(channel =>
|
||||||
@ -396,7 +396,7 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
(logger as IBindingLogger)?.QueueDeclare(queueName, true, true);
|
(logger as IBindingLogger)?.QueueDeclare(queueName, true, true);
|
||||||
channel.QueueDeclarePassive(queueName);
|
channel.QueueDeclarePassive(queueName);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ namespace Tapeti.Connection
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
deletedMessages = channel.QueueDelete(queueName);
|
deletedMessages = channel.QueueDelete(queueName);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
deletedQueues.Add(queueName);
|
deletedQueues.Add(queueName);
|
||||||
(logger as IBindingLogger)?.QueueObsolete(queueName, true, deletedMessages);
|
(logger as IBindingLogger)?.QueueObsolete(queueName, true, deletedMessages);
|
||||||
@ -434,7 +434,7 @@ namespace Tapeti.Connection
|
|||||||
// Get queue information from the Management API, since the AMQP operations will
|
// Get queue information from the Management API, since the AMQP operations will
|
||||||
// throw an error if the queue does not exist or still contains messages and resets
|
// throw an error if the queue does not exist or still contains messages and resets
|
||||||
// the connection. The resulting reconnect will cause subscribers to reset.
|
// the connection. The resulting reconnect will cause subscribers to reset.
|
||||||
var queueInfo = await GetQueueInfo(queueName);
|
var queueInfo = await GetQueueInfo(queueName).ConfigureAwait(false);
|
||||||
if (queueInfo == null)
|
if (queueInfo == null)
|
||||||
{
|
{
|
||||||
deletedQueues.Add(queueName);
|
deletedQueues.Add(queueName);
|
||||||
@ -467,7 +467,7 @@ namespace Tapeti.Connection
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Remove all bindings instead
|
// Remove all bindings instead
|
||||||
var existingBindings = (await GetQueueBindings(queueName)).ToList();
|
var existingBindings = (await GetQueueBindings(queueName).ConfigureAwait(false)).ToList();
|
||||||
|
|
||||||
if (existingBindings.Count > 0)
|
if (existingBindings.Count > 0)
|
||||||
{
|
{
|
||||||
@ -481,7 +481,7 @@ namespace Tapeti.Connection
|
|||||||
(logger as IBindingLogger)?.QueueObsolete(queueName, false, queueInfo.Messages);
|
(logger as IBindingLogger)?.QueueObsolete(queueName, false, queueInfo.Messages);
|
||||||
}
|
}
|
||||||
} while (retry);
|
} while (retry);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -507,7 +507,7 @@ namespace Tapeti.Connection
|
|||||||
queueName = channel.QueueDeclare(arguments: GetDeclareArguments(arguments)).QueueName;
|
queueName = channel.QueueDeclare(arguments: GetDeclareArguments(arguments)).QueueName;
|
||||||
bindingLogger?.QueueDeclare(queueName, false, false);
|
bindingLogger?.QueueDeclare(queueName, false, false);
|
||||||
}
|
}
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
if (queueName == null)
|
if (queueName == null)
|
||||||
@ -527,7 +527,7 @@ namespace Tapeti.Connection
|
|||||||
DeclareExchange(channel, binding.Exchange);
|
DeclareExchange(channel, binding.Exchange);
|
||||||
(logger as IBindingLogger)?.QueueBind(queueName, false, binding.Exchange, binding.RoutingKey);
|
(logger as IBindingLogger)?.QueueBind(queueName, false, binding.Exchange, binding.RoutingKey);
|
||||||
channel.QueueBind(queueName, binding.Exchange, binding.RoutingKey);
|
channel.QueueBind(queueName, binding.Exchange, binding.RoutingKey);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -551,8 +551,8 @@ namespace Tapeti.Connection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Empty the queue
|
// Empty the queue
|
||||||
await consumeChannel.Reset();
|
await consumeChannel.Reset().ConfigureAwait(false);
|
||||||
await publishChannel.Reset();
|
await publishChannel.Reset().ConfigureAwait(false);
|
||||||
|
|
||||||
// No need to close the channels as the connection will be closed
|
// No need to close the channels as the connection will be closed
|
||||||
capturedConsumeModel?.Dispose();
|
capturedConsumeModel?.Dispose();
|
||||||
@ -619,9 +619,9 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var content = await response.Content.ReadAsStringAsync();
|
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
return JsonConvert.DeserializeObject<ManagementQueueInfo>(content);
|
return JsonConvert.DeserializeObject<ManagementQueueInfo>(content);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -659,7 +659,7 @@ namespace Tapeti.Connection
|
|||||||
{
|
{
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var content = await response.Content.ReadAsStringAsync();
|
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
var bindings = JsonConvert.DeserializeObject<IEnumerable<ManagementBinding>>(content);
|
var bindings = JsonConvert.DeserializeObject<IEnumerable<ManagementBinding>>(content);
|
||||||
|
|
||||||
// Filter out the binding to an empty source, which is always present for direct-to-queue routing
|
// Filter out the binding to an empty source, which is always present for direct-to-queue routing
|
||||||
@ -667,7 +667,7 @@ namespace Tapeti.Connection
|
|||||||
.Where(binding => !string.IsNullOrEmpty(binding.Source) && !string.IsNullOrEmpty(binding.RoutingKey))
|
.Where(binding => !string.IsNullOrEmpty(binding.Source) && !string.IsNullOrEmpty(binding.RoutingKey))
|
||||||
.Select(binding => new QueueBinding(binding.Source!, binding.RoutingKey!))
|
.Select(binding => new QueueBinding(binding.Source!, binding.RoutingKey!))
|
||||||
?? Enumerable.Empty<QueueBinding>();
|
?? Enumerable.Empty<QueueBinding>();
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -702,8 +702,8 @@ namespace Tapeti.Connection
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = await managementClient.SendAsync(request);
|
var response = await managementClient.SendAsync(request).ConfigureAwait(false);
|
||||||
return await handleResponse(response);
|
return await handleResponse(response).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (TimeoutException)
|
catch (TimeoutException)
|
||||||
{
|
{
|
||||||
@ -717,7 +717,7 @@ namespace Tapeti.Connection
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(ExponentialBackoff[retryDelayIndex]);
|
await Task.Delay(ExponentialBackoff[retryDelayIndex]).ConfigureAwait(false);
|
||||||
|
|
||||||
if (retryDelayIndex < ExponentialBackoff.Length - 1)
|
if (retryDelayIndex < ExponentialBackoff.Length - 1)
|
||||||
retryDelayIndex++;
|
retryDelayIndex++;
|
||||||
|
@ -60,7 +60,7 @@ namespace Tapeti.Connection
|
|||||||
Exchange = exchange,
|
Exchange = exchange,
|
||||||
RoutingKey = routingKey,
|
RoutingKey = routingKey,
|
||||||
Properties = properties
|
Properties = properties
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception dispatchException)
|
catch (Exception dispatchException)
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ namespace Tapeti.Connection
|
|||||||
};
|
};
|
||||||
|
|
||||||
var exceptionContext = new ExceptionStrategyContext(emptyContext, dispatchException);
|
var exceptionContext = new ExceptionStrategyContext(emptyContext, dispatchException);
|
||||||
await HandleException(exceptionContext);
|
await HandleException(exceptionContext).ConfigureAwait(false);
|
||||||
|
|
||||||
return exceptionContext.ConsumeResult;
|
return exceptionContext.ConsumeResult;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
foreach (var binding in bindings.Where(binding => binding.Accept(messageType)))
|
foreach (var binding in bindings.Where(binding => binding.Accept(messageType)))
|
||||||
{
|
{
|
||||||
var consumeResult = await InvokeUsingBinding(message, messageContextData, binding);
|
var consumeResult = await InvokeUsingBinding(message, messageContextData, binding).ConfigureAwait(false);
|
||||||
validMessageType = true;
|
validMessageType = true;
|
||||||
|
|
||||||
if (consumeResult != ConsumeResult.Success)
|
if (consumeResult != ConsumeResult.Success)
|
||||||
@ -125,18 +125,18 @@ namespace Tapeti.Connection
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await MiddlewareHelper.GoAsync(config.Middleware.Message,
|
await MiddlewareHelper.GoAsync(config.Middleware.Message,
|
||||||
async (handler, next) => await handler.Handle(context, next),
|
async (handler, next) => await handler.Handle(context, next).ConfigureAwait(false),
|
||||||
async () => { await binding.Invoke(context); });
|
async () => { await binding.Invoke(context).ConfigureAwait(false); });
|
||||||
|
|
||||||
await binding.Cleanup(context, ConsumeResult.Success);
|
await binding.Cleanup(context, ConsumeResult.Success).ConfigureAwait(false);
|
||||||
return ConsumeResult.Success;
|
return ConsumeResult.Success;
|
||||||
}
|
}
|
||||||
catch (Exception invokeException)
|
catch (Exception invokeException)
|
||||||
{
|
{
|
||||||
var exceptionContext = new ExceptionStrategyContext(context, invokeException);
|
var exceptionContext = new ExceptionStrategyContext(context, invokeException);
|
||||||
await HandleException(exceptionContext);
|
await HandleException(exceptionContext).ConfigureAwait(false);
|
||||||
|
|
||||||
await binding.Cleanup(context, exceptionContext.ConsumeResult);
|
await binding.Cleanup(context, exceptionContext.ConsumeResult).ConfigureAwait(false);
|
||||||
return exceptionContext.ConsumeResult;
|
return exceptionContext.ConsumeResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await exceptionStrategy.HandleException(exceptionContext);
|
await exceptionStrategy.HandleException(exceptionContext).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception strategyException)
|
catch (Exception strategyException)
|
||||||
{
|
{
|
||||||
|
@ -34,21 +34,21 @@ namespace Tapeti.Connection
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task Publish(object message)
|
public async Task Publish(object message)
|
||||||
{
|
{
|
||||||
await Publish(message, null, IsMandatory(message));
|
await Publish(message, null, IsMandatory(message)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task PublishRequest<TController, TRequest, TResponse>(TRequest message, Expression<Func<TController, Action<TResponse>>> responseMethodSelector) where TController : class where TRequest : class where TResponse : class
|
public async Task PublishRequest<TController, TRequest, TResponse>(TRequest message, Expression<Func<TController, Action<TResponse>>> responseMethodSelector) where TController : class where TRequest : class where TResponse : class
|
||||||
{
|
{
|
||||||
await PublishRequest(message, responseMethodSelector.Body);
|
await PublishRequest(message, responseMethodSelector.Body).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task PublishRequest<TController, TRequest, TResponse>(TRequest message, Expression<Func<TController, Func<TResponse, Task>>> responseMethodSelector) where TController : class where TRequest : class where TResponse : class
|
public async Task PublishRequest<TController, TRequest, TResponse>(TRequest message, Expression<Func<TController, Func<TResponse, Task>>> responseMethodSelector) where TController : class where TRequest : class where TResponse : class
|
||||||
{
|
{
|
||||||
await PublishRequest(message, responseMethodSelector.Body);
|
await PublishRequest(message, responseMethodSelector.Body).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,14 +87,14 @@ namespace Tapeti.Connection
|
|||||||
ReplyTo = binding.QueueName
|
ReplyTo = binding.QueueName
|
||||||
};
|
};
|
||||||
|
|
||||||
await Publish(message, properties, IsMandatory(message));
|
await Publish(message, properties, IsMandatory(message)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task SendToQueue(string queueName, object message)
|
public async Task SendToQueue(string queueName, object message)
|
||||||
{
|
{
|
||||||
await PublishDirect(message, queueName, null, IsMandatory(message));
|
await PublishDirect(message, queueName, null, IsMandatory(message)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,14 +105,14 @@ namespace Tapeti.Connection
|
|||||||
var exchange = exchangeStrategy.GetExchange(messageClass);
|
var exchange = exchangeStrategy.GetExchange(messageClass);
|
||||||
var routingKey = routingKeyStrategy.GetRoutingKey(messageClass);
|
var routingKey = routingKeyStrategy.GetRoutingKey(messageClass);
|
||||||
|
|
||||||
await Publish(message, properties, exchange, routingKey, mandatory);
|
await Publish(message, properties, exchange, routingKey, mandatory).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task PublishDirect(object message, string queueName, IMessageProperties? properties, bool mandatory)
|
public async Task PublishDirect(object message, string queueName, IMessageProperties? properties, bool mandatory)
|
||||||
{
|
{
|
||||||
await Publish(message, properties, null, queueName, mandatory);
|
await Publish(message, properties, null, queueName, mandatory).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,12 +136,12 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
await MiddlewareHelper.GoAsync(
|
await MiddlewareHelper.GoAsync(
|
||||||
config.Middleware.Publish,
|
config.Middleware.Publish,
|
||||||
async (handler, next) => await handler.Handle(context, next),
|
async (handler, next) => await handler.Handle(context, next).ConfigureAwait(false),
|
||||||
async () =>
|
async () =>
|
||||||
{
|
{
|
||||||
var body = messageSerializer.Serialize(message, writableProperties);
|
var body = messageSerializer.Serialize(message, writableProperties);
|
||||||
await clientFactory().Publish(body, writableProperties, exchange, routingKey, mandatory);
|
await clientFactory().Publish(body, writableProperties, exchange, routingKey, mandatory).ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace Tapeti.Connection
|
|||||||
public async ValueTask DisposeAsync()
|
public async ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
if (consuming)
|
if (consuming)
|
||||||
await Stop();
|
await Stop().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ namespace Tapeti.Connection
|
|||||||
public async Task ApplyBindings()
|
public async Task ApplyBindings()
|
||||||
{
|
{
|
||||||
initializeCancellationTokenSource = new CancellationTokenSource();
|
initializeCancellationTokenSource = new CancellationTokenSource();
|
||||||
await ApplyBindings(initializeCancellationTokenSource.Token);
|
await ApplyBindings(initializeCancellationTokenSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,10 +81,10 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await ApplyBindings(cancellationToken);
|
await ApplyBindings(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (consuming && !cancellationToken.IsCancellationRequested)
|
if (consuming && !cancellationToken.IsCancellationRequested)
|
||||||
await ConsumeQueues(cancellationToken);
|
await ConsumeQueues(cancellationToken).ConfigureAwait(false);
|
||||||
}, CancellationToken.None);
|
}, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ namespace Tapeti.Connection
|
|||||||
consuming = true;
|
consuming = true;
|
||||||
initializeCancellationTokenSource = new CancellationTokenSource();
|
initializeCancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
await ConsumeQueues(initializeCancellationTokenSource.Token);
|
await ConsumeQueues(initializeCancellationTokenSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ namespace Tapeti.Connection
|
|||||||
initializeCancellationTokenSource?.Cancel();
|
initializeCancellationTokenSource?.Cancel();
|
||||||
initializeCancellationTokenSource = null;
|
initializeCancellationTokenSource = null;
|
||||||
|
|
||||||
await Task.WhenAll(consumerTags.Select(async tag => await clientFactory().Cancel(tag)));
|
await Task.WhenAll(consumerTags.Select(async tag => await clientFactory().Cancel(tag))).ConfigureAwait(false);
|
||||||
|
|
||||||
consumerTags.Clear();
|
consumerTags.Clear();
|
||||||
consuming = false;
|
consuming = false;
|
||||||
@ -133,9 +133,9 @@ namespace Tapeti.Connection
|
|||||||
bindingTarget = new NoVerifyBindingTarget(clientFactory, routingKeyStrategy, exchangeStrategy, cancellationToken);
|
bindingTarget = new NoVerifyBindingTarget(clientFactory, routingKeyStrategy, exchangeStrategy, cancellationToken);
|
||||||
|
|
||||||
foreach (var binding in config.Bindings)
|
foreach (var binding in config.Bindings)
|
||||||
await binding.Apply(bindingTarget);
|
await binding.Apply(bindingTarget).ConfigureAwait(false);
|
||||||
|
|
||||||
await bindingTarget.Apply();
|
await bindingTarget.Apply().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -155,8 +155,8 @@ namespace Tapeti.Connection
|
|||||||
var queueName = group.Key;
|
var queueName = group.Key;
|
||||||
var consumer = new TapetiConsumer(cancellationToken, config, queueName, group);
|
var consumer = new TapetiConsumer(cancellationToken, config, queueName, group);
|
||||||
|
|
||||||
return await clientFactory().Consume(queueName, consumer, cancellationToken);
|
return await clientFactory().Consume(queueName, consumer, cancellationToken).ConfigureAwait(false);
|
||||||
})))
|
})).ConfigureAwait(false))
|
||||||
.Where(t => t?.ConsumerTag != null)
|
.Where(t => t?.ConsumerTag != null)
|
||||||
.Cast<TapetiConsumerTag>());
|
.Cast<TapetiConsumerTag>());
|
||||||
}
|
}
|
||||||
@ -201,14 +201,14 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
public async ValueTask<string> BindDynamic(Type messageClass, string? queuePrefix, IRabbitMQArguments? arguments)
|
public async ValueTask<string> BindDynamic(Type messageClass, string? queuePrefix, IRabbitMQArguments? arguments)
|
||||||
{
|
{
|
||||||
var result = await DeclareDynamicQueue(messageClass, queuePrefix, arguments);
|
var result = await DeclareDynamicQueue(messageClass, queuePrefix, arguments).ConfigureAwait(false);
|
||||||
if (!result.IsNewMessageClass)
|
if (!result.IsNewMessageClass)
|
||||||
return result.QueueName;
|
return result.QueueName;
|
||||||
|
|
||||||
var routingKey = RoutingKeyStrategy.GetRoutingKey(messageClass);
|
var routingKey = RoutingKeyStrategy.GetRoutingKey(messageClass);
|
||||||
var exchange = ExchangeStrategy.GetExchange(messageClass);
|
var exchange = ExchangeStrategy.GetExchange(messageClass);
|
||||||
|
|
||||||
await ClientFactory().DynamicQueueBind(result.QueueName, new QueueBinding(exchange, routingKey), CancellationToken);
|
await ClientFactory().DynamicQueueBind(result.QueueName, new QueueBinding(exchange, routingKey), CancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return result.QueueName;
|
return result.QueueName;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
public async ValueTask<string> BindDynamicDirect(Type messageClass, string? queuePrefix, IRabbitMQArguments? arguments)
|
public async ValueTask<string> BindDynamicDirect(Type messageClass, string? queuePrefix, IRabbitMQArguments? arguments)
|
||||||
{
|
{
|
||||||
var result = await DeclareDynamicQueue(messageClass, queuePrefix, arguments);
|
var result = await DeclareDynamicQueue(messageClass, queuePrefix, arguments).ConfigureAwait(false);
|
||||||
return result.QueueName;
|
return result.QueueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ namespace Tapeti.Connection
|
|||||||
{
|
{
|
||||||
// If we don't know the routing key, always create a new queue to ensure there is no overlap.
|
// If we don't know the routing key, always create a new queue to ensure there is no overlap.
|
||||||
// Keep it out of the dynamicQueues dictionary, so it can't be re-used later on either.
|
// Keep it out of the dynamicQueues dictionary, so it can't be re-used later on either.
|
||||||
return await ClientFactory().DynamicQueueDeclare(queuePrefix, arguments, CancellationToken);
|
return await ClientFactory().DynamicQueueDeclare(queuePrefix, arguments, CancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ namespace Tapeti.Connection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Declare a new queue
|
// Declare a new queue
|
||||||
var queueName = await ClientFactory().DynamicQueueDeclare(queuePrefix, arguments, CancellationToken);
|
var queueName = await ClientFactory().DynamicQueueDeclare(queuePrefix, arguments, CancellationToken).ConfigureAwait(false);
|
||||||
var queueInfo = new DynamicQueueInfo
|
var queueInfo = new DynamicQueueInfo
|
||||||
{
|
{
|
||||||
QueueName = queueName,
|
QueueName = queueName,
|
||||||
@ -363,8 +363,8 @@ namespace Tapeti.Connection
|
|||||||
public override async Task Apply()
|
public override async Task Apply()
|
||||||
{
|
{
|
||||||
var client = ClientFactory();
|
var client = ClientFactory();
|
||||||
await DeclareQueues(client);
|
await DeclareQueues(client).ConfigureAwait(false);
|
||||||
await DeleteObsoleteQueues(client);
|
await DeleteObsoleteQueues(client).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -380,8 +380,8 @@ namespace Tapeti.Connection
|
|||||||
return new QueueBinding(exchange, routingKey);
|
return new QueueBinding(exchange, routingKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
await client.DurableQueueDeclare(queue.Key, bindings, queue.Value.Arguments, CancellationToken);
|
await client.DurableQueueDeclare(queue.Key, bindings, queue.Value.Arguments, CancellationToken).ConfigureAwait(false);
|
||||||
}));
|
})).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -389,8 +389,8 @@ namespace Tapeti.Connection
|
|||||||
{
|
{
|
||||||
await Task.WhenAll(obsoleteDurableQueues.Except(durableQueues.Keys).Select(async queue =>
|
await Task.WhenAll(obsoleteDurableQueues.Except(durableQueues.Keys).Select(async queue =>
|
||||||
{
|
{
|
||||||
await client.DurableQueueDelete(queue, true, CancellationToken);
|
await client.DurableQueueDelete(queue, true, CancellationToken).ConfigureAwait(false);
|
||||||
}));
|
})).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,12 +407,12 @@ namespace Tapeti.Connection
|
|||||||
|
|
||||||
public override async ValueTask BindDurable(Type messageClass, string queueName, IRabbitMQArguments? arguments)
|
public override async ValueTask BindDurable(Type messageClass, string queueName, IRabbitMQArguments? arguments)
|
||||||
{
|
{
|
||||||
await VerifyDurableQueue(queueName, arguments);
|
await VerifyDurableQueue(queueName, arguments).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async ValueTask BindDurableDirect(string queueName, IRabbitMQArguments? arguments)
|
public override async ValueTask BindDurableDirect(string queueName, IRabbitMQArguments? arguments)
|
||||||
{
|
{
|
||||||
await VerifyDurableQueue(queueName, arguments);
|
await VerifyDurableQueue(queueName, arguments).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ValueTask BindDurableObsolete(string queueName)
|
public override ValueTask BindDurableObsolete(string queueName)
|
||||||
@ -426,7 +426,7 @@ namespace Tapeti.Connection
|
|||||||
if (!durableQueues.Add(queueName))
|
if (!durableQueues.Add(queueName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await ClientFactory().DurableQueueVerify(queueName, arguments, CancellationToken);
|
await ClientFactory().DurableQueueVerify(queueName, arguments, CancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,10 +117,10 @@ namespace Tapeti.Default
|
|||||||
{
|
{
|
||||||
case BindingTargetMode.Default:
|
case BindingTargetMode.Default:
|
||||||
if (bindingInfo.QueueInfo.QueueType == Config.QueueType.Dynamic)
|
if (bindingInfo.QueueInfo.QueueType == Config.QueueType.Dynamic)
|
||||||
QueueName = await target.BindDynamic(bindingInfo.MessageClass, bindingInfo.QueueInfo.Name, bindingInfo.QueueInfo.QueueArguments);
|
QueueName = await target.BindDynamic(bindingInfo.MessageClass, bindingInfo.QueueInfo.Name, bindingInfo.QueueInfo.QueueArguments).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await target.BindDurable(bindingInfo.MessageClass, bindingInfo.QueueInfo.Name!, bindingInfo.QueueInfo.QueueArguments);
|
await target.BindDurable(bindingInfo.MessageClass, bindingInfo.QueueInfo.Name!, bindingInfo.QueueInfo.QueueArguments).ConfigureAwait(false);
|
||||||
QueueName = bindingInfo.QueueInfo.Name;
|
QueueName = bindingInfo.QueueInfo.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,10 +128,10 @@ namespace Tapeti.Default
|
|||||||
|
|
||||||
case BindingTargetMode.Direct:
|
case BindingTargetMode.Direct:
|
||||||
if (bindingInfo.QueueInfo.QueueType == Config.QueueType.Dynamic)
|
if (bindingInfo.QueueInfo.QueueType == Config.QueueType.Dynamic)
|
||||||
QueueName = await target.BindDynamicDirect(bindingInfo.MessageClass, bindingInfo.QueueInfo.Name, bindingInfo.QueueInfo.QueueArguments);
|
QueueName = await target.BindDynamicDirect(bindingInfo.MessageClass, bindingInfo.QueueInfo.Name, bindingInfo.QueueInfo.QueueArguments).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await target.BindDurableDirect(bindingInfo.QueueInfo.Name!, bindingInfo.QueueInfo.QueueArguments);
|
await target.BindDurableDirect(bindingInfo.QueueInfo.Name!, bindingInfo.QueueInfo.QueueArguments).ConfigureAwait(false);
|
||||||
QueueName = bindingInfo.QueueInfo.Name;
|
QueueName = bindingInfo.QueueInfo.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ namespace Tapeti.Default
|
|||||||
}
|
}
|
||||||
else if (bindingInfo.QueueInfo.QueueType == Config.QueueType.Durable)
|
else if (bindingInfo.QueueInfo.QueueType == Config.QueueType.Durable)
|
||||||
{
|
{
|
||||||
await target.BindDurableObsolete(bindingInfo.QueueInfo.Name!);
|
await target.BindDurableObsolete(bindingInfo.QueueInfo.Name!).ConfigureAwait(false);
|
||||||
QueueName = bindingInfo.QueueInfo.Name;
|
QueueName = bindingInfo.QueueInfo.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,14 +165,14 @@ namespace Tapeti.Default
|
|||||||
var controller = Method.IsStatic ? null : dependencyResolver.Resolve(bindingInfo.ControllerType);
|
var controller = Method.IsStatic ? null : dependencyResolver.Resolve(bindingInfo.ControllerType);
|
||||||
context.Store(new ControllerMessageContextPayload(controller, (IControllerMethodBinding)context.Binding));
|
context.Store(new ControllerMessageContextPayload(controller, (IControllerMethodBinding)context.Binding));
|
||||||
|
|
||||||
if (!await FilterAllowed(context))
|
if (!await FilterAllowed(context).ConfigureAwait(false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
await MiddlewareHelper.GoAsync(
|
await MiddlewareHelper.GoAsync(
|
||||||
bindingInfo.MessageMiddleware,
|
bindingInfo.MessageMiddleware,
|
||||||
async (handler, next) => await handler.Handle(context, next),
|
async (handler, next) => await handler.Handle(context, next).ConfigureAwait(false),
|
||||||
async () => await messageHandler(context));
|
async () => await messageHandler(context).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -181,8 +181,8 @@ namespace Tapeti.Default
|
|||||||
{
|
{
|
||||||
await MiddlewareHelper.GoAsync(
|
await MiddlewareHelper.GoAsync(
|
||||||
bindingInfo.CleanupMiddleware,
|
bindingInfo.CleanupMiddleware,
|
||||||
async (handler, next) => await handler.Cleanup(context, consumeResult, next),
|
async (handler, next) => await handler.Cleanup(context, consumeResult, next).ConfigureAwait(false),
|
||||||
() => default);
|
() => default).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -191,12 +191,12 @@ namespace Tapeti.Default
|
|||||||
var allowed = false;
|
var allowed = false;
|
||||||
await MiddlewareHelper.GoAsync(
|
await MiddlewareHelper.GoAsync(
|
||||||
bindingInfo.FilterMiddleware,
|
bindingInfo.FilterMiddleware,
|
||||||
async (handler, next) => await handler.Filter(context, next),
|
async (handler, next) => await handler.Filter(context, next).ConfigureAwait(false),
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
allowed = true;
|
allowed = true;
|
||||||
return default;
|
return default;
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ namespace Tapeti.Default
|
|||||||
switch (payload)
|
switch (payload)
|
||||||
{
|
{
|
||||||
case IAsyncDisposable asyncDisposable:
|
case IAsyncDisposable asyncDisposable:
|
||||||
await asyncDisposable.DisposeAsync();
|
await asyncDisposable.DisposeAsync().ConfigureAwait(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDisposable disposable:
|
case IDisposable disposable:
|
||||||
@ -151,7 +151,7 @@ namespace Tapeti.Default
|
|||||||
foreach (var item in items.Values)
|
foreach (var item in items.Values)
|
||||||
{
|
{
|
||||||
if (item is IAsyncDisposable asyncDisposable)
|
if (item is IAsyncDisposable asyncDisposable)
|
||||||
await asyncDisposable.DisposeAsync();
|
await asyncDisposable.DisposeAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,15 +75,15 @@ namespace Tapeti.Default
|
|||||||
|
|
||||||
private static async ValueTask PublishGenericTaskResult<T>(IMessageContext messageContext, object value) where T : class
|
private static async ValueTask PublishGenericTaskResult<T>(IMessageContext messageContext, object value) where T : class
|
||||||
{
|
{
|
||||||
var message = await (Task<T>)value;
|
var message = await ((Task<T>)value).ConfigureAwait(false);
|
||||||
await Reply(message, messageContext);
|
await Reply(message, messageContext).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static async ValueTask PublishGenericValueTaskResult<T>(IMessageContext messageContext, object value) where T : class
|
private static async ValueTask PublishGenericValueTaskResult<T>(IMessageContext messageContext, object value) where T : class
|
||||||
{
|
{
|
||||||
var message = await (ValueTask<T>)value;
|
var message = await ((ValueTask<T>)value).ConfigureAwait(false);
|
||||||
await Reply(message, messageContext);
|
await Reply(message, messageContext).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -99,9 +99,9 @@ namespace Tapeti.Default
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(messageContext.Properties.ReplyTo))
|
if (!string.IsNullOrEmpty(messageContext.Properties.ReplyTo))
|
||||||
await publisher.PublishDirect(message, messageContext.Properties.ReplyTo, properties, messageContext.Properties.Persistent.GetValueOrDefault(true));
|
await publisher.PublishDirect(message, messageContext.Properties.ReplyTo, properties, messageContext.Properties.Persistent.GetValueOrDefault(true)).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await publisher.Publish(message, properties, false);
|
await publisher.Publish(message, properties, false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace Tapeti.Default
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await next();
|
await next().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace Tapeti.Helpers
|
|||||||
var handlerIndex = middleware?.Count - 1 ?? -1;
|
var handlerIndex = middleware?.Count - 1 ?? -1;
|
||||||
if (middleware == null || handlerIndex == -1)
|
if (middleware == null || handlerIndex == -1)
|
||||||
{
|
{
|
||||||
await lastHandler();
|
await lastHandler().ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,12 +58,12 @@ namespace Tapeti.Helpers
|
|||||||
{
|
{
|
||||||
handlerIndex--;
|
handlerIndex--;
|
||||||
if (handlerIndex >= 0)
|
if (handlerIndex >= 0)
|
||||||
await handle(middleware[handlerIndex], HandleNext);
|
await handle(middleware[handlerIndex], HandleNext).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await lastHandler();
|
await lastHandler().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
await handle(middleware[handlerIndex], HandleNext);
|
await handle(middleware[handlerIndex], HandleNext).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,11 +63,11 @@ namespace Tapeti
|
|||||||
if (subscriber == null)
|
if (subscriber == null)
|
||||||
{
|
{
|
||||||
subscriber = new TapetiSubscriber(() => client.Value, config);
|
subscriber = new TapetiSubscriber(() => client.Value, config);
|
||||||
await subscriber.ApplyBindings();
|
await subscriber.ApplyBindings().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startConsuming)
|
if (startConsuming)
|
||||||
await subscriber.Resume();
|
await subscriber.Resume().ConfigureAwait(false);
|
||||||
|
|
||||||
return subscriber;
|
return subscriber;
|
||||||
}
|
}
|
||||||
@ -91,28 +91,36 @@ namespace Tapeti
|
|||||||
public async Task Close()
|
public async Task Close()
|
||||||
{
|
{
|
||||||
if (client.IsValueCreated)
|
if (client.IsValueCreated)
|
||||||
await client.Value.Close();
|
await client.Value.Close().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (!disposed)
|
GC.SuppressFinalize(this);
|
||||||
DisposeAsync().GetAwaiter().GetResult();
|
|
||||||
|
if (disposed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var disposeAsyncTask = DisposeAsync();
|
||||||
|
if (!disposeAsyncTask.IsCompleted)
|
||||||
|
disposeAsyncTask.AsTask().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async ValueTask DisposeAsync()
|
public async ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (disposed)
|
if (disposed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (subscriber != null)
|
if (subscriber != null)
|
||||||
await subscriber.DisposeAsync();
|
await subscriber.DisposeAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
await Close();
|
await Close().ConfigureAwait(false);
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user