Ryan Sweet edbd20167b
bring back grpc service (#5377)
Restoring the grpc + Orleans server into the project

## Why are these changes needed?

This is the distributed agent runtime for .NET that can manage routing
messages amongst a fleet of grpc agent runtimes.

## Related issue number

## Checks

- [ ] I've included any doc changes needed for
https://microsoft.github.io/autogen/. See
https://microsoft.github.io/autogen/docs/Contribute#documentation to
build and test documentation locally.
- [x] I've added tests (if relevant) corresponding to the changes
introduced in this PR.
- [x] I've made sure all auto checks have passed.

---------

Co-authored-by: Jack Gerrits <jack@jackgerrits.com>
Co-authored-by: Jacob Alber <jaalber@microsoft.com>
2025-02-07 19:28:55 -05:00

36 lines
1.1 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved.
// TestGrpcClient.cs
using Microsoft.AutoGen.Protobuf;
namespace Microsoft.AutoGen.RuntimeGateway.Grpc.Tests.Helpers.Grpc;
internal sealed class TestGrpcClient : IDisposable
{
public TestAsyncStreamReader<Message> RequestStream { get; }
public TestServerStreamWriter<Message> ResponseStream { get; }
public TestServerCallContext CallContext { get; }
private CancellationTokenSource CallContextCancellation = new();
public TestGrpcClient()
{
CallContext = TestServerCallContext.Create(cancellationToken: CallContextCancellation.Token);
RequestStream = new TestAsyncStreamReader<Message>(CallContext);
ResponseStream = new TestServerStreamWriter<Message>(CallContext);
}
public async Task<Message> ReadNext()
{
var response = await ResponseStream.ReadNextAsync();
return response!;
}
public void AddMessage(Message message)
{
RequestStream.AddMessage(message);
}
public void Dispose()
{
CallContextCancellation.Cancel();
RequestStream.Dispose();
ResponseStream.Dispose();
}
}