mirror of
https://github.com/microsoft/autogen.git
synced 2026-02-06 07:06:38 +00:00
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>
36 lines
1.1 KiB
C#
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();
|
|
}
|
|
}
|
|
|