Fix async callback awaiting in HTTP endpoint (#6660)
* Await HTTP resume callbacks * Update HttpEndpoint.cs * Update HttpEndpointActivityExecutionContextExtensions.cs * Refactor to use `WaitForHttpRequestAsync` consistently. Replaced `WaitForHttpRequest` with `WaitForHttpRequestAsync` across the codebase to align with asynchronous naming conventions. This change improves clarity and maintains consistency in method naming. * Add 'codex/*' branch to workflow path filters This update ensures that actions in the workflow are triggered for changes in branches following the 'codex/*' naming convention. It aligns the path filters with the branching strategy and improves CI/CD coverage.
This commit is contained in:
parent
2dcd852833
commit
562d91bd55
1
.github/workflows/packages.yml
vendored
1
.github/workflows/packages.yml
vendored
|
|
@ -11,6 +11,7 @@ on:
|
|||
- 'enh/*'
|
||||
- 'rc/*'
|
||||
- 'develop/*'
|
||||
- 'codex/*'
|
||||
release:
|
||||
types: [ prereleased, published ]
|
||||
env:
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public class HttpEndpoint : Trigger<HttpRequest>
|
|||
{
|
||||
var path = Path.Get(context);
|
||||
var methods = SupportedMethods.GetOrDefault(context) ?? new List<string> { HttpMethods.Get };
|
||||
context.WaitForHttpRequest(path, methods, OnResumeAsync);
|
||||
await context.WaitForHttpRequestAsync(path, methods, OnResumeAsync);
|
||||
}
|
||||
|
||||
private async ValueTask OnResumeAsync(ActivityExecutionContext context)
|
||||
|
|
@ -497,4 +497,4 @@ public class HttpEndpoint : Trigger<HttpRequest>
|
|||
|
||||
return routeData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ public abstract class HttpEndpointBase<TResult> : Trigger<TResult>
|
|||
{
|
||||
}
|
||||
|
||||
protected override void Execute(ActivityExecutionContext context)
|
||||
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
|
||||
{
|
||||
var options = GetOptions();
|
||||
context.WaitForHttpRequest(options, HttpRequestReceivedAsync);
|
||||
await context.WaitForHttpRequestAsync(options, HttpRequestReceivedAsync);
|
||||
}
|
||||
|
||||
protected override IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context)
|
||||
|
|
|
|||
|
|
@ -9,27 +9,27 @@ namespace Elsa.Http.Extensions;
|
|||
|
||||
public static class HttpEndpointActivityExecutionContextExtensions
|
||||
{
|
||||
public static void WaitForHttpRequest(this ActivityExecutionContext context, string path, string method, ExecuteActivityDelegate? callback = null)
|
||||
public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, string path, string method, ExecuteActivityDelegate? callback = null)
|
||||
{
|
||||
var options = new HttpEndpointOptions
|
||||
{
|
||||
var options = new HttpEndpointOptions
|
||||
{
|
||||
Path = path,
|
||||
Methods = [method]
|
||||
};
|
||||
WaitForHttpRequest(context, options, callback);
|
||||
}
|
||||
Path = path,
|
||||
Methods = [method]
|
||||
};
|
||||
await WaitForHttpRequestAsync(context, options, callback);
|
||||
}
|
||||
|
||||
public static void WaitForHttpRequest(this ActivityExecutionContext context, string path, IEnumerable<string> methods, ExecuteActivityDelegate? callback = null)
|
||||
public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, string path, IEnumerable<string> methods, ExecuteActivityDelegate? callback = null)
|
||||
{
|
||||
var options = new HttpEndpointOptions
|
||||
{
|
||||
var options = new HttpEndpointOptions
|
||||
{
|
||||
Path = path,
|
||||
Methods = methods.ToList()
|
||||
};
|
||||
WaitForHttpRequest(context, options, callback);
|
||||
}
|
||||
Path = path,
|
||||
Methods = methods.ToList()
|
||||
};
|
||||
await WaitForHttpRequestAsync(context, options, callback);
|
||||
}
|
||||
|
||||
public static void WaitForHttpRequest(this ActivityExecutionContext context, HttpEndpointOptions options, ExecuteActivityDelegate? callback = null)
|
||||
public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, HttpEndpointOptions options, ExecuteActivityDelegate? callback = null)
|
||||
{
|
||||
var path = options.Path;
|
||||
if (path.Contains("//"))
|
||||
|
|
@ -42,7 +42,8 @@ public static class HttpEndpointActivityExecutionContextExtensions
|
|||
return;
|
||||
}
|
||||
|
||||
callback?.Invoke(context);
|
||||
if (callback is not null)
|
||||
await callback(context);
|
||||
}
|
||||
|
||||
public static IEnumerable<object> GetHttpEndpointStimuli(this TriggerIndexingContext context, string path, string method)
|
||||
|
|
@ -91,4 +92,4 @@ public static class HttpEndpointActivityExecutionContextExtensions
|
|||
};
|
||||
context.CreateBookmark(bookmarkOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue