Skip to content

Commit

Permalink
back off of aspnet
Browse files Browse the repository at this point in the history
  • Loading branch information
rysweet committed Jan 17, 2025
1 parent 7093034 commit 5b297fb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions dotnet/src/Microsoft.AutoGen/Core.Grpc/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Google.Protobuf;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
Expand All @@ -13,25 +12,24 @@ namespace Microsoft.AutoGen.Core.Grpc;
public static class AgentsApp
{
// need a variable to store the runtime instance
public static WebApplication? Host { get; private set; }
public static IHost? Host { get; private set; }

[MemberNotNull(nameof(Host))]
public static async ValueTask<WebApplication> StartAsync(WebApplicationBuilder? builder = null, AgentTypes? agentTypes = null, bool local = false)
public static async ValueTask<IHost> StartAsync(HostApplicationBuilder? builder = null, AgentTypes? agentTypes = null, bool local = false)
{
builder ??= WebApplication.CreateBuilder();
builder ??= new HostApplicationBuilder();
builder.Services.TryAddSingleton(DistributedContextPropagator.Current);
builder.AddGrpcAgentWorker()
.AddAgents(agentTypes);
builder.AddServiceDefaults();
var app = builder.Build();
Host = app;
await app.StartAsync().ConfigureAwait(false);
return Host;
}
public static async ValueTask<WebApplication> PublishMessageAsync(
public static async ValueTask<IHost> PublishMessageAsync(
string topic,
IMessage message,
WebApplicationBuilder? builder = null,
HostApplicationBuilder? builder = null,
AgentTypes? agents = null,
bool local = false)
{
Expand Down

0 comments on commit 5b297fb

Please sign in to comment.