3
3
using System . Diagnostics ;
4
4
using System . Diagnostics . CodeAnalysis ;
5
5
using Google . Protobuf ;
6
- using Microsoft . AspNetCore . Builder ;
7
6
using Microsoft . Extensions . DependencyInjection ;
8
7
using Microsoft . Extensions . DependencyInjection . Extensions ;
9
8
using Microsoft . Extensions . Hosting ;
@@ -13,25 +12,24 @@ namespace Microsoft.AutoGen.Core.Grpc;
13
12
public static class AgentsApp
14
13
{
15
14
// need a variable to store the runtime instance
16
- public static WebApplication ? Host { get ; private set ; }
15
+ public static IHost ? Host { get ; private set ; }
17
16
18
17
[ MemberNotNull ( nameof ( Host ) ) ]
19
- public static async ValueTask < WebApplication > StartAsync ( WebApplicationBuilder ? builder = null , AgentTypes ? agentTypes = null , bool local = false )
18
+ public static async ValueTask < IHost > StartAsync ( HostApplicationBuilder ? builder = null , AgentTypes ? agentTypes = null , bool local = false )
20
19
{
21
- builder ??= WebApplication . CreateBuilder ( ) ;
20
+ builder ??= new HostApplicationBuilder ( ) ;
22
21
builder . Services . TryAddSingleton ( DistributedContextPropagator . Current ) ;
23
22
builder . AddGrpcAgentWorker ( )
24
23
. AddAgents ( agentTypes ) ;
25
- builder . AddServiceDefaults ( ) ;
26
24
var app = builder . Build ( ) ;
27
25
Host = app ;
28
26
await app . StartAsync ( ) . ConfigureAwait ( false ) ;
29
27
return Host ;
30
28
}
31
- public static async ValueTask < WebApplication > PublishMessageAsync (
29
+ public static async ValueTask < IHost > PublishMessageAsync (
32
30
string topic ,
33
31
IMessage message ,
34
- WebApplicationBuilder ? builder = null ,
32
+ HostApplicationBuilder ? builder = null ,
35
33
AgentTypes ? agents = null ,
36
34
bool local = false )
37
35
{
0 commit comments