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,27 +12,25 @@ namespace Microsoft.AutoGen.Core;
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 )
18
+ public static async ValueTask < IHost > StartAsync ( HostApplicationBuilder ? builder = null , AgentTypes ? agentTypes = null )
20
19
{
21
- builder ??= WebApplication . CreateBuilder ( ) ;
20
+ builder ??= new HostApplicationBuilder ( ) ;
22
21
builder . Services . TryAddSingleton ( DistributedContextPropagator . Current ) ;
23
22
builder . AddAgentWorker ( )
24
23
. AddAgents ( agentTypes ) ;
25
- builder . AddServiceDefaults ( ) ;
26
24
var app = builder . Build ( ) ;
27
25
28
- app . MapDefaultEndpoints ( ) ;
29
26
Host = app ;
30
27
await app . StartAsync ( ) . ConfigureAwait ( false ) ;
31
28
return Host ;
32
29
}
33
- public static async ValueTask < WebApplication > PublishMessageAsync (
30
+ public static async ValueTask < IHost > PublishMessageAsync (
34
31
string topic ,
35
32
IMessage message ,
36
- WebApplicationBuilder ? builder = null ,
33
+ HostApplicationBuilder ? builder = null ,
37
34
AgentTypes ? agents = null ,
38
35
bool local = false )
39
36
{
0 commit comments