Skip to content

Commit

Permalink
fix DI for GrpcGateway Service
Browse files Browse the repository at this point in the history
  • Loading branch information
rysweet committed Nov 2, 2024
1 parent 65d77ff commit 2291cb5
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
namespace Microsoft.AutoGen.Agents;

// gRPC service which handles communication between the agent worker and the cluster.
internal sealed class GrpcGatewayService(GrpcGateway agentWorker) : AgentRpc.AgentRpcBase
internal sealed class GrpcGatewayService : AgentRpc.AgentRpcBase
{
private readonly GrpcGateway Gateway;
public GrpcGatewayService(IGateway gateway)
{
Gateway = (GrpcGateway)gateway;
}
public override async Task OpenChannel(IAsyncStreamReader<Message> requestStream, IServerStreamWriter<Message> responseStream, ServerCallContext context)
{
try
{
await agentWorker.ConnectToWorkerProcess(requestStream, responseStream, context).ConfigureAwait(true);
await Gateway.ConnectToWorkerProcess(requestStream, responseStream, context).ConfigureAwait(true);
}
catch
{
Expand All @@ -26,13 +31,13 @@ public override async Task OpenChannel(IAsyncStreamReader<Message> requestStream
}
public override async Task<GetStateResponse> GetState(AgentId request, ServerCallContext context)
{
var state = await agentWorker.ReadAsync(request);
var state = await Gateway.ReadAsync(request);
return new GetStateResponse { AgentState = state };
}

public override async Task<SaveStateResponse> SaveState(AgentState request, ServerCallContext context)
{
await agentWorker.StoreAsync(request);
await Gateway.StoreAsync(request);
return new SaveStateResponse
{
Success = true // TODO: Implement error handling
Expand Down

0 comments on commit 2291cb5

Please sign in to comment.