Skip to content

Commit

Permalink
Merge 3.0.1 (#4759)
Browse files Browse the repository at this point in the history
* Update packages.yml for version 3.0.1

The packages.yml workflow file has been updated to target the v3.0.1 branch instead of main. The version also has been updated from 3.0.0 to 3.0.1 in the version prediction logic. Hotfix tags usage has been removed.

* Update git branch for commit verification in workflow

The Github workflow's step for verifying commits' existence has been updated. Instead of searching in the 'origin/main' branch, the workflow now checks in the 'origin/v3.0.1' branch. This modification ensures compatibility and consistency with the version being used.

* Update Elsa.Studio package versions

The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages in the Elsa.ServerAndStudio.Web and Elsa.Studio.Web projects have been updated from version 3.0.0-preview.177 to the stable version 3.0.0. This is to ensure we're using the stable and reliable versions of these packages in our projects.

* Add background execution to activities and update HTTP requests

Significantly enhanced the capabilities of background execution of activities. Included a change in activity type of "SendHttpRequest" from 'Task' to 'Action'. Introduced new classes for handling outcomes of context in background execution. Made some necessary adjustments to HTTP Request Task to handle sending HTTP requests from a background task. Updated several middleware classes to align with these modifications.

* Add background execution handling to activity context

This commit adds the ability to manage the background execution state directly within the activity execution context. This includes adding methods to set and verify the background execution state, and modifying the existing code to use these new methods. A method for handling activity scheduling during background execution has also been started, but its implementation is not finished yet. The HTTP Request activities were updated accordingly to reflect these changes.

* Add scheduling function for background activities

This commit achieves two main goals. Firstly, it introduces two new classes called ScheduledActivity and ScheduledActivityOptions to store scheduled activities' information. Secondly, it modifies how activities are executed in the background by capturing the scheduling information as a serializable format and storing it in the workflow execution context properties dictionary. This change allows the workflow execution context to resume the activity execution context.

* Refactor HTTP request handling by removing SendHttpRequestTask

SendHttpRequestTask was deleted and its functionality was merged into SendHttpRequestBase. This consolidation led to the addition of StatusCode and ResponseHeaders output fields in SendHttpRequestBase. Another change includes the update in FlowSendHttpRequest to indicate that it's no longer deprecated. Also, HttpHeaders class was extended to accommodate HttpResponseHeaders objects. The consolidation was done to streamline the HTTP request handling process.

* Update GitHub Actions workflow for new release

The GitHub Actions workflow configuration has been updated to target the '3.0.1' branch instead of 'main'. Furthermore, the preview version set in the workflow has been updated to '3.0.1-preview', changing from the previous '3.0.0-preview'.

* Update branch verification in GitHub workflow

The GitHub workflow configuration has been updated to verify that the commit exists in the branch 'origin/3.0.1' instead of 'origin/main'. This is done during the automated package generation process.

* New options to control retry logic for transient failures (#4750)

* Add an option to control the number of automatic retries for transient failures.

* Add SleepDurationProvider option for ElsaClientBuilderOptions

---------

Co-authored-by: admin <[email protected]>

* Add IExecuteWorkflowApi interface and refine retry policy configuration

A new interface, IExecuteWorkflowApi, was created to handle execution and dispatch of workflow definitions. This breaks down functionalities previously present in IWorkflowDefinitionsApi. Also, the retry policy configuration for HTTP requests has been refactored. Instead of hardcoding retry settings, now a delegate method can be optionally passed to customize the behavior. This makes it more flexible and shifts the responsibility of configuring retry policies to the client.

* Add option for synchronous broadcast in WorkflowInbox

This update introduces a new option to control synchronicity when broadcasting messages in the WorkflowInbox. The 'BroadcastWorkflowInboxMessageOptions' class allows the developer to specify whether the broadcasting will occur synchronously or asynchronously. The update also includes a new Endpoint and Workflow for demonstration and testing of this functionality.

* Update FastEndpoints packages to version 5.21.2

The current commit updates the version of all FastEndpoints packages from 5.20.1.7-beta to 5.21.2 in the 'Elsa.Api.Common' project. This ensures we are using the most recent stable release of these packages.

#4747

* Add decimal check in PolymorphicObjectConverter

In the PolymorphicObjectConverter class, the check for primitive types and specific object types was updated to include decimal.

Fixes #4714

* Refactor Dapper workflow and update migrations

Modified the store service to optimize the SaveManyAsync method by converting input to list only once. Also, enhanced deletion query in the store service to enable usage of different primary keys. Made changes in the Dapper migrations, replacing "NodeId" with "ActivityNodeId".

* Update workflow to use main branch and version 3.1.0

The workflow has been updated to work with updates on the 'main' branch rather than the 'v3.0.1' branch. Also, the version number for the 'VERSION' variable in preview mode has been updated to 3.1.0 from 3.0.1.

* Remove unnecessary Elsa Server activities

Deleted sample files: DataSourceActivity, MyEndpoint, and MyEventWorkflow from the Elsa Server Web bundle as part of our ongoing codebase optimization strategy. These files were no longer required and their removal simplifies our code structure.

* Update package workflow to reference v3.0.1

The GitHub actions workflow has been updated to pull from branch v3.0.1 instead of main. This change affects the commit verification and version setting steps, now using version 3.0.1-preview in the workflow process.

* Update Elsa.Studio packages to version 3.0.1-preview.196

This commit involves updating the versions of `Elsa.Studio`, `Elsa.Studio.Core.BlazorWasm`, and `Elsa.Studio.Login.BlazorWasm` packages in `Elsa.ServerAndStudio.Web.csproj` and `ElsaStudioWebAssembly.csproj` files to 3.0.1-preview.196. This update will incorporate the new changes and improvements included in this newer version.

* Update Elsa.Studio package versions

The Elsa.Studio and Elsa.Studio.Login.BlazorWasm package versions have been updated in the Elsa.Studio.Web project. Both package versions have been upgraded from 3.0.0 to 3.0.1-preview.196.

* Remove unused Workflow models and simplify AddStorageDriver method

The commit removes BackgroundExecutionOutcome and BackgroundExecutionResult models from Elsa.Workflows.Core, as they are no longer in use. Additionally, it simplifies the AddStorageDriver extension method in ModuleExtensions.cs, now it directly adds the service as an implementation of the IStorageDriver interface.

* Remove unnecessary dependencies in DefaultBackgroundActivityInvoker

Dependencies on IBookmarksPersister and IWorkflowStateExtractor have been removed in the DefaultBackgroundActivityInvoker.cs file. Additionally, an unused `using` statement for Elsa.Workflows.Helpers has been eliminated. This commit aims to declutter the code and increase its maintainability by eliminating unnecessary dependencies.

---------

Co-authored-by: Night Wu <[email protected]>
Co-authored-by: admin <[email protected]>
  • Loading branch information
3 people authored Jan 6, 2024
1 parent 2884969 commit 71690a2
Show file tree
Hide file tree
Showing 40 changed files with 456 additions and 174 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ on:
workflow_dispatch:
push:
branches:
- main
tags:
- hotfix-* # e.g. 3.0.0-hotfix-1
- v3.0.1
release:
types: [ prereleased, published ]
env:
Expand All @@ -20,18 +18,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Verify commit exists in origin/main
- name: Verify commit exists in origin/v3.0.1
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep origin/main
git branch --remote --contains | grep origin/v3.0.1
- name: Set VERSION variable
run: |
if [[ "${{ github.ref }}" == refs/tags/* && "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then
TAG_NAME=${{ github.ref }} # e.g., refs/tags/3.0.0
TAG_NAME=${TAG_NAME#refs/tags/} # remove the refs/tags/ prefix
echo "VERSION=${TAG_NAME}" >> $GITHUB_ENV
else
echo "VERSION=3.0.0-preview.${{github.run_number}}" >> $GITHUB_ENV
echo "VERSION=3.0.1-preview.${{github.run_number}}" >> $GITHUB_ENV
fi
- name: Build
run: dotnet build --configuration Release /p:Version=${VERSION}
Expand Down
30 changes: 0 additions & 30 deletions src/bundles/Elsa.Server.Web/DataSourceActivity.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/bundles/Elsa.Server.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
const bool useMongoDb = false;
const bool useSqlServer = false;
const bool useDapper = false;
const bool useProtoActor = true;
const bool useProtoActor = false;
const bool useHangfire = false;
const bool useQuartz = true;
const bool useMassTransit = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Elsa.Studio" Version="3.0.0-preview.177"/>
<PackageReference Include="Elsa.Studio.Login.BlazorWasm" Version="3.0.0-preview.177"/>
<PackageReference Include="Elsa.Studio" Version="3.0.1-preview.196"/>
<PackageReference Include="Elsa.Studio.Login.BlazorWasm" Version="3.0.1-preview.196"/>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/bundles/Elsa.Studio.Web/Elsa.Studio.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Elsa.Studio" Version="3.0.0-preview.177"/>
<PackageReference Include="Elsa.Studio.Login.BlazorWasm" Version="3.0.0-preview.177"/>
<PackageReference Include="Elsa.Studio" Version="3.0.1-preview.196"/>
<PackageReference Include="Elsa.Studio.Login.BlazorWasm" Version="3.0.1-preview.196"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Elsa.Studio" Version="3.0.0-preview.177"/>
<PackageReference Include="Elsa.Studio.Core.BlazorWasm" Version="3.0.0-preview.177"/>
<PackageReference Include="Elsa.Studio.Login.BlazorWasm" Version="3.0.0-preview.177"/>
<PackageReference Include="Elsa.Studio" Version="3.0.1-preview.196"/>
<PackageReference Include="Elsa.Studio.Core.BlazorWasm" Version="3.0.1-preview.196"/>
<PackageReference Include="Elsa.Studio.Login.BlazorWasm" Version="3.0.1-preview.196"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public static IServiceCollection AddElsaClient(this IServiceCollection services,
{
var builderOptions = new ElsaClientBuilderOptions();
configureClient.Invoke(builderOptions);

builderOptions.ConfigureHttpClientBuilder += builder => builder.AddHttpMessageHandler(sp => (DelegatingHandler)sp.GetRequiredService(builderOptions.AuthenticationHandler));

services.AddScoped(builderOptions.AuthenticationHandler);
Expand All @@ -63,7 +62,19 @@ public static IServiceCollection AddElsaClient(this IServiceCollection services,
options.ConfigureHttpClient = builderOptions.ConfigureHttpClient;
options.ApiKey = builderOptions.ApiKey;
});

var builderOptionsWithoutRetryPolicy = new ElsaClientBuilderOptions
{
ApiKey = builderOptions.ApiKey,
AuthenticationHandler = builderOptions.AuthenticationHandler,
BaseAddress = builderOptions.BaseAddress,
ConfigureHttpClient = builderOptions.ConfigureHttpClient,
ConfigureHttpClientBuilder = builderOptions.ConfigureHttpClientBuilder,
ConfigureRetryPolicy = null
};

services.AddApi<IWorkflowDefinitionsApi>(builderOptions);
services.AddApi<IExecuteWorkflowApi>(builderOptionsWithoutRetryPolicy);
services.AddApi<IWorkflowInstancesApi>(builderOptions);
services.AddApi<IActivityDescriptorsApi>(builderOptions);
services.AddApi<IActivityDescriptorOptionsApi>(builderOptions);
Expand All @@ -89,8 +100,20 @@ public static IServiceCollection AddElsaClient(this IServiceCollection services,
public static void AddApi<T>(this IServiceCollection services, ElsaClientBuilderOptions? httpClientBuilderOptions = default) where T : class
{
var builder = services.AddRefitClient<T>(CreateRefitSettings, typeof(T).Name).ConfigureHttpClient(ConfigureElsaApiHttpClient);
httpClientBuilderOptions?.ConfigureHttpClientBuilder?.Invoke(builder);
builder.AddTransientHttpErrorPolicy(p => p.WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))));
httpClientBuilderOptions?.ConfigureHttpClientBuilder(builder);
httpClientBuilderOptions?.ConfigureRetryPolicy?.Invoke(builder);
}

/// <summary>
/// Adds a refit client for the specified API type.
/// </summary>
/// <param name="services">The service collection.</param>
/// <param name="httpClientBuilderOptions">An options object that can be used to configure the HTTP client builder.</param>
/// <typeparam name="T">The type representing the API.</typeparam>
public static void AddApiWithoutRetryPolicy<T>(this IServiceCollection services, ElsaClientBuilderOptions? httpClientBuilderOptions = default) where T : class
{
var builder = services.AddRefitClient<T>(CreateRefitSettings, typeof(T).Name).ConfigureHttpClient(ConfigureElsaApiHttpClient);
httpClientBuilderOptions?.ConfigureHttpClientBuilder(builder);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Elsa.Api.Client.HttpMessageHandlers;
using Microsoft.Extensions.DependencyInjection;
using Polly;

namespace Elsa.Api.Client.Options;

Expand Down Expand Up @@ -33,4 +34,9 @@ public class ElsaClientBuilderOptions
/// Gets or sets a delegate that can be used to configure the HTTP client builder.
/// </summary>
public Action<IHttpClientBuilder> ConfigureHttpClientBuilder { get; set; } = _ => { };

/// <summary>
/// Gets or sets a delegate that can be used to configure the retry policy.
/// </summary>
public Action<IHttpClientBuilder>? ConfigureRetryPolicy { get; set; } = builder => builder.AddTransientHttpErrorPolicy(p => p.WaitAndRetryAsync(3, attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt))));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Elsa.Api.Client.Resources.WorkflowDefinitions.Requests;
using JetBrains.Annotations;
using Refit;

namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Contracts;

/// <summary>
/// Represents a client for the workflow definitions API.
/// </summary>
[PublicAPI]
public interface IExecuteWorkflowApi
{
/// <summary>
/// Executes a workflow definition.
/// </summary>
/// <param name="definitionId">The definition ID of the workflow definition to execute.</param>
/// <param name="request">An optional request containing options for executing the workflow definition.</param>
/// <param name="cancellationToken">An optional cancellation token.</param>
/// <returns>A response containing information about the workflow instance that was created.</returns>
[Post("/workflow-definitions/{definitionId}/execute")]
Task<HttpResponseMessage> ExecuteAsync(string definitionId, ExecuteWorkflowDefinitionRequest? request, CancellationToken cancellationToken = default);

/// <summary>
/// Dispatches a request to execute the specified workflow definition.
/// </summary>
/// <param name="definitionId">The definition ID of the workflow definition to dispatch request.</param>
/// <param name="request">An optional request containing options for dispatching a request to execute the specified workflow definition.</param>
/// <param name="cancellationToken">An optional cancellation token.</param>
/// <returns>A response containing information about the workflow instance that was created.</returns>
[Post("/workflow-definitions/{definitionId}/dispatch")]
Task<HttpResponseMessage> DispatchAsync(string definitionId, DispatchWorkflowDefinitionRequest? request, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,4 @@ public interface IWorkflowDefinitionsApi
/// <param name="cancellationToken">An optional cancellation token.</param>
[Post("/workflow-definitions/{definitionId}/revert/{version}")]
Task RevertVersionAsync(string definitionId, int version, CancellationToken cancellationToken = default);

/// <summary>
/// Executes a workflow definition.
/// </summary>
/// <param name="definitionId">The definition ID of the workflow definition to execute.</param>
/// <param name="request">An optional request containing options for executing the workflow definition.</param>
/// <param name="cancellationToken">An optional cancellation token.</param>
/// <returns>A response containing information about the workflow instance that was created.</returns>
[Post("/workflow-definitions/{definitionId}/execute")]
Task<HttpResponseMessage> ExecuteAsync(string definitionId, ExecuteWorkflowDefinitionRequest? request, CancellationToken cancellationToken = default);

/// <summary>
/// Dispatches a request to execute the specified workflow definition.
/// </summary>
/// <param name="definitionId">The definition ID of the workflow definition to dispatch request.</param>
/// <param name="request">An optional request containing options for dispatching a request to execute the specified workflow definition.</param>
/// <param name="cancellationToken">An optional cancellation token.</param>
/// <returns>A response containing information about the workflow instance that was created.</returns>
[Post("/workflow-definitions/{definitionId}/dispatch")]
Task<HttpResponseMessage> DispatchAsync(string definitionId, DispatchWorkflowDefinitionRequest? request, CancellationToken cancellationToken = default);
}
6 changes: 3 additions & 3 deletions src/common/Elsa.Api.Common/Elsa.Api.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="FastEndpoints" Version="5.20.1.7-beta"/>
<PackageReference Include="FastEndpoints.Security" Version="5.20.1.7-beta"/>
<PackageReference Include="FastEndpoints.Swagger" Version="5.20.1.7-beta"/>
<PackageReference Include="FastEndpoints" Version="5.21.2"/>
<PackageReference Include="FastEndpoints.Security" Version="5.21.2"/>
<PackageReference Include="FastEndpoints.Swagger" Version="5.21.2"/>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Elsa.Dapper.Migrations/Runtime/Initial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public override void Up()
.WithColumn("ActivityType").AsString().NotNullable().Indexed()
.WithColumn("ActivityTypeVersion").AsInt32().NotNullable().Indexed()
.WithColumn("ActivityName").AsString().Nullable().Indexed()
.WithColumn("NodeId").AsString().NotNullable().Indexed()
.WithColumn("ActivityNodeId").AsString().NotNullable().Indexed()
.WithColumn("EventName").AsString().Nullable().Indexed()
.WithColumn("Message").AsString().Nullable()
.WithColumn("Source").AsString().Nullable()
Expand All @@ -86,7 +86,7 @@ public override void Up()
.WithColumn("ActivityType").AsString().NotNullable().Indexed()
.WithColumn("ActivityTypeVersion").AsInt32().NotNullable().Indexed()
.WithColumn("ActivityName").AsString().Nullable().Indexed()
.WithColumn("NodeId").AsString().NotNullable().Indexed()
.WithColumn("ActivityNodeId").AsString().NotNullable().Indexed()
.WithColumn("EventName").AsString().Nullable().Indexed()
.WithColumn("Message").AsString().Nullable()
.WithColumn("Source").AsString().Nullable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async ValueTask<long> DeleteManyAsync(WorkflowInboxMessageFilter filter,
if (pageArgs == null)
return await _store.DeleteAsync(q => ApplyFilter(q, filter), cancellationToken);

return await _store.DeleteAsync(q => ApplyFilter(q, filter), pageArgs, new[] { new OrderField(nameof(WorkflowInboxMessage.CreatedAt), OrderDirection.Ascending) }, cancellationToken);
return await _store.DeleteAsync(q => ApplyFilter(q, filter), pageArgs, new[] { new OrderField(nameof(WorkflowInboxMessage.CreatedAt), OrderDirection.Ascending) }, cancellationToken: cancellationToken);
}

private void ApplyFilter(ParameterizedQuery query, params WorkflowInboxMessageFilter[] filters)
Expand Down
22 changes: 14 additions & 8 deletions src/modules/Elsa.Dapper/Services/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,15 @@ public async Task SaveAsync(T record, string primaryKey = "Id", CancellationToke
/// <param name="cancellationToken">The cancellation token.</param>
public async Task SaveManyAsync(IEnumerable<T> records, string primaryKey = "Id", CancellationToken cancellationToken = default)
{
var recordsList = records.ToList();

if (!recordsList.Any())
return;

var query = new ParameterizedQuery(_dbConnectionProvider.Dialect);
var currentIndex = 0;

foreach (var record in records)
foreach (var record in recordsList)
{
var index = currentIndex;
query.Upsert(TableName, primaryKey, record, field => $"{field}_{index}");
Expand All @@ -217,7 +222,7 @@ public async Task SaveManyAsync(IEnumerable<T> records, string primaryKey = "Id"
using var connection = _dbConnectionProvider.GetConnection();
await query.ExecuteAsync(connection);
}

/// <summary>
/// Adds the specified record.
/// </summary>
Expand All @@ -243,26 +248,27 @@ public async Task<long> DeleteAsync(Action<ParameterizedQuery> filter, Cancellat
using var connection = _dbConnectionProvider.GetConnection();
return await query.ExecuteAsync(connection);
}

/// <summary>
/// Deletes all records matching the specified query.
/// </summary>
/// <param name="filter">The conditions to apply to the query.</param>
/// <param name="pageArgs">The page arguments.</param>
/// <param name="orderFields">The fields by which to order the results.</param>
/// <param name="primaryKey">The primary key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The number of records deleted.</returns>
public async Task<long> DeleteAsync(Action<ParameterizedQuery> filter, PageArgs pageArgs, IEnumerable<OrderField> orderFields, CancellationToken cancellationToken = default)
public async Task<long> DeleteAsync(Action<ParameterizedQuery> filter, PageArgs pageArgs, IEnumerable<OrderField> orderFields, string primaryKey = "Id", CancellationToken cancellationToken = default)
{
var selectQuery = _dbConnectionProvider.CreateQuery().From(TableName, "rowid");
var selectQuery = _dbConnectionProvider.CreateQuery().From(TableName, primaryKey);
filter(selectQuery);
selectQuery = selectQuery.OrderBy(orderFields.ToArray()).Page(pageArgs);

var deleteQuery = _dbConnectionProvider.CreateQuery().Delete(TableName, selectQuery);
using var connection = _dbConnectionProvider.GetConnection();
return await deleteQuery.ExecuteAsync(connection);
}

/// <summary>
/// Returns <c>true</c> if any records match the specified query.
/// </summary>
Expand All @@ -276,7 +282,7 @@ public async Task<bool> AnyAsync(Action<ParameterizedQuery> filter, Cancellation
using var connection = _dbConnectionProvider.GetConnection();
return await connection.QueryFirstOrDefaultAsync<object>(query.Sql.ToString(), query.Parameters) != null;
}

/// <summary>
/// Returns the number of records matching the specified query.
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Elsa.Http/Activities/FlowSendHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ protected override async ValueTask HandleResponseAsync(ActivityExecutionContext
outcomes.Add(outcome);

outcomes.Add("Done");

context.JournalData["StatusCode"] = statusCode;
await context.CompleteActivityWithOutcomesAsync(outcomes.ToArray());
}

Expand Down
17 changes: 17 additions & 0 deletions src/modules/Elsa.Http/Activities/SendHttpRequestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,24 @@ protected SendHttpRequestBase(string? source = default, int? line = default) : b
)]
public Input<HttpHeaders?> RequestHeaders { get; set; } = new(new HttpHeaders());

/// <summary>
/// The HTTP response status code
/// </summary>
[Output(Description = "The HTTP response status code")]
public Output<int> StatusCode { get; set; } = default!;

/// <summary>
/// The parsed content, if any.
/// </summary>
[Output(Description = "The parsed content, if any.")]
public Output<object?> ParsedContent { get; set; } = default!;

/// <summary>
/// The response headers that were received.
/// </summary>
[Output(Description = "The response headers that were received.")]
public Output<HttpHeaders?> ResponseHeaders { get; set; } = default!;

/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
Expand Down Expand Up @@ -115,8 +127,13 @@ private async Task TrySendAsync(ActivityExecutionContext context)
{
var response = await httpClient.SendAsync(request, cancellationToken);
var parsedContent = await ParseContentAsync(context, response.Content);
var statusCode = (int)response.StatusCode;
var responseHeaders = new HttpHeaders(response.Headers);

context.Set(Result, response);
context.Set(ParsedContent, parsedContent);
context.Set(StatusCode, statusCode);
context.Set(ResponseHeaders, responseHeaders);

await HandleResponseAsync(context, response);
}
Expand Down
Loading

0 comments on commit 71690a2

Please sign in to comment.