-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure surrogates for Orleans tests
- Loading branch information
1 parent
f276683
commit 680c3d0
Showing
11 changed files
with
345 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/Helpers/Orleans/SiloBuilderConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// SiloBuilderConfigurator.cs | ||
|
||
using Orleans.Serialization; | ||
using Orleans.TestingHost; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans; | ||
|
||
public class SiloBuilderConfigurator : ISiloConfigurator | ||
{ | ||
public void Configure(ISiloBuilder siloBuilder) | ||
{ | ||
siloBuilder.ConfigureServices(services => | ||
{ | ||
services.AddSerializer(a=> a.AddProtobufSerializer()); | ||
}); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../test/Microsoft.AutoGen.Runtime.Grpc.Tests/Helpers/Orleans/Surrogates/AgentIdSurrogate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// AgentIdSurrogate.cs | ||
using Microsoft.AutoGen.Abstractions; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans.Surrogates; | ||
|
||
[GenerateSerializer] | ||
public struct AgentIdSurrogate | ||
{ | ||
[Id(0)] | ||
public string Key; | ||
[Id(1)] | ||
public string Type; | ||
} | ||
|
||
[RegisterConverter] | ||
public sealed class AgentIdSurrogateConverter : | ||
IConverter<AgentId, AgentIdSurrogate> | ||
{ | ||
public AgentId ConvertFromSurrogate( | ||
in AgentIdSurrogate surrogate) => | ||
new AgentId | ||
{ | ||
Key = surrogate.Key, | ||
Type = surrogate.Type | ||
}; | ||
|
||
public AgentIdSurrogate ConvertToSurrogate( | ||
in AgentId value) => | ||
new AgentIdSurrogate | ||
{ | ||
Key = value.Key, | ||
Type = value.Type | ||
}; | ||
} |
53 changes: 53 additions & 0 deletions
53
...st/Microsoft.AutoGen.Runtime.Grpc.Tests/Helpers/Orleans/Surrogates/AgentStateSurrogate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// AgentStateSurrogate.cs | ||
|
||
using Google.Protobuf; | ||
using Google.Protobuf.WellKnownTypes; | ||
using Microsoft.AutoGen.Abstractions; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans.Surrogates; | ||
|
||
[GenerateSerializer] | ||
public struct AgentStateSurrogate | ||
{ | ||
[Id(0)] | ||
public string Id; | ||
[Id(1)] | ||
public string TextData; | ||
[Id(2)] | ||
public ByteString BinaryData; | ||
[Id(3)] | ||
public AgentId AgentId; | ||
[Id(4)] | ||
public string Etag; | ||
[Id(5)] | ||
public Any ProtoData; | ||
} | ||
|
||
[RegisterConverter] | ||
public sealed class AgentStateSurrogateConverter : | ||
IConverter<AgentState, AgentStateSurrogate> | ||
{ | ||
public AgentState ConvertFromSurrogate( | ||
in AgentStateSurrogate surrogate) => | ||
new AgentState | ||
{ | ||
TextData = surrogate.TextData, | ||
BinaryData = surrogate.BinaryData, | ||
AgentId = surrogate.AgentId, | ||
ProtoData = surrogate.ProtoData, | ||
ETag = surrogate.Etag | ||
}; | ||
|
||
public AgentStateSurrogate ConvertToSurrogate( | ||
in AgentState value) => | ||
new AgentStateSurrogate | ||
{ | ||
AgentId = value.AgentId, | ||
BinaryData = value.BinaryData, | ||
TextData = value.TextData, | ||
Etag = value.ETag, | ||
ProtoData = value.ProtoData | ||
}; | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
...st/Microsoft.AutoGen.Runtime.Grpc.Tests/Helpers/Orleans/Surrogates/CloudEventSurrogate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// CloudEventSurrogate.cs | ||
|
||
using Google.Protobuf; | ||
using Google.Protobuf.WellKnownTypes; | ||
using Microsoft.AutoGen.Abstractions; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans.Surrogates; | ||
|
||
// TODO: Add the rest of the properties | ||
[GenerateSerializer] | ||
public struct CloudEventSurrogate | ||
{ | ||
[Id(0)] | ||
public string Id; | ||
[Id(1)] | ||
public string TextData; | ||
[Id(2)] | ||
public ByteString BinaryData; | ||
[Id(3)] | ||
public Any ProtoData; | ||
} | ||
|
||
[RegisterConverter] | ||
public sealed class CloudEventSurrogateConverter : | ||
IConverter<CloudEvent, CloudEventSurrogate> | ||
{ | ||
public CloudEvent ConvertFromSurrogate( | ||
in CloudEventSurrogate surrogate) => | ||
new CloudEvent | ||
{ | ||
TextData = surrogate.TextData, | ||
BinaryData = surrogate.BinaryData , | ||
Id = surrogate.Id | ||
}; | ||
|
||
public CloudEventSurrogate ConvertToSurrogate( | ||
in CloudEvent value) => | ||
new CloudEventSurrogate | ||
{ | ||
TextData = value.TextData, | ||
BinaryData = value.BinaryData, | ||
Id = value.Id, | ||
ProtoData = value.ProtoData | ||
}; | ||
} |
41 changes: 41 additions & 0 deletions
41
...utoGen.Runtime.Grpc.Tests/Helpers/Orleans/Surrogates/RegisterAgentTypeRequestSurrogate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// RegisterAgentTypeRequestSurrogate.cs | ||
|
||
using Google.Protobuf.Collections; | ||
using Microsoft.AutoGen.Abstractions; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans.Surrogates; | ||
|
||
[GenerateSerializer] | ||
public struct RegisterAgentTypeRequestSurrogate | ||
{ | ||
[Id(0)] | ||
public string RequestId; | ||
[Id(1)] | ||
public string Type; | ||
[Id(2)] | ||
public RepeatedField<string> Events; | ||
} | ||
|
||
[RegisterConverter] | ||
public sealed class RegisterAgentTypeRequestSurrogateConverter : | ||
IConverter<RegisterAgentTypeRequest, RegisterAgentTypeRequestSurrogate> | ||
{ | ||
public RegisterAgentTypeRequest ConvertFromSurrogate( | ||
in RegisterAgentTypeRequestSurrogate surrogate) => | ||
new RegisterAgentTypeRequest() | ||
{ | ||
RequestId = surrogate.RequestId, | ||
Type = surrogate.Type, | ||
// TODO : Map Events | ||
}; | ||
|
||
public RegisterAgentTypeRequestSurrogate ConvertToSurrogate( | ||
in RegisterAgentTypeRequest value) => | ||
new RegisterAgentTypeRequestSurrogate | ||
{ | ||
RequestId = value.RequestId, | ||
Type = value.Type, | ||
Events = value.Events | ||
}; | ||
} |
41 changes: 41 additions & 0 deletions
41
...toGen.Runtime.Grpc.Tests/Helpers/Orleans/Surrogates/RegisterAgentTypeResponseSurrogate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// RegisterAgentTypeResponseSurrogate.cs | ||
|
||
using Microsoft.AutoGen.Abstractions; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans.Surrogates; | ||
|
||
[GenerateSerializer] | ||
public struct RegisterAgentTypeResponseSurrogate | ||
{ | ||
[Id(0)] | ||
public string RequestId; | ||
[Id(1)] | ||
public bool Success; | ||
[Id(2)] | ||
public string Error; | ||
} | ||
|
||
[RegisterConverter] | ||
public sealed class RegisterAgentTypeResponseSurrogateConverter : | ||
IConverter<RegisterAgentTypeResponse, RegisterAgentTypeResponseSurrogate> | ||
{ | ||
public RegisterAgentTypeResponse ConvertFromSurrogate( | ||
in RegisterAgentTypeResponseSurrogate surrogate) => | ||
new RegisterAgentTypeResponse | ||
{ | ||
RequestId = surrogate.RequestId, | ||
Success = surrogate.Success, | ||
Error = surrogate.Error | ||
}; | ||
|
||
public RegisterAgentTypeResponseSurrogate ConvertToSurrogate( | ||
in RegisterAgentTypeResponse value) => | ||
new RegisterAgentTypeResponseSurrogate | ||
{ | ||
RequestId = value.RequestId, | ||
Success = value.Success, | ||
Error = value.Error | ||
}; | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
...st/Microsoft.AutoGen.Runtime.Grpc.Tests/Helpers/Orleans/Surrogates/RpcRequestSurrogate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// RpcRequestSurrogate.cs | ||
|
||
using Google.Protobuf.Collections; | ||
using Microsoft.AutoGen.Abstractions; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans.Surrogates; | ||
|
||
[GenerateSerializer] | ||
public struct RpcRequestSurrogate | ||
{ | ||
[Id(0)] | ||
public string RequestId; | ||
[Id(1)] | ||
public AgentId Source; | ||
[Id(2)] | ||
public AgentId Target; | ||
[Id(3)] | ||
public string Method; | ||
[Id(4)] | ||
public Payload Payload; | ||
[Id(5)] | ||
public MapField<string, string> Metadata; | ||
} | ||
|
||
[RegisterConverter] | ||
public sealed class RpcRequestSurrogateConverter : | ||
IConverter<RpcRequest, RpcRequestSurrogate> | ||
{ | ||
public RpcRequest ConvertFromSurrogate( | ||
in RpcRequestSurrogate surrogate) => | ||
new RpcRequest | ||
{ | ||
RequestId = surrogate.RequestId, | ||
Source = surrogate.Source, | ||
Target = surrogate.Target, | ||
Method = surrogate.Method, | ||
Payload = surrogate.Payload, | ||
// TODO: Add Metadata Metadata = surrogate.Metadata | ||
}; | ||
|
||
public RpcRequestSurrogate ConvertToSurrogate( | ||
in RpcRequest value) => | ||
new RpcRequestSurrogate | ||
{ | ||
RequestId = value.RequestId, | ||
Source = value.Source, | ||
Target = value.Target, | ||
Method = value.Method, | ||
Payload = value.Payload, | ||
Metadata = value.Metadata | ||
}; | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
...t/Microsoft.AutoGen.Runtime.Grpc.Tests/Helpers/Orleans/Surrogates/RpcResponseSurrogate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// RpcResponseSurrogate.cs | ||
|
||
using Google.Protobuf.Collections; | ||
using Microsoft.AutoGen.Abstractions; | ||
|
||
namespace Microsoft.AutoGen.Runtime.Grpc.Tests.Helpers.Orleans.Surrogates; | ||
|
||
[GenerateSerializer] | ||
public struct RpcResponseSurrogate | ||
{ | ||
[Id(0)] | ||
public string RequestId; | ||
[Id(1)] | ||
public Payload Payload; | ||
[Id(2)] | ||
public string Error; | ||
[Id(3)] | ||
public MapField<string, string> Metadata; | ||
} | ||
|
||
[RegisterConverter] | ||
public sealed class RpcResponseurrogateConverter : | ||
IConverter<RpcResponse, RpcResponseSurrogate> | ||
{ | ||
public RpcResponse ConvertFromSurrogate( | ||
in RpcResponseSurrogate surrogate) => | ||
new RpcResponse | ||
{ | ||
RequestId = surrogate.RequestId, | ||
Payload = surrogate.Payload, | ||
Error = surrogate.Error, | ||
// TODO: Add Metadata = value.Metadata | ||
}; | ||
|
||
public RpcResponseSurrogate ConvertToSurrogate( | ||
in RpcResponse value) => | ||
new RpcResponseSurrogate | ||
{ | ||
RequestId = value.RequestId, | ||
Payload = value.Payload, | ||
Error = value.Error, | ||
Metadata = value.Metadata | ||
}; | ||
} | ||
|