first commit
This commit is contained in:
commit
ef058becac
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
# Build results
|
||||
bin/
|
||||
obj/
|
||||
|
||||
# IDE cruft
|
||||
/.vs
|
||||
/.vscode
|
||||
/.idea
|
52
Program.cs
Normal file
52
Program.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Temporalio.Client;
|
||||
using Temporalio.Extensions.Hosting;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services
|
||||
.AddHostedTemporalWorker(
|
||||
clientTargetHost: "localhost:7233",
|
||||
clientNamespace: "default",
|
||||
taskQueue: MyWorkflow.TaskQueue)
|
||||
.AddWorkflow<MyWorkflow>();
|
||||
|
||||
builder.Services.AddSingleton(ct => TemporalClient.ConnectAsync(new()
|
||||
{
|
||||
TargetHost = "localhost:7233"
|
||||
}));
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapGet("/", async (Task<TemporalClient> clientTask, string? name) =>
|
||||
{
|
||||
var client = await clientTask;
|
||||
var isRunning = await client.StartWorkflowAsync(
|
||||
(MyWorkflow wf) => wf.RunAsync(name ?? "Temporal"),
|
||||
new(id: $"aspnet-sample-workflow-{Guid.NewGuid()}", taskQueue: MyWorkflow.TaskQueue));
|
||||
return Results.Ok(isRunning.Id);
|
||||
});
|
||||
|
||||
app.MapGet("/Get", async (Task<TemporalClient> clientTask, string GetId) =>
|
||||
{
|
||||
var client = await clientTask;
|
||||
var handle = client.GetWorkflowHandle(GetId);
|
||||
var responce = await handle.DescribeAsync();
|
||||
if (responce.Status != Temporalio.Api.Enums.V1.WorkflowExecutionStatus.Completed)
|
||||
return Results.Ok(responce.Status.ToString());
|
||||
|
||||
var result = await handle.GetResultAsync<string>();
|
||||
return Results.Ok(result);
|
||||
});
|
||||
app.Run();
|
23
Properties/launchSettings.json
Normal file
23
Properties/launchSettings.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5167",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7127;http://localhost:5167",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
WorkerSerVice.cs
Normal file
18
WorkerSerVice.cs
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
using System.Threading;
|
||||
using Temporalio.Client;
|
||||
using Temporalio.Worker;
|
||||
using Temporalio.Workflows;
|
||||
|
||||
[Workflow]
|
||||
public class MyWorkflow
|
||||
{
|
||||
public const string TaskQueue = "asp-net-sample";
|
||||
|
||||
[WorkflowRun]
|
||||
public async Task<string> RunAsync(string name)
|
||||
{
|
||||
await Workflow.DelayAsync(30 * 1000);
|
||||
return $"Hello, {name}! welcome {TaskQueue}";
|
||||
}
|
||||
}
|
8
appsettings.Development.json
Normal file
8
appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
appsettings.json
Normal file
9
appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
16
aspnetnew.csproj
Normal file
16
aspnetnew.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.4" />
|
||||
<PackageReference Include="Temporalio" Version="1.6.0" />
|
||||
<PackageReference Include="Temporalio.Extensions.Hosting" Version="1.6.0" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
aspnetnew.csproj.user
Normal file
6
aspnetnew.csproj.user
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>https</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
6
aspnetnew.http
Normal file
6
aspnetnew.http
Normal file
@ -0,0 +1,6 @@
|
||||
@aspnetnew_HostAddress = http://localhost:5167
|
||||
|
||||
GET {{aspnetnew_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
Loading…
x
Reference in New Issue
Block a user