[IDL Comm] Improve IDL for consistent naming
* [IDL Comm] Improve IDL for consistent naming Conform to predominant IDL naming convention. Also pass service and method names as separate strings. Minor fixups on empty string usage. Closes [#231](https://github.com/Microsoft/bond/pull/231)
This commit is contained in:
Родитель
e9315ac5b6
Коммит
c1e71e7313
|
@ -20,6 +20,10 @@ different versioning scheme, following the Haskell community's
|
|||
* C# NuGet version: major bump needed
|
||||
* C# Comm NuGet version: minor bump needed
|
||||
|
||||
### IDL comm ###
|
||||
* Update IDL to conform to naming conventions.
|
||||
* Adjust IDL for changes made to Epoxy internals
|
||||
|
||||
### C++ ###
|
||||
* Generated enum types now have a `FromEnum` method that can be used to
|
||||
convert from an enum value to a string. Now generated enum types have all
|
||||
|
|
|
@ -112,7 +112,8 @@ namespace #{csNamespace}
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<#{getMessageInputTypeName}, #{getMessageResultTypeName}>(
|
||||
"#{getDeclTypeName idl s}.#{methodName}",
|
||||
"#{getDeclTypeName idl s}",
|
||||
"#{methodName}",
|
||||
param,
|
||||
ct);
|
||||
}|]
|
||||
|
@ -129,7 +130,8 @@ namespace #{csNamespace}
|
|||
public void #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param)
|
||||
{
|
||||
m_connection.FireEventAsync<#{getMessageInputTypeName}>(
|
||||
"#{getDeclTypeName idl s}.#{methodName}",
|
||||
"#{getDeclTypeName idl s}",
|
||||
"#{methodName}",
|
||||
param);
|
||||
}|]
|
||||
where
|
||||
|
|
|
@ -34,7 +34,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<global::Bond.Void>> foo31Async(global::Bond.Comm.IMessage<Payload> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<Payload, global::Bond.Void>(
|
||||
"tests.Foo.foo31",
|
||||
"tests.Foo",
|
||||
"foo31",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -48,7 +49,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<Payload>> foo32Async(global::Bond.Comm.IMessage<global::Bond.Void> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<global::Bond.Void, Payload>(
|
||||
"tests.Foo.foo32",
|
||||
"tests.Foo",
|
||||
"foo32",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -62,7 +64,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<Payload>> foo33Async(global::Bond.Comm.IMessage<Payload> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<Payload, Payload>(
|
||||
"tests.Foo.foo33",
|
||||
"tests.Foo",
|
||||
"foo33",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ namespace tests
|
|||
public void foo11Async(global::Bond.Comm.IMessage<global::Bond.Void> param)
|
||||
{
|
||||
m_connection.FireEventAsync<global::Bond.Void>(
|
||||
"tests.Foo.foo11",
|
||||
"tests.Foo",
|
||||
"foo11",
|
||||
param);
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,8 @@ namespace tests
|
|||
public void foo12Async(global::Bond.Comm.IMessage<global::Bond.Void> param)
|
||||
{
|
||||
m_connection.FireEventAsync<global::Bond.Void>(
|
||||
"tests.Foo.foo12",
|
||||
"tests.Foo",
|
||||
"foo12",
|
||||
param);
|
||||
}
|
||||
|
||||
|
@ -60,7 +62,8 @@ namespace tests
|
|||
public void foo13Async(global::Bond.Comm.IMessage<BasicTypes> param)
|
||||
{
|
||||
m_connection.FireEventAsync<BasicTypes>(
|
||||
"tests.Foo.foo13",
|
||||
"tests.Foo",
|
||||
"foo13",
|
||||
param);
|
||||
}
|
||||
|
||||
|
@ -73,7 +76,8 @@ namespace tests
|
|||
public void foo14Async(global::Bond.Comm.IMessage<dummy> param)
|
||||
{
|
||||
m_connection.FireEventAsync<dummy>(
|
||||
"tests.Foo.foo14",
|
||||
"tests.Foo",
|
||||
"foo14",
|
||||
param);
|
||||
}
|
||||
|
||||
|
@ -86,7 +90,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<global::Bond.Void>> foo21Async(global::Bond.Comm.IMessage<global::Bond.Void> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<global::Bond.Void, global::Bond.Void>(
|
||||
"tests.Foo.foo21",
|
||||
"tests.Foo",
|
||||
"foo21",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -100,7 +105,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<global::Bond.Void>> foo22Async(global::Bond.Comm.IMessage<global::Bond.Void> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<global::Bond.Void, global::Bond.Void>(
|
||||
"tests.Foo.foo22",
|
||||
"tests.Foo",
|
||||
"foo22",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -114,7 +120,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<global::Bond.Void>> foo23Async(global::Bond.Comm.IMessage<BasicTypes> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<BasicTypes, global::Bond.Void>(
|
||||
"tests.Foo.foo23",
|
||||
"tests.Foo",
|
||||
"foo23",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -128,7 +135,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<global::Bond.Void>> foo24Async(global::Bond.Comm.IMessage<dummy> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<dummy, global::Bond.Void>(
|
||||
"tests.Foo.foo24",
|
||||
"tests.Foo",
|
||||
"foo24",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -142,7 +150,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<BasicTypes>> foo31Async(global::Bond.Comm.IMessage<global::Bond.Void> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<global::Bond.Void, BasicTypes>(
|
||||
"tests.Foo.foo31",
|
||||
"tests.Foo",
|
||||
"foo31",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -156,7 +165,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<BasicTypes>> foo32Async(global::Bond.Comm.IMessage<global::Bond.Void> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<global::Bond.Void, BasicTypes>(
|
||||
"tests.Foo.foo32",
|
||||
"tests.Foo",
|
||||
"foo32",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -170,7 +180,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<BasicTypes>> foo33Async(global::Bond.Comm.IMessage<BasicTypes> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<BasicTypes, BasicTypes>(
|
||||
"tests.Foo.foo33",
|
||||
"tests.Foo",
|
||||
"foo33",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -184,7 +195,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<BasicTypes>> foo34Async(global::Bond.Comm.IMessage<dummy> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<dummy, BasicTypes>(
|
||||
"tests.Foo.foo34",
|
||||
"tests.Foo",
|
||||
"foo34",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -198,7 +210,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<dummy>> foo41Async(global::Bond.Comm.IMessage<global::Bond.Void> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<global::Bond.Void, dummy>(
|
||||
"tests.Foo.foo41",
|
||||
"tests.Foo",
|
||||
"foo41",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -212,7 +225,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<dummy>> foo42Async(global::Bond.Comm.IMessage<global::Bond.Void> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<global::Bond.Void, dummy>(
|
||||
"tests.Foo.foo42",
|
||||
"tests.Foo",
|
||||
"foo42",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -226,7 +240,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<dummy>> foo43Async(global::Bond.Comm.IMessage<BasicTypes> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<BasicTypes, dummy>(
|
||||
"tests.Foo.foo43",
|
||||
"tests.Foo",
|
||||
"foo43",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
@ -240,7 +255,8 @@ namespace tests
|
|||
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<dummy>> foo44Async(global::Bond.Comm.IMessage<dummy> param, global::System.Threading.CancellationToken ct)
|
||||
{
|
||||
return m_connection.RequestResponseAsync<dummy, dummy>(
|
||||
"tests.Foo.foo44",
|
||||
"tests.Foo",
|
||||
"foo44",
|
||||
param,
|
||||
ct);
|
||||
}
|
||||
|
|
|
@ -160,7 +160,8 @@ namespace Bond.Comm.Epoxy
|
|||
return $"{nameof(EpoxyConnection)}(local: {LocalEndPoint}, remote: {RemoteEndPoint})";
|
||||
}
|
||||
|
||||
internal static Frame MessageToFrame(ulong conversationId, string methodName, EpoxyMessageType type, IMessage message, IBonded layerData, Logger logger)
|
||||
internal static Frame MessageToFrame(ulong conversationId, string serviceName, string methodName,
|
||||
EpoxyMessageType type, IMessage message, IBonded layerData, Logger logger)
|
||||
{
|
||||
var frame = new Frame(logger);
|
||||
|
||||
|
@ -169,6 +170,7 @@ namespace Bond.Comm.Epoxy
|
|||
{
|
||||
conversation_id = conversationId,
|
||||
message_type = type,
|
||||
service_name = serviceName ?? string.Empty, // service_name is not nullable
|
||||
method_name = methodName ?? string.Empty, // method_name is not nullable
|
||||
};
|
||||
|
||||
|
@ -234,7 +236,7 @@ namespace Bond.Comm.Epoxy
|
|||
return frame;
|
||||
}
|
||||
|
||||
private async Task<IMessage> SendRequestAsync<TPayload>(string methodName, IMessage<TPayload> request)
|
||||
private async Task<IMessage> SendRequestAsync<TPayload>(string serviceName, string methodName, IMessage<TPayload> request)
|
||||
{
|
||||
var conversationId = AllocateNextConversationId();
|
||||
var totalTime = Stopwatch.StartNew();
|
||||
|
@ -248,24 +250,24 @@ namespace Bond.Comm.Epoxy
|
|||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnSend(
|
||||
layerStack, MessageType.Request, sendContext, out layerData, logger);
|
||||
layerStack, MessageType.REQUEST, sendContext, out layerData, logger);
|
||||
}
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("{0} Sending request {1}/{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
this, conversationId, methodName, layerError.error_code, layerError.message);
|
||||
logger.Site().Error("{0} Sending request {1}/{2}.{3} failed due to layer error (Code: {4}, Message: {5}).",
|
||||
this, conversationId, serviceName, methodName, layerError.error_code, layerError.message);
|
||||
return Message.FromError(layerError);
|
||||
}
|
||||
|
||||
var frame = MessageToFrame(conversationId, methodName, EpoxyMessageType.Request, request, layerData, logger);
|
||||
var frame = MessageToFrame(conversationId, serviceName, methodName, EpoxyMessageType.REQUEST, request, layerData, logger);
|
||||
|
||||
logger.Site().Debug("{0} Sending request {1}/{2}.", this, conversationId, methodName);
|
||||
var responseTask = responseMap.Add(conversationId, layerStack);
|
||||
|
||||
bool wasSent = await SendFrameAsync(frame);
|
||||
logger.Site().Debug("{0} Sending request {1}/{2} {3}.",
|
||||
this, conversationId, methodName, wasSent ? "succeeded" : "failed");
|
||||
logger.Site().Debug("{0} Sending request {1}/{2}.{3} {4}.",
|
||||
this, conversationId, serviceName, methodName, wasSent ? "succeeded" : "failed");
|
||||
|
||||
if (!wasSent)
|
||||
{
|
||||
|
@ -273,14 +275,14 @@ namespace Bond.Comm.Epoxy
|
|||
conversationId,
|
||||
Message.FromError(new Error
|
||||
{
|
||||
error_code = (int) ErrorCode.TransportError,
|
||||
error_code = (int) ErrorCode.TRANSPORT_ERROR,
|
||||
message = "Request could not be sent"
|
||||
}));
|
||||
|
||||
if (!wasCompleted)
|
||||
{
|
||||
logger.Site().Information("{0} Unsuccessfully sent request {1}/{2} still received response.",
|
||||
this, conversationId, methodName);
|
||||
logger.Site().Information("{0} Unsuccessfully sent request {1}/{2}.{3} still received response.",
|
||||
this, conversationId, serviceName, methodName);
|
||||
}
|
||||
}
|
||||
var message = await responseTask;
|
||||
|
@ -297,7 +299,7 @@ namespace Bond.Comm.Epoxy
|
|||
|
||||
IBonded layerData;
|
||||
Error layerError = LayerStackUtils.ProcessOnSend(
|
||||
layerStack, MessageType.Response, sendContext, out layerData, logger);
|
||||
layerStack, MessageType.RESPONSE, sendContext, out layerData, logger);
|
||||
|
||||
// If there was a layer error, replace the response with the layer error
|
||||
if (layerError != null)
|
||||
|
@ -310,7 +312,7 @@ namespace Bond.Comm.Epoxy
|
|||
response = Message.FromError(Errors.CleanseInternalServerError(layerError));
|
||||
}
|
||||
|
||||
var frame = MessageToFrame(conversationId, null, EpoxyMessageType.Response, response, layerData, logger);
|
||||
var frame = MessageToFrame(conversationId, null, null, EpoxyMessageType.RESPONSE, response, layerData, logger);
|
||||
logger.Site().Debug("{0} Sending reply for conversation ID {1}.", this, conversationId);
|
||||
|
||||
bool wasSent = await SendFrameAsync(frame);
|
||||
|
@ -318,7 +320,7 @@ namespace Bond.Comm.Epoxy
|
|||
this, conversationId, wasSent ? "succeedeed" : "failed");
|
||||
}
|
||||
|
||||
internal async Task SendEventAsync(string methodName, IMessage message)
|
||||
internal async Task SendEventAsync(string serviceName, string methodName, IMessage message)
|
||||
{
|
||||
var conversationId = AllocateNextConversationId();
|
||||
var totalTime = Stopwatch.StartNew();
|
||||
|
@ -332,23 +334,23 @@ namespace Bond.Comm.Epoxy
|
|||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnSend(
|
||||
layerStack, MessageType.Event, sendContext, out layerData, logger);
|
||||
layerStack, MessageType.EVENT, sendContext, out layerData, logger);
|
||||
}
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("{0} Sending event {1}/{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
this, conversationId, methodName, layerError.error_code, layerError.message);
|
||||
logger.Site().Error("{0} Sending event {1}/{2}.{3} failed due to layer error (Code: {4}, Message: {5}).",
|
||||
this, conversationId, serviceName, methodName, layerError.error_code, layerError.message);
|
||||
return;
|
||||
}
|
||||
|
||||
var frame = MessageToFrame(conversationId, methodName, EpoxyMessageType.Event, message, layerData, logger);
|
||||
var frame = MessageToFrame(conversationId, serviceName, methodName, EpoxyMessageType.EVENT, message, layerData, logger);
|
||||
|
||||
logger.Site().Debug("{0} Sending event {1}/{2}.", this, conversationId, methodName);
|
||||
logger.Site().Debug("{0} Sending event {1}/{2}.{3}.", this, conversationId, serviceName, methodName);
|
||||
|
||||
bool wasSent = await SendFrameAsync(frame);
|
||||
logger.Site().Debug("{0} Sending event {1}/{2} {3}.",
|
||||
this, conversationId, methodName, wasSent ? "succeeded" : "failed");
|
||||
logger.Site().Debug("{0} Sending event {1}/{2}.{3} {4}.",
|
||||
this, conversationId, serviceName, methodName, wasSent ? "succeeded" : "failed");
|
||||
|
||||
Metrics.FinishRequestMetrics(requestMetrics, totalTime);
|
||||
metrics.Emit(requestMetrics);
|
||||
|
@ -698,6 +700,7 @@ namespace Bond.Comm.Epoxy
|
|||
var receiveContext = new EpoxyReceiveContext(this, ConnectionMetrics, requestMetrics);
|
||||
|
||||
ILayerStack layerStack = null;
|
||||
|
||||
IMessage result;
|
||||
|
||||
if (messageData.IsError)
|
||||
|
@ -706,7 +709,7 @@ namespace Bond.Comm.Epoxy
|
|||
this, headers.conversation_id);
|
||||
result = Message.FromError(new Error
|
||||
{
|
||||
error_code = (int)ErrorCode.InvalidInvocation,
|
||||
error_code = (int)ErrorCode.INVALID_INVOCATION,
|
||||
message = "Received request with an error message"
|
||||
});
|
||||
}
|
||||
|
@ -720,17 +723,17 @@ namespace Bond.Comm.Epoxy
|
|||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnReceive(
|
||||
layerStack, MessageType.Request, receiveContext, bondedLayerData, logger);
|
||||
layerStack, MessageType.REQUEST, receiveContext, bondedLayerData, logger);
|
||||
}
|
||||
|
||||
if (layerError == null)
|
||||
{
|
||||
result = await serviceHost.DispatchRequest(headers.method_name, receiveContext, request);
|
||||
result = await serviceHost.DispatchRequest(headers.service_name, headers.method_name, receiveContext, request);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Site().Error("{0} Receiving request {1}/{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
this, headers.conversation_id, headers.method_name,
|
||||
logger.Site().Error("{0} Receiving request {1}/{2}.{3} failed due to layer error (Code: {4}, Message: {5}).",
|
||||
this, headers.conversation_id, headers.service_name, headers.method_name,
|
||||
layerError.error_code, layerError.message);
|
||||
|
||||
// Set layer error as result of this Bond method call and do not dispatch to method.
|
||||
|
@ -772,12 +775,12 @@ namespace Bond.Comm.Epoxy
|
|||
|
||||
ILayerStack layerStack = tcs.Task.AsyncState as ILayerStack;
|
||||
|
||||
Error layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.Response, receiveContext, bondedLayerData, logger);
|
||||
Error layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.RESPONSE, receiveContext, bondedLayerData, logger);
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("{0} Receiving response {1}/{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
this, headers.conversation_id, headers.method_name,
|
||||
logger.Site().Error("{0} Receiving response {1}/{2}.{3} failed due to layer error (Code: {4}, Message: {5}).",
|
||||
this, headers.conversation_id, headers.service_name, headers.method_name,
|
||||
layerError.error_code, layerError.message);
|
||||
response = Message.FromError(layerError);
|
||||
}
|
||||
|
@ -811,18 +814,18 @@ namespace Bond.Comm.Epoxy
|
|||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnReceive(
|
||||
layerStack, MessageType.Event, receiveContext, bondedLayerData, logger);
|
||||
layerStack, MessageType.EVENT, receiveContext, bondedLayerData, logger);
|
||||
}
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("{0}: Receiving event {1}/{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
this, headers.conversation_id, headers.method_name,
|
||||
logger.Site().Error("{0}: Receiving event {1}/{2}.{3} failed due to layer error (Code: {4}, Message: {5}).",
|
||||
this, headers.conversation_id, headers.service_name, headers.method_name,
|
||||
layerError.error_code, layerError.message);
|
||||
return;
|
||||
}
|
||||
|
||||
await serviceHost.DispatchEvent(headers.method_name, receiveContext, request);
|
||||
await serviceHost.DispatchEvent(headers.service_name, headers.method_name, receiveContext, request);
|
||||
Metrics.FinishRequestMetrics(requestMetrics, totalTime);
|
||||
metrics.Emit(requestMetrics);
|
||||
});
|
||||
|
@ -837,19 +840,20 @@ namespace Bond.Comm.Epoxy
|
|||
return stopTask.Task;
|
||||
}
|
||||
|
||||
public async Task<IMessage<TResponse>> RequestResponseAsync<TRequest, TResponse>(string methodName, IMessage<TRequest> message, CancellationToken ct)
|
||||
public async Task<IMessage<TResponse>> RequestResponseAsync<TRequest, TResponse>(string serviceName, string methodName,
|
||||
IMessage<TRequest> message, CancellationToken ct)
|
||||
{
|
||||
EnsureCorrectState(State.Connected);
|
||||
|
||||
// TODO: cancellation
|
||||
IMessage response = await SendRequestAsync(methodName, message);
|
||||
IMessage response = await SendRequestAsync(serviceName, methodName, message);
|
||||
return response.Convert<TResponse>();
|
||||
}
|
||||
|
||||
public Task FireEventAsync<TPayload>(string methodName, IMessage<TPayload> message)
|
||||
public Task FireEventAsync<TPayload>(string serviceName, string methodName, IMessage<TPayload> message)
|
||||
{
|
||||
EnsureCorrectState(State.Connected);
|
||||
return SendEventAsync(methodName, message);
|
||||
return SendEventAsync(serviceName, methodName, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -471,9 +471,9 @@ namespace Bond.Comm.Epoxy
|
|||
|
||||
switch (headers.message_type)
|
||||
{
|
||||
case EpoxyMessageType.Request:
|
||||
case EpoxyMessageType.Response:
|
||||
case EpoxyMessageType.Event:
|
||||
case EpoxyMessageType.REQUEST:
|
||||
case EpoxyMessageType.RESPONSE:
|
||||
case EpoxyMessageType.EVENT:
|
||||
return ClassifyState.ValidFrame;
|
||||
|
||||
default:
|
||||
|
@ -493,15 +493,15 @@ namespace Bond.Comm.Epoxy
|
|||
|
||||
switch (headers.message_type)
|
||||
{
|
||||
case EpoxyMessageType.Request:
|
||||
case EpoxyMessageType.REQUEST:
|
||||
disposition = FrameDisposition.DeliverRequestToService;
|
||||
return ClassifyState.ClassifiedValidFrame;
|
||||
|
||||
case EpoxyMessageType.Response:
|
||||
case EpoxyMessageType.RESPONSE:
|
||||
disposition = FrameDisposition.DeliverResponseToProxy;
|
||||
return ClassifyState.ClassifiedValidFrame;
|
||||
|
||||
case EpoxyMessageType.Event:
|
||||
case EpoxyMessageType.EVENT:
|
||||
disposition = FrameDisposition.DeliverEventToService;
|
||||
return ClassifyState.ClassifiedValidFrame;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Bond.Comm.Epoxy
|
|||
/// The <see cref="ErrorCode"/> that is used in the <see cref="Error"/>
|
||||
/// response when the ResponseMap has been shutdown.
|
||||
/// </summary>
|
||||
public static readonly ErrorCode ShutDownErrorCode = ErrorCode.ConnectionShutDown;
|
||||
public static readonly ErrorCode ShutDownErrorCode = ErrorCode.CONNECTION_SHUT_DOWN;
|
||||
const string ShutdownMessage = "Connection has already been shutdown";
|
||||
|
||||
static readonly Lazy<IMessage> alreadyShutdownResponse = new Lazy<IMessage>(InitAlreadyShutdownResponse, LazyThreadSafetyMode.PublicationOnly);
|
||||
|
|
|
@ -18,10 +18,13 @@ namespace Bond.Comm
|
|||
/// </summary>
|
||||
/// <typeparam name="TRequest">The type of the request.</typeparam>
|
||||
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
||||
/// <param name="methodName">
|
||||
/// The fully qualified name in the Bond namespace of the method to
|
||||
/// <param name="serviceName">
|
||||
/// The fully qualified name in the Bond namespace of the service to
|
||||
/// invoke.
|
||||
/// </param>
|
||||
/// <param name="methodName">
|
||||
/// The name of the method to invoke within the indicated service.
|
||||
/// </param>
|
||||
/// <param name="message">The message to send.</param>
|
||||
/// <param name="ct">
|
||||
/// The cancellation token for cooperative cancellation.
|
||||
|
@ -30,7 +33,8 @@ namespace Bond.Comm
|
|||
/// A task that represents the result of invoking the method. This is
|
||||
/// usually the response to the method, but may be an error.
|
||||
/// </returns>
|
||||
Task<IMessage<TResponse>> RequestResponseAsync<TRequest, TResponse>(string methodName, IMessage<TRequest> message, CancellationToken ct);
|
||||
Task<IMessage<TResponse>> RequestResponseAsync<TRequest, TResponse>(string serviceName, string methodName,
|
||||
IMessage<TRequest> message, CancellationToken ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -43,10 +47,13 @@ namespace Bond.Comm
|
|||
/// Starts an asynchronous operation to invoke an event method.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPayload">The type of the event.</typeparam>
|
||||
/// <param name="methodName">
|
||||
/// The fully qualified name in the Bond namespace of the method to
|
||||
/// <param name="serviceName">
|
||||
/// The fully qualified name in the Bond namespace of the service to
|
||||
/// invoke.
|
||||
/// </param>
|
||||
/// <param name="methodName">
|
||||
/// The name of the method to invoke within the indicated service.
|
||||
/// </param>
|
||||
/// <param name="message">The message to send.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <remarks>
|
||||
|
@ -54,7 +61,7 @@ namespace Bond.Comm
|
|||
/// task may represent an error if there was a local error sending the
|
||||
/// message.
|
||||
/// </remarks>
|
||||
Task FireEventAsync<TPayload>(string methodName, IMessage<TPayload> message);
|
||||
Task FireEventAsync<TPayload>(string serviceName, string methodName, IMessage<TPayload> message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace Bond.Comm
|
|||
{
|
||||
var internalServerError = new InternalServerError
|
||||
{
|
||||
error_code = (int) ErrorCode.InternalServerError,
|
||||
unique_id = uniqueId ?? "",
|
||||
error_code = (int) ErrorCode.INTERNAL_SERVER_ERROR,
|
||||
unique_id = uniqueId ?? string.Empty,
|
||||
message = message ?? InternalErrorMessage
|
||||
};
|
||||
|
||||
|
@ -68,8 +68,8 @@ namespace Bond.Comm
|
|||
{
|
||||
var internalServerError = new InternalServerError
|
||||
{
|
||||
error_code = (int)ErrorCode.InternalServerError,
|
||||
unique_id = uniqueId ?? ""
|
||||
error_code = (int)ErrorCode.INTERNAL_SERVER_ERROR,
|
||||
unique_id = uniqueId ?? string.Empty
|
||||
};
|
||||
|
||||
if (includeDetails && exception != null)
|
||||
|
@ -82,7 +82,7 @@ namespace Bond.Comm
|
|||
{
|
||||
var aggregateError = new AggregateError
|
||||
{
|
||||
error_code = (int) ErrorCode.MultipleErrorsOccured,
|
||||
error_code = (int) ErrorCode.MULTIPLE_ERRORS_OCCURRED,
|
||||
message = "One or more errors occured",
|
||||
inner_errors = new List<IBonded<Error>>(aggEx.InnerExceptions.Count)
|
||||
};
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace Bond.Comm
|
|||
/// <remarks>
|
||||
/// After a service has been removed, the listener will cease directing
|
||||
/// messages to its methods and will respond with a
|
||||
/// <see cref="ErrorCode.MethodNotFound"/> error.
|
||||
/// <see cref="ErrorCode.METHOD_NOT_FOUND"/> error.
|
||||
/// </remarks>
|
||||
public abstract void RemoveService<T>(T service) where T : IService;
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@ namespace Bond.Comm.Service
|
|||
this.logger = logger;
|
||||
}
|
||||
|
||||
private static void Update(RequestMetrics requestMetrics, string methodName, Stopwatch serviceTime)
|
||||
private static void Update(RequestMetrics requestMetrics, string serviceName, string methodName, Stopwatch serviceTime)
|
||||
{
|
||||
requestMetrics.method_name = methodName ?? "";
|
||||
requestMetrics.service_name = serviceName ?? string.Empty;
|
||||
requestMetrics.method_name = methodName ?? string.Empty;
|
||||
requestMetrics.service_method_time_millis = serviceTime?.Elapsed.TotalMilliseconds ?? 0;
|
||||
}
|
||||
|
||||
|
@ -113,25 +114,26 @@ namespace Bond.Comm.Service
|
|||
logger.Site().Information("Deregistered {0}.", typeof(T).Name);
|
||||
}
|
||||
|
||||
public async Task<IMessage> DispatchRequest(string methodName, ReceiveContext context, IMessage message)
|
||||
public async Task<IMessage> DispatchRequest(string serviceName, string methodName, ReceiveContext context, IMessage message)
|
||||
{
|
||||
string qualifiedName = serviceName + "." + methodName;
|
||||
Stopwatch serviceTime = null;
|
||||
logger.Site().Information("Got request [{0}] from {1}.", methodName, context.Connection);
|
||||
logger.Site().Information("Got request [{0}] from {1}.", qualifiedName, context.Connection);
|
||||
|
||||
try
|
||||
{
|
||||
ServiceMethodInfo methodInfo;
|
||||
lock (dispatchTableLock)
|
||||
{
|
||||
if (!dispatchTable.TryGetValue(methodName, out methodInfo))
|
||||
if (!dispatchTable.TryGetValue(qualifiedName, out methodInfo))
|
||||
{
|
||||
var errorMessage = "Got request for unknown method [" + methodName + "].";
|
||||
var errorMessage = "Got request for unknown method [" + qualifiedName + "].";
|
||||
|
||||
logger.Site().Error(errorMessage);
|
||||
var error = new Error
|
||||
{
|
||||
message = errorMessage,
|
||||
error_code = (int) ErrorCode.MethodNotFound
|
||||
error_code = (int) ErrorCode.METHOD_NOT_FOUND
|
||||
};
|
||||
return Message.FromError(error);
|
||||
}
|
||||
|
@ -139,7 +141,7 @@ namespace Bond.Comm.Service
|
|||
|
||||
if (methodInfo.CallbackType != ServiceCallbackType.RequestResponse)
|
||||
{
|
||||
var errorMessage = "Method [" + methodName + "] invoked as if it were " +
|
||||
var errorMessage = "Method [" + qualifiedName + "] invoked as if it were " +
|
||||
ServiceCallbackType.RequestResponse + ", but it was registered as " +
|
||||
methodInfo.CallbackType + ".";
|
||||
|
||||
|
@ -147,7 +149,7 @@ namespace Bond.Comm.Service
|
|||
var error = new Error
|
||||
{
|
||||
message = errorMessage,
|
||||
error_code = (int) ErrorCode.InvalidInvocation
|
||||
error_code = (int) ErrorCode.INVALID_INVOCATION
|
||||
};
|
||||
return Message.FromError(error);
|
||||
}
|
||||
|
@ -164,7 +166,7 @@ namespace Bond.Comm.Service
|
|||
catch (Exception ex)
|
||||
{
|
||||
logger.Site()
|
||||
.Error(ex, "Failed to complete method [{0}]. With exception: {1}", methodName, ex.Message);
|
||||
.Error(ex, "Failed to complete method [{0}]. With exception: {1}", qualifiedName, ex.Message);
|
||||
result = Message.FromError(
|
||||
Errors.MakeInternalServerError(ex, context.RequestMetrics.request_id, includeDetails: false));
|
||||
}
|
||||
|
@ -172,23 +174,24 @@ namespace Bond.Comm.Service
|
|||
}
|
||||
finally
|
||||
{
|
||||
Update(context.RequestMetrics, methodName, serviceTime);
|
||||
Update(context.RequestMetrics, serviceName, methodName, serviceTime);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DispatchEvent(string methodName, ReceiveContext context, IMessage message)
|
||||
public async Task DispatchEvent(string serviceName, string methodName, ReceiveContext context, IMessage message)
|
||||
{
|
||||
string qualifiedName = serviceName + "." + methodName;
|
||||
Stopwatch serviceTime = null;
|
||||
logger.Site().Information("Got event [{0}] from {1}.", methodName, context.Connection);
|
||||
logger.Site().Information("Got event [{0}] from {1}.", qualifiedName, context.Connection);
|
||||
|
||||
try
|
||||
{
|
||||
ServiceMethodInfo methodInfo;
|
||||
lock (dispatchTableLock)
|
||||
{
|
||||
if (!dispatchTable.TryGetValue(methodName, out methodInfo))
|
||||
if (!dispatchTable.TryGetValue(qualifiedName, out methodInfo))
|
||||
{
|
||||
logger.Site().Error("Got request for unknown method [{0}].", methodName);
|
||||
logger.Site().Error("Got request for unknown method [{0}].", qualifiedName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +199,7 @@ namespace Bond.Comm.Service
|
|||
if (methodInfo.CallbackType != ServiceCallbackType.Event)
|
||||
{
|
||||
logger.Site().Error("Method [{0}] invoked as if it were {1}, but it was registered as {2}.",
|
||||
methodName, ServiceCallbackType.Event, methodInfo.CallbackType);
|
||||
qualifiedName, ServiceCallbackType.Event, methodInfo.CallbackType);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -208,12 +211,12 @@ namespace Bond.Comm.Service
|
|||
catch (Exception ex)
|
||||
{
|
||||
logger.Site()
|
||||
.Error(ex, "Failed to complete method [{0}]. With exception: {1}", methodName, ex.Message);
|
||||
.Error(ex, "Failed to complete method [{0}]. With exception: {1}", qualifiedName, ex.Message);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Update(context.RequestMetrics, methodName, serviceTime);
|
||||
Update(context.RequestMetrics, serviceName, methodName, serviceTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,15 +43,15 @@ namespace Bond.Comm.SimpleInMem.Processor
|
|||
|
||||
switch(payload.headers.message_type)
|
||||
{
|
||||
case SimpleInMemMessageType.Event:
|
||||
case SimpleInMemMessageType.EVENT:
|
||||
Task.Run(() => DispatchEvent(payload));
|
||||
break;
|
||||
|
||||
case SimpleInMemMessageType.Request:
|
||||
case SimpleInMemMessageType.REQUEST:
|
||||
Task.Run(() => DispatchRequest(payload, writeQueue));
|
||||
break;
|
||||
|
||||
case SimpleInMemMessageType.Response:
|
||||
case SimpleInMemMessageType.RESPONSE:
|
||||
Task.Run(() => DispatchResponse(payload));
|
||||
break;
|
||||
|
||||
|
@ -81,19 +81,19 @@ namespace Bond.Comm.SimpleInMem.Processor
|
|||
|
||||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.Request, receiveContext, layerData, logger);
|
||||
layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.REQUEST, receiveContext, layerData, logger);
|
||||
}
|
||||
|
||||
IMessage response;
|
||||
|
||||
if (layerError == null)
|
||||
{
|
||||
response = await serviceHost.DispatchRequest(headers.method_name, receiveContext, message);
|
||||
response = await serviceHost.DispatchRequest(headers.service_name, headers.method_name, receiveContext, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Site().Error("Receiving request {0}/{1} failed due to layer error (Code: {2}, Message: {3}).",
|
||||
headers.conversation_id, headers.method_name, layerError.error_code, layerError.message);
|
||||
logger.Site().Error("Receiving request {0}/{1}.{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
headers.conversation_id, headers.service_name, headers.method_name, layerError.error_code, layerError.message);
|
||||
|
||||
// Set layer error as result of this Bond method call and do not dispatch to method.
|
||||
// Since this error will be returned to client, cleanse out internal server error details, if any.
|
||||
|
@ -112,7 +112,7 @@ namespace Bond.Comm.SimpleInMem.Processor
|
|||
var sendContext = new SimpleInMemSendContext(connection, connection.ConnectionMetrics, requestMetrics);
|
||||
IBonded layerData = null;
|
||||
|
||||
Error layerError = LayerStackUtils.ProcessOnSend(layerStack, MessageType.Response, sendContext, out layerData, logger);
|
||||
Error layerError = LayerStackUtils.ProcessOnSend(layerStack, MessageType.RESPONSE, sendContext, out layerData, logger);
|
||||
|
||||
// If there was a layer error, replace the response with the layer error
|
||||
if (layerError != null)
|
||||
|
@ -125,7 +125,7 @@ namespace Bond.Comm.SimpleInMem.Processor
|
|||
response = Message.FromError(Errors.CleanseInternalServerError(layerError));
|
||||
}
|
||||
|
||||
var payload = Util.NewPayLoad(conversationId, SimpleInMemMessageType.Response, layerData, response, taskSource);
|
||||
var payload = Util.NewPayLoad(conversationId, SimpleInMemMessageType.RESPONSE, layerData, response, taskSource);
|
||||
queue.Enqueue(payload);
|
||||
}
|
||||
|
||||
|
@ -140,12 +140,12 @@ namespace Bond.Comm.SimpleInMem.Processor
|
|||
|
||||
ILayerStack layerStack = taskSource.Task.AsyncState as ILayerStack;
|
||||
|
||||
Error layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.Response, receiveContext, layerData, logger);
|
||||
Error layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.RESPONSE, receiveContext, layerData, logger);
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("Receiving response {0}/{1} failed due to layer error (Code: {2}, Message: {3}).",
|
||||
headers.conversation_id, headers.method_name, layerError.error_code, layerError.message);
|
||||
logger.Site().Error("Receiving response {0}/{1}.{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
headers.conversation_id, headers.service_name, headers.method_name, layerError.error_code, layerError.message);
|
||||
message = Message.FromError(layerError);
|
||||
}
|
||||
|
||||
|
@ -165,17 +165,17 @@ namespace Bond.Comm.SimpleInMem.Processor
|
|||
|
||||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.Event, receiveContext, layerData, logger);
|
||||
layerError = LayerStackUtils.ProcessOnReceive(layerStack, MessageType.EVENT, receiveContext, layerData, logger);
|
||||
}
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("Receiving event {0}/{1} failed due to layer error (Code: {2}, Message: {3}).",
|
||||
headers.conversation_id, headers.method_name, layerError.error_code, layerError.message);
|
||||
logger.Site().Error("Receiving event {0}/{1}.{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
headers.conversation_id, headers.service_name, headers.method_name, layerError.error_code, layerError.message);
|
||||
return;
|
||||
}
|
||||
|
||||
await serviceHost.DispatchEvent(headers.method_name, receiveContext, message);
|
||||
await serviceHost.DispatchEvent(headers.service_name, headers.method_name, receiveContext, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,17 +158,18 @@ namespace Bond.Comm.SimpleInMem
|
|||
return pair;
|
||||
}
|
||||
|
||||
public async Task<IMessage<TResponse>> RequestResponseAsync<TRequest, TResponse>(string methodName, IMessage<TRequest> message, CancellationToken ct)
|
||||
public async Task<IMessage<TResponse>> RequestResponseAsync<TRequest, TResponse>(string serviceName, string methodName,
|
||||
IMessage<TRequest> message, CancellationToken ct)
|
||||
{
|
||||
EnsureCorrectState(CnxState.Connected);
|
||||
IMessage response = await SendRequestAsync(methodName, message);
|
||||
IMessage response = await SendRequestAsync(serviceName, methodName, message);
|
||||
return response.Convert<TResponse>();
|
||||
}
|
||||
|
||||
public Task FireEventAsync<TPayload>(string methodName, IMessage<TPayload> message)
|
||||
public Task FireEventAsync<TPayload>(string serviceName, string methodName, IMessage<TPayload> message)
|
||||
{
|
||||
EnsureCorrectState(CnxState.Connected);
|
||||
SendEventAsync(methodName, message);
|
||||
SendEventAsync(serviceName, methodName, message);
|
||||
return TaskExt.CompletedTask;
|
||||
}
|
||||
|
||||
|
@ -189,7 +190,7 @@ namespace Bond.Comm.SimpleInMem
|
|||
}
|
||||
}
|
||||
|
||||
private Task<IMessage> SendRequestAsync(string methodName, IMessage request)
|
||||
private Task<IMessage> SendRequestAsync(string serviceName, string methodName, IMessage request)
|
||||
{
|
||||
var requestMetrics = Metrics.StartRequestMetrics(ConnectionMetrics);
|
||||
var conversationId = AllocateNextConversationId();
|
||||
|
@ -202,26 +203,27 @@ namespace Bond.Comm.SimpleInMem
|
|||
|
||||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnSend(layerStack, MessageType.Request, sendContext, out layerData, logger);
|
||||
layerError = LayerStackUtils.ProcessOnSend(layerStack, MessageType.REQUEST, sendContext, out layerData, logger);
|
||||
}
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("{0}: Sending request {1}/{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
this, conversationId, methodName, layerError.error_code, layerError.message);
|
||||
logger.Site().Error("{0}: Sending request {1}/{2}.{3} failed due to layer error (Code: {4}, Message: {5}).",
|
||||
this, conversationId, serviceName, methodName, layerError.error_code, layerError.message);
|
||||
return Task.FromResult<IMessage>(Message.FromError(layerError));
|
||||
}
|
||||
|
||||
// Pass the layer stack instance as state in response task completion source.
|
||||
var responseCompletionSource = new TaskCompletionSource<IMessage>(layerStack);
|
||||
var payload = Util.NewPayLoad(conversationId, SimpleInMemMessageType.Request, layerData, request, responseCompletionSource);
|
||||
var payload = Util.NewPayLoad(conversationId, SimpleInMemMessageType.REQUEST, layerData, request, responseCompletionSource);
|
||||
payload.headers.service_name = serviceName;
|
||||
payload.headers.method_name = methodName;
|
||||
writeQueue.Enqueue(payload);
|
||||
|
||||
return payload.outstandingRequest.Task;
|
||||
}
|
||||
|
||||
private void SendEventAsync(string methodName, IMessage message)
|
||||
private void SendEventAsync(string serviceName, string methodName, IMessage message)
|
||||
{
|
||||
var requestMetrics = Metrics.StartRequestMetrics(ConnectionMetrics);
|
||||
var conversationId = AllocateNextConversationId();
|
||||
|
@ -233,17 +235,18 @@ namespace Bond.Comm.SimpleInMem
|
|||
|
||||
if (layerError == null)
|
||||
{
|
||||
layerError = LayerStackUtils.ProcessOnSend(layerStack, MessageType.Event, sendContext, out layerData, logger);
|
||||
layerError = LayerStackUtils.ProcessOnSend(layerStack, MessageType.EVENT, sendContext, out layerData, logger);
|
||||
}
|
||||
|
||||
if (layerError != null)
|
||||
{
|
||||
logger.Site().Error("{0}: Sending event {1}/{2} failed due to layer error (Code: {3}, Message: {4}).",
|
||||
this, conversationId, methodName, layerError.error_code, layerError.message);
|
||||
logger.Site().Error("{0}: Sending event {1}/{2}.{3} failed due to layer error (Code: {4}, Message: {5}).",
|
||||
this, conversationId, serviceName, methodName, layerError.error_code, layerError.message);
|
||||
return;
|
||||
}
|
||||
|
||||
var payload = Util.NewPayLoad(conversationId, SimpleInMemMessageType.Event, layerData, message, null);
|
||||
var payload = Util.NewPayLoad(conversationId, SimpleInMemMessageType.EVENT, layerData, message, null);
|
||||
payload.headers.service_name = serviceName;
|
||||
payload.headers.method_name = methodName;
|
||||
writeQueue.Enqueue(payload);
|
||||
}
|
||||
|
|
|
@ -5,14 +5,15 @@ namespace bond.comm.simpleinmem;
|
|||
|
||||
enum SimpleInMemMessageType
|
||||
{
|
||||
Request = 1;
|
||||
Response = 2;
|
||||
Event = 3;
|
||||
REQUEST = 1;
|
||||
RESPONSE = 2;
|
||||
EVENT = 3;
|
||||
}
|
||||
|
||||
struct SimpleInMemHeaders
|
||||
{
|
||||
0: uint64 conversation_id;
|
||||
1: required SimpleInMemMessageType message_type = Request;
|
||||
2: string method_name;
|
||||
1: required SimpleInMemMessageType message_type = REQUEST;
|
||||
2: string service_name;
|
||||
3: string method_name;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace UnitTest.Epoxy
|
|||
|
||||
private static readonly Error AnyDetails = new Error
|
||||
{
|
||||
error_code = (int) ErrorCode.MethodNotFound,
|
||||
error_code = (int) ErrorCode.METHOD_NOT_FOUND,
|
||||
message = "This is some error message"
|
||||
};
|
||||
|
||||
|
@ -97,7 +97,7 @@ namespace UnitTest.Epoxy
|
|||
IMessage<SomePayload> anyPayload = Message.FromPayload(new SomePayload());
|
||||
Task<IMessage<SomePayload>> responseTask = connection
|
||||
.RequestResponseAsync<SomePayload, SomePayload>(
|
||||
"TestService.NeverRespond", anyPayload, CancellationToken.None);
|
||||
"TestService", "NeverRespond", anyPayload, CancellationToken.None);
|
||||
|
||||
await connection.StopAsync();
|
||||
|
||||
|
@ -105,7 +105,7 @@ namespace UnitTest.Epoxy
|
|||
|
||||
Assert.IsTrue(response.IsError);
|
||||
Error err = response.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.ConnectionShutDown, err.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.CONNECTION_SHUT_DOWN, err.error_code);
|
||||
}
|
||||
|
||||
class TestServiceNeverResponds : IService
|
||||
|
|
|
@ -19,33 +19,38 @@ namespace UnitTest.Epoxy
|
|||
{
|
||||
private const uint GoodRequestId = 1;
|
||||
private const uint GoodResponseId = 1;
|
||||
private const string GoodService = "MyService";
|
||||
private const string GoodMethod = "ShaveYaks";
|
||||
private const ProtocolErrorCode MeaninglessErrorCode = ProtocolErrorCode.GENERIC_ERROR;
|
||||
private static readonly IMessage<Dummy> meaninglessPayload = new Message<Dummy>(new Dummy());
|
||||
private static readonly IMessage meaninglessError = Message.FromError(new InternalServerError() { error_code = (int)ErrorCode.InternalServerError, message = "Meaningless message"});
|
||||
private static readonly IMessage meaninglessError = Message.FromError(new InternalServerError() { error_code = (int)ErrorCode.INTERNAL_SERVER_ERROR, message = "Meaningless message"});
|
||||
private static readonly ArraySegment<byte> emptyLayerData = new ArraySegment<byte>();
|
||||
private static ArraySegment<byte> goodLayerData;
|
||||
|
||||
private static readonly EpoxyHeaders goodRequestHeaders = new EpoxyHeaders
|
||||
{
|
||||
service_name = GoodService,
|
||||
method_name = GoodMethod,
|
||||
message_type = EpoxyMessageType.Request,
|
||||
message_type = EpoxyMessageType.REQUEST,
|
||||
conversation_id = GoodRequestId
|
||||
};
|
||||
private static readonly EpoxyHeaders goodResponseHeaders = new EpoxyHeaders
|
||||
{
|
||||
service_name = GoodService,
|
||||
method_name = GoodMethod,
|
||||
message_type = EpoxyMessageType.Response,
|
||||
message_type = EpoxyMessageType.RESPONSE,
|
||||
conversation_id = GoodResponseId
|
||||
};
|
||||
private static readonly EpoxyHeaders goodEventHeaders = new EpoxyHeaders
|
||||
{
|
||||
service_name = GoodService,
|
||||
method_name = GoodMethod,
|
||||
message_type = EpoxyMessageType.Event,
|
||||
message_type = EpoxyMessageType.EVENT,
|
||||
conversation_id = GoodRequestId
|
||||
};
|
||||
private static readonly EpoxyHeaders unknownTypeHeaders = new EpoxyHeaders
|
||||
{
|
||||
service_name = GoodService,
|
||||
method_name = GoodMethod,
|
||||
message_type = (EpoxyMessageType)(-100),
|
||||
conversation_id = GoodRequestId
|
||||
|
@ -85,17 +90,17 @@ namespace UnitTest.Epoxy
|
|||
|
||||
// Good frames, from which we can pull good framelets to build bad frames.
|
||||
goodRequestFrame = EpoxyConnection.MessageToFrame(
|
||||
GoodRequestId, GoodMethod, EpoxyMessageType.Request, meaninglessPayload, null, LoggerTests.BlackHole);
|
||||
GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.REQUEST, meaninglessPayload, null, LoggerTests.BlackHole);
|
||||
goodRequestLayerDataFrame = EpoxyConnection.MessageToFrame(
|
||||
GoodRequestId, GoodMethod, EpoxyMessageType.Request, meaninglessPayload, goodLayerObject, LoggerTests.BlackHole);
|
||||
GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.REQUEST, meaninglessPayload, goodLayerObject, LoggerTests.BlackHole);
|
||||
|
||||
goodResponseFrame = EpoxyConnection.MessageToFrame(
|
||||
GoodResponseId, GoodMethod, EpoxyMessageType.Response, meaninglessPayload, null, LoggerTests.BlackHole);
|
||||
GoodResponseId, GoodService, GoodMethod, EpoxyMessageType.RESPONSE, meaninglessPayload, null, LoggerTests.BlackHole);
|
||||
goodErrorResponseFrame = EpoxyConnection.MessageToFrame(
|
||||
GoodResponseId, GoodMethod, EpoxyMessageType.Response, meaninglessError, null, LoggerTests.BlackHole);
|
||||
GoodResponseId, GoodService, GoodMethod, EpoxyMessageType.RESPONSE, meaninglessError, null, LoggerTests.BlackHole);
|
||||
|
||||
goodEventFrame = EpoxyConnection.MessageToFrame(
|
||||
GoodRequestId, GoodMethod, EpoxyMessageType.Event, meaninglessPayload, null, LoggerTests.BlackHole);
|
||||
GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.EVENT, meaninglessPayload, null, LoggerTests.BlackHole);
|
||||
|
||||
configFrame = EpoxyConnection.MakeConfigFrame(LoggerTests.BlackHole);
|
||||
protocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(MeaninglessErrorCode, null, LoggerTests.BlackHole);
|
||||
|
@ -196,8 +201,9 @@ namespace UnitTest.Epoxy
|
|||
Assert.AreEqual(EpoxyProtocol.ClassifyState.ExpectOptionalLayerData, after);
|
||||
Assert.NotNull(headers);
|
||||
Assert.AreEqual(GoodRequestId, headers.conversation_id);
|
||||
Assert.AreEqual(GoodService, headers.service_name);
|
||||
Assert.AreEqual(GoodMethod, headers.method_name);
|
||||
Assert.AreEqual(EpoxyMessageType.Request, headers.message_type);
|
||||
Assert.AreEqual(EpoxyMessageType.REQUEST, headers.message_type);
|
||||
Assert.Null(errorCode);
|
||||
|
||||
after = EpoxyProtocol.TransitionExpectEpoxyHeaders(
|
||||
|
@ -206,8 +212,9 @@ namespace UnitTest.Epoxy
|
|||
Assert.AreEqual(EpoxyProtocol.ClassifyState.ExpectOptionalLayerData, after);
|
||||
Assert.NotNull(headers);
|
||||
Assert.AreEqual(GoodRequestId, headers.conversation_id);
|
||||
Assert.AreEqual(GoodService, headers.service_name);
|
||||
Assert.AreEqual(GoodMethod, headers.method_name);
|
||||
Assert.AreEqual(EpoxyMessageType.Request, headers.message_type);
|
||||
Assert.AreEqual(EpoxyMessageType.REQUEST, headers.message_type);
|
||||
Assert.Null(errorCode);
|
||||
}
|
||||
|
||||
|
@ -549,6 +556,7 @@ namespace UnitTest.Epoxy
|
|||
{
|
||||
Assert.AreEqual(expected.conversation_id, actual.conversation_id);
|
||||
Assert.AreEqual(expected.message_type, actual.message_type);
|
||||
Assert.AreEqual(expected.service_name, actual.service_name);
|
||||
Assert.AreEqual(expected.method_name, actual.method_name);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace UnitTest.Epoxy
|
|||
{
|
||||
var error = new Error
|
||||
{
|
||||
error_code = (int) ErrorCode.InternalServerError,
|
||||
error_code = (int) ErrorCode.INTERNAL_SERVER_ERROR,
|
||||
};
|
||||
|
||||
return Task.FromResult<IMessage>(Message.FromError(error));
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace UnitTest.Epoxy
|
|||
public void Parse_InvalidUris()
|
||||
{
|
||||
Assert.Null(EpoxyTransport.Parse(null, LoggerTests.BlackHole));
|
||||
Assert.Null(EpoxyTransport.Parse("", LoggerTests.BlackHole));
|
||||
Assert.Null(EpoxyTransport.Parse(string.Empty, LoggerTests.BlackHole));
|
||||
Assert.Null(EpoxyTransport.Parse("127.0.0.1", LoggerTests.BlackHole));
|
||||
Assert.Null(EpoxyTransport.Parse("cows", LoggerTests.BlackHole));
|
||||
Assert.Null(EpoxyTransport.Parse(":12", LoggerTests.BlackHole));
|
||||
|
@ -206,7 +206,7 @@ namespace UnitTest.Epoxy
|
|||
{
|
||||
TestClientServer<TestService> testClientServer = await SetupTestClientServer<TestService>();
|
||||
|
||||
var response = await testClientServer.ClientConnection.RequestResponseAsync<Bond.Void, Bond.Void>("TestService.RespondWithEmpty", EmptyMessage, CancellationToken.None);
|
||||
var response = await testClientServer.ClientConnection.RequestResponseAsync<Bond.Void, Bond.Void>("TestService", "RespondWithEmpty", EmptyMessage, CancellationToken.None);
|
||||
|
||||
Assert.IsFalse(response.IsError);
|
||||
Assert.IsNotNull(response.Payload);
|
||||
|
@ -223,13 +223,13 @@ namespace UnitTest.Epoxy
|
|||
{
|
||||
TestClientServer<TestService> testClientServer = await SetupTestClientServer<TestService>();
|
||||
|
||||
var response = await testClientServer.ClientConnection.RequestResponseAsync<Bond.Void, Bond.Void>("TestService.RespondWithError", EmptyMessage, CancellationToken.None);
|
||||
var response = await testClientServer.ClientConnection.RequestResponseAsync<Bond.Void, Bond.Void>("TestService", "RespondWithError", EmptyMessage, CancellationToken.None);
|
||||
|
||||
Assert.IsTrue(response.IsError);
|
||||
Assert.IsNotNull(response.Error);
|
||||
|
||||
var error = response.Error.Deserialize<Error>();
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
|
||||
await testClientServer.ServiceTransport.StopAsync();
|
||||
await testClientServer.ClientTransport.StopAsync();
|
||||
|
@ -240,13 +240,13 @@ namespace UnitTest.Epoxy
|
|||
{
|
||||
TestClientServer<TestService> testClientServer = await SetupTestClientServer<TestService>();
|
||||
|
||||
var response = await testClientServer.ClientConnection.RequestResponseAsync<Bond.Void, Bond.Void>("TestService.ThrowInsteadOfResponding", EmptyMessage, CancellationToken.None);
|
||||
var response = await testClientServer.ClientConnection.RequestResponseAsync<Bond.Void, Bond.Void>("TestService", "ThrowInsteadOfResponding", EmptyMessage, CancellationToken.None);
|
||||
|
||||
Assert.IsTrue(response.IsError);
|
||||
Assert.IsNotNull(response.Error);
|
||||
|
||||
var error = response.Error.Deserialize<Error>();
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.That(error.message, Is.StringContaining(Errors.InternalErrorMessage));
|
||||
|
||||
await testClientServer.ServiceTransport.StopAsync();
|
||||
|
@ -329,7 +329,7 @@ namespace UnitTest.Epoxy
|
|||
var proxy = new DummyTestProxy<EpoxyConnection>(testClientServer.ClientConnection);
|
||||
var request = new Dummy { int_value = 100 };
|
||||
|
||||
errorLayer.SetState(MessageType.Request, errorOnSend: true, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.REQUEST, errorOnSend: true, errorOnReceive: false);
|
||||
IMessage<Dummy> response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
Assert.AreEqual(TestLayer_ReturnErrors.SendError, response.Error.Deserialize().error_code);
|
||||
|
@ -337,7 +337,7 @@ namespace UnitTest.Epoxy
|
|||
Assert.AreEqual(0, testClientServer.Service.RequestCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testClientServer.Service.LastRequestReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Response, errorOnSend: false, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.RESPONSE, errorOnSend: false, errorOnReceive: true);
|
||||
response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
Assert.AreEqual(TestLayer_ReturnErrors.ReceiveError, response.Error.Deserialize().error_code);
|
||||
|
@ -388,7 +388,7 @@ namespace UnitTest.Epoxy
|
|||
var proxy = new DummyTestProxy<EpoxyConnection>(testClientServer.ClientConnection);
|
||||
var request = new Dummy { int_value = 100 };
|
||||
|
||||
errorLayer.SetState(MessageType.Request, errorOnSend: false, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.REQUEST, errorOnSend: false, errorOnReceive: true);
|
||||
|
||||
IMessage<Dummy> response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
|
@ -398,7 +398,7 @@ namespace UnitTest.Epoxy
|
|||
Assert.AreEqual(0, testClientServer.Service.RequestCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testClientServer.Service.LastRequestReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Response, errorOnSend: true, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.RESPONSE, errorOnSend: true, errorOnReceive: false);
|
||||
response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
error = response.Error.Deserialize();
|
||||
|
@ -420,7 +420,7 @@ namespace UnitTest.Epoxy
|
|||
var proxy = new DummyTestProxy<EpoxyConnection>(testClientServer.ClientConnection);
|
||||
var theEvent = new Dummy { int_value = 100 };
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: true, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: true, errorOnReceive: false);
|
||||
|
||||
ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();
|
||||
proxy.EventMethodAsync(theEvent);
|
||||
|
@ -431,7 +431,7 @@ namespace UnitTest.Epoxy
|
|||
Assert.AreEqual(0, testClientServer.Service.EventCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testClientServer.Service.LastEventReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: false, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: true);
|
||||
|
||||
theEvent.int_value = 101;
|
||||
|
||||
|
@ -456,7 +456,7 @@ namespace UnitTest.Epoxy
|
|||
var proxy = new DummyTestProxy<EpoxyConnection>(testClientServer.ClientConnection);
|
||||
var theEvent = new Dummy { int_value = 100 };
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: false, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: true);
|
||||
|
||||
ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();
|
||||
proxy.EventMethodAsync(theEvent);
|
||||
|
@ -467,7 +467,7 @@ namespace UnitTest.Epoxy
|
|||
Assert.AreEqual(0, testClientServer.Service.EventCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testClientServer.Service.LastEventReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: true, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: true, errorOnReceive: false);
|
||||
theEvent.int_value = 101;
|
||||
|
||||
waitForEvent = testClientServer.Service.CreateResetEvent();
|
||||
|
@ -544,7 +544,7 @@ namespace UnitTest.Epoxy
|
|||
IMessage<Dummy> response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
Error error = response.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.AreEqual(TestLayerStackProvider_Fails.InternalDetails, error.message);
|
||||
|
||||
await testClientServer.ServiceTransport.StopAsync();
|
||||
|
@ -566,7 +566,7 @@ namespace UnitTest.Epoxy
|
|||
IMessage<Dummy> response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
Error error = response.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.AreEqual(Errors.InternalErrorMessage, error.message);
|
||||
|
||||
await testClientServer.ServiceTransport.StopAsync();
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace UnitTest.Epoxy
|
|||
IMessage response = await responseTask;
|
||||
Assert.IsTrue(response.IsError);
|
||||
Error err = response.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.ConnectionShutDown, err.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.CONNECTION_SHUT_DOWN, err.error_code);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -84,7 +84,7 @@ namespace UnitTest.Epoxy
|
|||
var response = await responseTask;
|
||||
Assert.IsTrue(response.IsError);
|
||||
Error err = response.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.ConnectionShutDown, err.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.CONNECTION_SHUT_DOWN, err.error_code);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace UnitTest.Interfaces
|
|||
|
||||
InternalServerError error = Errors.MakeInternalServerError(ex, "some ID", includeDetails: false);
|
||||
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.IsNotEmpty(error.unique_id);
|
||||
Assert.That(error.message, Is.Not.StringContaining(ex.Message));
|
||||
Assert.IsEmpty(error.server_stack_trace);
|
||||
|
@ -28,7 +28,7 @@ namespace UnitTest.Interfaces
|
|||
public void MakeInternalServerError_NullExIncludeDetails_GenericErrorReturned()
|
||||
{
|
||||
InternalServerError error = Errors.MakeInternalServerError(exception: null, uniqueId: "some ID", includeDetails: true);
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.IsNotEmpty(error.unique_id);
|
||||
Assert.IsNotEmpty(error.message);
|
||||
Assert.IsEmpty(error.server_stack_trace);
|
||||
|
@ -48,7 +48,7 @@ namespace UnitTest.Interfaces
|
|||
InternalServerError cleansedInternalError = cleansedError as InternalServerError;
|
||||
Assert.NotNull(cleansedInternalError);
|
||||
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, cleansedInternalError.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, cleansedInternalError.error_code);
|
||||
Assert.AreEqual(Errors.InternalErrorMessage, cleansedInternalError.message);
|
||||
Assert.IsNull(cleansedInternalError.inner_error);
|
||||
Assert.AreEqual(savedID, cleansedInternalError.unique_id);
|
||||
|
@ -58,11 +58,11 @@ namespace UnitTest.Interfaces
|
|||
[Test]
|
||||
public void CleanseInternalServerError_WithOtherError()
|
||||
{
|
||||
Error error = new Error { error_code = (int)ErrorCode.TransportError, message = "message" };
|
||||
Error error = new Error { error_code = (int)ErrorCode.TRANSPORT_ERROR, message = "message" };
|
||||
|
||||
Error cleansedError = Errors.CleanseInternalServerError(error);
|
||||
Assert.NotNull(cleansedError);
|
||||
Assert.AreEqual((int)ErrorCode.TransportError, cleansedError.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.TRANSPORT_ERROR, cleansedError.error_code);
|
||||
Assert.AreEqual("message", cleansedError.message);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace UnitTest.Interfaces
|
|||
var ex = GenerateException(new Exception("this is some message", GenerateException<InvalidOperationException>()));
|
||||
InternalServerError error = Errors.MakeInternalServerError(ex, "some ID", includeDetails: true);
|
||||
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.IsNotEmpty(error.unique_id);
|
||||
Assert.That(error.message, Is.StringContaining(ex.Message));
|
||||
Assert.IsNotEmpty(error.server_stack_trace);
|
||||
|
@ -86,14 +86,14 @@ namespace UnitTest.Interfaces
|
|||
var aggEx = GenerateException(new AggregateException("this is some message", innerExceptions));
|
||||
InternalServerError error = Errors.MakeInternalServerError(aggEx, "some ID", includeDetails: true);
|
||||
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.IsNotEmpty(error.unique_id);
|
||||
Assert.That(error.message, Is.StringContaining(aggEx.Message));
|
||||
Assert.IsNotEmpty(error.server_stack_trace);
|
||||
Assert.IsNotNull(error.inner_error);
|
||||
|
||||
var aggError = error.inner_error.Deserialize<AggregateError>();
|
||||
Assert.AreEqual((int)ErrorCode.MultipleErrorsOccured, aggError.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.MULTIPLE_ERRORS_OCCURRED, aggError.error_code);
|
||||
Assert.That(aggError.message, Is.StringMatching("One or more errors occured"));
|
||||
Assert.AreEqual(2, aggError.inner_errors.Count);
|
||||
}
|
||||
|
|
|
@ -61,18 +61,18 @@ namespace UnitTest.Interfaces
|
|||
var connectionMetrics = Metrics.StartConnectionMetrics();
|
||||
|
||||
AssertValidId(connectionMetrics.connection_id);
|
||||
Assert.AreEqual("", connectionMetrics.local_endpoint);
|
||||
Assert.AreEqual("", connectionMetrics.remote_endpoint);
|
||||
Assert.IsEmpty(connectionMetrics.local_endpoint);
|
||||
Assert.IsEmpty(connectionMetrics.remote_endpoint);
|
||||
Assert.AreEqual(0.0, connectionMetrics.duration_millis);
|
||||
Assert.AreEqual(ConnectionShutdownReason.Unknown, connectionMetrics.shutdown_reason);
|
||||
Assert.AreEqual(ConnectionShutdownReason.UNKNOWN, connectionMetrics.shutdown_reason);
|
||||
|
||||
Metrics.FinishConnectionMetrics(connectionMetrics, stopwatch);
|
||||
|
||||
AssertValidId(connectionMetrics.connection_id);
|
||||
Assert.AreEqual("", connectionMetrics.local_endpoint);
|
||||
Assert.AreEqual("", connectionMetrics.remote_endpoint);
|
||||
Assert.IsEmpty(connectionMetrics.local_endpoint);
|
||||
Assert.IsEmpty(connectionMetrics.remote_endpoint);
|
||||
Assert.Greater(connectionMetrics.duration_millis, 0.0);
|
||||
Assert.AreEqual(ConnectionShutdownReason.Unknown, connectionMetrics.shutdown_reason);
|
||||
Assert.AreEqual(ConnectionShutdownReason.UNKNOWN, connectionMetrics.shutdown_reason);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -84,9 +84,10 @@ namespace UnitTest.Interfaces
|
|||
|
||||
AssertValidId(requestMetrics.request_id);
|
||||
Assert.AreEqual(connectionMetrics.connection_id, requestMetrics.connection_id);
|
||||
Assert.AreEqual("", requestMetrics.local_endpoint);
|
||||
Assert.AreEqual("", requestMetrics.remote_endpoint);
|
||||
Assert.AreEqual("", requestMetrics.method_name);
|
||||
Assert.IsEmpty(requestMetrics.local_endpoint);
|
||||
Assert.IsEmpty(requestMetrics.remote_endpoint);
|
||||
Assert.IsEmpty(requestMetrics.service_name);
|
||||
Assert.IsEmpty(requestMetrics.method_name);
|
||||
Assert.AreEqual(0.0, requestMetrics.service_method_time_millis);
|
||||
Assert.AreEqual(0.0, requestMetrics.total_time_millis);
|
||||
Assert.Null(requestMetrics.error);
|
||||
|
@ -95,9 +96,10 @@ namespace UnitTest.Interfaces
|
|||
|
||||
AssertValidId(requestMetrics.request_id);
|
||||
Assert.AreEqual(connectionMetrics.connection_id, requestMetrics.connection_id);
|
||||
Assert.AreEqual("", requestMetrics.local_endpoint);
|
||||
Assert.AreEqual("", requestMetrics.remote_endpoint);
|
||||
Assert.AreEqual("", requestMetrics.method_name);
|
||||
Assert.IsEmpty(requestMetrics.local_endpoint);
|
||||
Assert.IsEmpty(requestMetrics.remote_endpoint);
|
||||
Assert.IsEmpty(requestMetrics.service_name);
|
||||
Assert.IsEmpty(requestMetrics.method_name);
|
||||
Assert.AreEqual(0.0, requestMetrics.service_method_time_millis);
|
||||
Assert.Greater(requestMetrics.total_time_millis, 0.0);
|
||||
Assert.Null(requestMetrics.error);
|
||||
|
@ -106,13 +108,13 @@ namespace UnitTest.Interfaces
|
|||
[Test]
|
||||
public async Task Server_Request_MetricsAreEmitted()
|
||||
{
|
||||
await Server_MetricsAreEmitted(MessageType.Request);
|
||||
await Server_MetricsAreEmitted(MessageType.REQUEST);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Server_Event_MetricsAreEmitted()
|
||||
{
|
||||
await Server_MetricsAreEmitted(MessageType.Event);
|
||||
await Server_MetricsAreEmitted(MessageType.EVENT);
|
||||
}
|
||||
|
||||
private async Task Server_MetricsAreEmitted(MessageType messageType)
|
||||
|
@ -120,16 +122,17 @@ namespace UnitTest.Interfaces
|
|||
// There are several invariants around metrics that involve cross-request and cross-connection state.
|
||||
// Bring up a service, connect to it several times, and make several requests each time.
|
||||
|
||||
const string expectedServiceName = "unittest.comm.DummyTest";
|
||||
string expectedMethodName;
|
||||
Action<DummyTestProxy<EpoxyConnection>> doRpc;
|
||||
switch (messageType)
|
||||
{
|
||||
case MessageType.Request:
|
||||
expectedMethodName = "unittest.comm.DummyTest.ReqRspMethod";
|
||||
case MessageType.REQUEST:
|
||||
expectedMethodName = "ReqRspMethod";
|
||||
doRpc = async proxy => await proxy.ReqRspMethodAsync(new Dummy());
|
||||
break;
|
||||
case MessageType.Event:
|
||||
expectedMethodName = "unittest.comm.DummyTest.EventMethod";
|
||||
case MessageType.EVENT:
|
||||
expectedMethodName = "EventMethod";
|
||||
doRpc = proxy => proxy.EventMethodAsync(new Dummy());
|
||||
break;
|
||||
default:
|
||||
|
@ -185,6 +188,7 @@ namespace UnitTest.Interfaces
|
|||
|
||||
Assert.AreEqual(serverEndpoint, requestMetrics.local_endpoint);
|
||||
Assert.AreEqual(clientEndpoint, requestMetrics.remote_endpoint);
|
||||
Assert.AreEqual(expectedServiceName, requestMetrics.service_name);
|
||||
Assert.AreEqual(expectedMethodName, requestMetrics.method_name);
|
||||
Assert.Null(requestMetrics.error);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace UnitTest.Layers
|
|||
Assert.IsNull(error);
|
||||
|
||||
IBonded layerData;
|
||||
error = stack.OnSend(MessageType.Request, sendContext, out layerData);
|
||||
error = stack.OnSend(MessageType.REQUEST, sendContext, out layerData);
|
||||
|
||||
Assert.IsNull(error);
|
||||
Assert.IsNotNull(layerData);
|
||||
|
@ -69,7 +69,7 @@ namespace UnitTest.Layers
|
|||
Error error = stackProvider.GetLayerStack(null, out stack);
|
||||
Assert.IsNull(error);
|
||||
|
||||
error = stack.OnReceive(MessageType.Request, receiveContext, CreateBondedTestData(initialReceiveValue));
|
||||
error = stack.OnReceive(MessageType.REQUEST, receiveContext, CreateBondedTestData(initialReceiveValue));
|
||||
|
||||
Assert.IsNull(error);
|
||||
Assert.AreEqual(2, testList.Count);
|
||||
|
@ -83,9 +83,9 @@ namespace UnitTest.Layers
|
|||
var stack = new LayerStack<Dummy>(LoggerTests.BlackHole, new TestLayer_AlwaysThrows());
|
||||
|
||||
IBonded layerData;
|
||||
Error error = stack.OnSend(MessageType.Request, sendContext, out layerData);
|
||||
Error error = stack.OnSend(MessageType.REQUEST, sendContext, out layerData);
|
||||
Assert.IsNotNull(error);
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -93,9 +93,9 @@ namespace UnitTest.Layers
|
|||
{
|
||||
var stack = new LayerStack<Dummy>(LoggerTests.BlackHole, new TestLayer_AlwaysThrows());
|
||||
|
||||
Error error = stack.OnReceive(MessageType.Request, receiveContext, CreateBondedTestData(initialReceiveValue));
|
||||
Error error = stack.OnReceive(MessageType.REQUEST, receiveContext, CreateBondedTestData(initialReceiveValue));
|
||||
Assert.IsNotNull(error);
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
}
|
||||
|
||||
public void LayerStackProvider_BadCtorArguments_Throw()
|
||||
|
|
|
@ -88,9 +88,9 @@ namespace UnitTest.SimpleInMem
|
|||
Assert.IsTrue(subResponse.IsError);
|
||||
Error addError = addResponse.Error.Deserialize();
|
||||
Error subError = subResponse.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.MethodNotFound, (int)addError.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.METHOD_NOT_FOUND, (int)addError.error_code);
|
||||
Assert.AreEqual("Got request for unknown method [unittest.simpleinmem.Calculator.Add].", addError.message);
|
||||
Assert.AreEqual((int)ErrorCode.MethodNotFound, (int)subError.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.METHOD_NOT_FOUND, (int)subError.error_code);
|
||||
Assert.AreEqual("Got request for unknown method [unittest.simpleinmem.Calculator.Subtract].", subError.message);
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ namespace UnitTest.SimpleInMem
|
|||
IMessage<Output> multiplyResponse = await calculatorProxy.MultiplyAsync(request, System.Threading.CancellationToken.None);
|
||||
Assert.IsTrue(multiplyResponse.IsError);
|
||||
InternalServerError error = multiplyResponse.Error.Deserialize<InternalServerError>();
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.That(error.message, Is.StringContaining(Errors.InternalErrorMessage));
|
||||
}
|
||||
|
||||
|
@ -325,6 +325,7 @@ namespace UnitTest.SimpleInMem
|
|||
|
||||
const int first = 91;
|
||||
const int second = 23;
|
||||
const string serviceName = "Calculator";
|
||||
const string methodName = "Divide";
|
||||
|
||||
var input = new PairedInput
|
||||
|
@ -333,11 +334,11 @@ namespace UnitTest.SimpleInMem
|
|||
Second = second
|
||||
};
|
||||
var request = new Message<PairedInput>(input);
|
||||
IMessage<Output> divideResponse = await connections[0].RequestResponseAsync<PairedInput, Output>(methodName, request, new System.Threading.CancellationToken());
|
||||
IMessage<Output> divideResponse = await connections[0].RequestResponseAsync<PairedInput, Output>(serviceName, methodName, request, new System.Threading.CancellationToken());
|
||||
Assert.IsTrue(divideResponse.IsError);
|
||||
Error error = divideResponse.Error.Deserialize<Error>();
|
||||
Assert.AreEqual((int)ErrorCode.MethodNotFound, error.error_code);
|
||||
Assert.That(error.message, Is.StringContaining($"Got request for unknown method [{methodName}]."));
|
||||
Assert.AreEqual((int)ErrorCode.METHOD_NOT_FOUND, error.error_code);
|
||||
Assert.That(error.message, Is.StringContaining($"Got request for unknown method [{serviceName}.{methodName}]."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -417,7 +418,7 @@ namespace UnitTest.SimpleInMem
|
|||
var proxy = new DummyTestProxy<SimpleInMemConnection>(connections[0]);
|
||||
var request = new Dummy { int_value = 100 };
|
||||
|
||||
errorLayer.SetState(MessageType.Request, errorOnSend: false, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.REQUEST, errorOnSend: false, errorOnReceive: true);
|
||||
IMessage<Dummy> response = await proxy.ReqRspMethodAsync(request);
|
||||
|
||||
Assert.IsTrue(response.IsError);
|
||||
|
@ -427,7 +428,7 @@ namespace UnitTest.SimpleInMem
|
|||
Assert.AreEqual(0, testService.RequestCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testService.LastRequestReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Request, errorOnSend: true, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.REQUEST, errorOnSend: true, errorOnReceive: false);
|
||||
request.int_value = 101;
|
||||
response = await proxy.ReqRspMethodAsync(request);
|
||||
|
||||
|
@ -438,7 +439,7 @@ namespace UnitTest.SimpleInMem
|
|||
Assert.AreEqual(0, testService.RequestCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testService.LastRequestReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Response, errorOnSend: true, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.RESPONSE, errorOnSend: true, errorOnReceive: false);
|
||||
request.int_value = 102;
|
||||
response = await proxy.ReqRspMethodAsync(request);
|
||||
|
||||
|
@ -449,7 +450,7 @@ namespace UnitTest.SimpleInMem
|
|||
Assert.AreEqual(1, testService.RequestCount);
|
||||
Assert.AreEqual(request.int_value, testService.LastRequestReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Response, errorOnSend: false, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.RESPONSE, errorOnSend: false, errorOnReceive: true);
|
||||
request.int_value = 103;
|
||||
response = await proxy.ReqRspMethodAsync(request);
|
||||
|
||||
|
@ -460,7 +461,7 @@ namespace UnitTest.SimpleInMem
|
|||
Assert.AreEqual(2, testService.RequestCount);
|
||||
Assert.AreEqual(request.int_value, testService.LastRequestReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: true, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: true, errorOnReceive: true);
|
||||
request.int_value = 104;
|
||||
response = await proxy.ReqRspMethodAsync(request);
|
||||
|
||||
|
@ -489,7 +490,7 @@ namespace UnitTest.SimpleInMem
|
|||
response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
Error error = response.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.AreEqual(TestLayerStackProvider_Fails.InternalDetails, error.message);
|
||||
}
|
||||
|
||||
|
@ -511,7 +512,7 @@ namespace UnitTest.SimpleInMem
|
|||
response = await proxy.ReqRspMethodAsync(request);
|
||||
Assert.IsTrue(response.IsError);
|
||||
Error error = response.Error.Deserialize();
|
||||
Assert.AreEqual((int)ErrorCode.InternalServerError, error.error_code);
|
||||
Assert.AreEqual((int)ErrorCode.INTERNAL_SERVER_ERROR, error.error_code);
|
||||
Assert.AreEqual(Errors.InternalErrorMessage, error.message);
|
||||
}
|
||||
|
||||
|
@ -554,7 +555,7 @@ namespace UnitTest.SimpleInMem
|
|||
var proxy = new DummyTestProxy<SimpleInMemConnection>(connections[0]);
|
||||
var theEvent = new Dummy { int_value = 100 };
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: false, errorOnReceive: true);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: true);
|
||||
|
||||
ManualResetEventSlim waitForEvent = testService.CreateResetEvent();
|
||||
proxy.EventMethodAsync(theEvent);
|
||||
|
@ -565,7 +566,7 @@ namespace UnitTest.SimpleInMem
|
|||
Assert.AreEqual(0, testService.EventCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testService.LastEventReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: true, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: true, errorOnReceive: false);
|
||||
theEvent.int_value = 101;
|
||||
|
||||
waitForEvent = testService.CreateResetEvent();
|
||||
|
@ -577,7 +578,7 @@ namespace UnitTest.SimpleInMem
|
|||
Assert.AreEqual(0, testService.EventCount);
|
||||
Assert.AreEqual(Dummy.Empty.int_value, testService.LastEventReceived.int_value);
|
||||
|
||||
errorLayer.SetState(MessageType.Event, errorOnSend: false, errorOnReceive: false);
|
||||
errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: false);
|
||||
theEvent.int_value = 102;
|
||||
|
||||
waitForEvent = testService.CreateResetEvent();
|
||||
|
|
|
@ -214,7 +214,7 @@ World", target._str);
|
|||
|
||||
var target = ParseJson<BasicTypes>(json);
|
||||
|
||||
Assert.AreEqual(string.Empty, target._str);
|
||||
Assert.IsEmpty(target._str);
|
||||
Assert.IsTrue(target._bool);
|
||||
Assert.AreEqual(13.2, target._double);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ World</_str>
|
|||
|
||||
var target = ParseXml<BasicTypes>(xml);
|
||||
|
||||
Assert.AreEqual(string.Empty, target._str);
|
||||
Assert.IsEmpty(target._str);
|
||||
Assert.IsTrue(target._bool);
|
||||
Assert.AreEqual(13.2, target._double);
|
||||
}
|
||||
|
|
|
@ -284,16 +284,17 @@ various messaging patterns.
|
|||
|
||||
enum EpoxyMessageType
|
||||
{
|
||||
Request = 1;
|
||||
Response = 2;
|
||||
Event = 3;
|
||||
REQUEST = 1;
|
||||
RESPONSE = 2;
|
||||
EVENT = 3;
|
||||
}
|
||||
|
||||
struct EpoxyHeaders
|
||||
{
|
||||
0: uint64 conversation_id;
|
||||
1: required EpoxyMessageType message_type;
|
||||
2: string method_name;
|
||||
2: string service_name;
|
||||
3: string method_name;
|
||||
}
|
||||
|
||||
### Conversation ID ###
|
||||
|
@ -346,17 +347,26 @@ connection for over 580 years before exhausting its conversation IDs. In
|
|||
practice, the `CONVERSATION_IDS_EXHAUSTED` error should never be
|
||||
encountered.
|
||||
|
||||
### Service name ###
|
||||
|
||||
The `service_name` field is the name of the service that is being invoked.
|
||||
|
||||
The `service_name` field must be set to a UTF-8 encoded string (without a
|
||||
BOM) that is the fully-qualified service name. Namespace elements are
|
||||
separated by the period character ('.', ASCII 0x2E). May be the empty string
|
||||
if the message type does not require a service name.
|
||||
|
||||
Example: `root_namespace.child_namespace.some_service`
|
||||
|
||||
### Method name ###
|
||||
|
||||
The `method_name` field is the name of the service and it's method being
|
||||
invoked.
|
||||
The `method_name` field is the name of the method on the service that is
|
||||
being invoked.
|
||||
|
||||
The `method_name` field must be set to a UTF-8 encoded string (without a
|
||||
BOM) that is the concatenation of the fully-qualified service name with the
|
||||
method name. Namespace elements are separated by the period character ('.',
|
||||
ASCII 0x2E), as is the service name from the method name.
|
||||
It is also a UTF-8 encoded string (without a BOM). May be the
|
||||
empty string if the message type does not require a method name.
|
||||
|
||||
Example: `root_namespace.child_namespace.some_service.some_method`
|
||||
Example: `SomeMethod`
|
||||
|
||||
### Message type ###
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Bond.Examples.Metrics
|
|||
sb.Append($"\trequest ID: {metrics.request_id}\n");
|
||||
sb.Append($"\tconnection ID: {metrics.connection_id}\n");
|
||||
sb.Append($"\tendpoints: {metrics.local_endpoint} <-> {metrics.remote_endpoint}\n");
|
||||
sb.Append($"\tservice: {metrics.service_name}\n");
|
||||
sb.Append($"\tmethod: {metrics.method_name}\n");
|
||||
sb.Append($"\ttotal millis: {metrics.total_time_millis}\n");
|
||||
sb.Append($"\tservice millis: {metrics.service_method_time_millis}\n");
|
||||
|
|
|
@ -5,30 +5,30 @@ namespace bond.comm;
|
|||
|
||||
enum MessageType
|
||||
{
|
||||
Request = 0;
|
||||
Response = 1;
|
||||
Event = 2;
|
||||
REQUEST = 0;
|
||||
RESPONSE = 1;
|
||||
EVENT = 2;
|
||||
}
|
||||
|
||||
enum ErrorCode
|
||||
{
|
||||
InternalServerError = 0xA0BD0000; // Error is an InternalServerError
|
||||
MethodNotFound = 0xA0BD0001;
|
||||
InvalidInvocation = 0xA0BD0002;
|
||||
TransportError = 0xA0BD0003;
|
||||
ConnectionShutDown = 0xA0BD0004;
|
||||
MultipleErrorsOccured = 0xA0BD0005; // Error is an AggregateError
|
||||
INTERNAL_SERVER_ERROR = 0xA0BD0000; // Error is an InternalServerError
|
||||
METHOD_NOT_FOUND = 0xA0BD0001;
|
||||
INVALID_INVOCATION = 0xA0BD0002;
|
||||
TRANSPORT_ERROR = 0xA0BD0003;
|
||||
CONNECTION_SHUT_DOWN = 0xA0BD0004;
|
||||
MULTIPLE_ERRORS_OCCURRED = 0xA0BD0005; // Error is an AggregateError
|
||||
}
|
||||
|
||||
enum ConnectionShutdownReason
|
||||
{
|
||||
Unknown = 0x0;
|
||||
ClientGraceful = 0x1;
|
||||
ServerGraceful = 0x2;
|
||||
ClientProtocolError = 0x3;
|
||||
BondInternalError = 0x4;
|
||||
ServiceInternalError = 0x5;
|
||||
NetworkError = 0x6;
|
||||
UNKNOWN= 0x0;
|
||||
CLIENT_GRACEFUL = 0x1;
|
||||
SERVER_GRACEFUL = 0x2;
|
||||
CLIENT_PROTOCOL_ERROR = 0x3;
|
||||
BOND_INTERNAL_ERROR = 0x4;
|
||||
SERVICE_INTERNAL_ERROR = 0x5;
|
||||
NETWORK_ERROR = 0x6;
|
||||
}
|
||||
|
||||
struct Error
|
||||
|
@ -54,7 +54,7 @@ struct ConnectionMetrics
|
|||
0: string connection_id;
|
||||
1: string local_endpoint;
|
||||
2: string remote_endpoint;
|
||||
3: ConnectionShutdownReason shutdown_reason = Unknown;
|
||||
3: ConnectionShutdownReason shutdown_reason = UNKNOWN;
|
||||
4: double duration_millis;
|
||||
}
|
||||
|
||||
|
@ -62,10 +62,11 @@ struct RequestMetrics
|
|||
{
|
||||
0: string request_id;
|
||||
1: string connection_id;
|
||||
2: string method_name;
|
||||
3: string local_endpoint;
|
||||
4: string remote_endpoint;
|
||||
5: nullable<InternalServerError> error;
|
||||
6: double total_time_millis;
|
||||
7: double service_method_time_millis;
|
||||
2: string service_name;
|
||||
3: string method_name;
|
||||
4: string local_endpoint;
|
||||
5: string remote_endpoint;
|
||||
6: nullable<InternalServerError> error;
|
||||
7: double total_time_millis;
|
||||
8: double service_method_time_millis;
|
||||
}
|
||||
|
|
|
@ -11,16 +11,17 @@ struct EpoxyConfig
|
|||
|
||||
enum EpoxyMessageType
|
||||
{
|
||||
Request = 1;
|
||||
Response = 2;
|
||||
Event = 3;
|
||||
REQUEST = 1;
|
||||
RESPONSE = 2;
|
||||
EVENT = 3;
|
||||
}
|
||||
|
||||
struct EpoxyHeaders
|
||||
{
|
||||
0: uint64 conversation_id;
|
||||
1: required EpoxyMessageType message_type = Request;
|
||||
2: string method_name;
|
||||
1: required EpoxyMessageType message_type = REQUEST;
|
||||
2: string service_name;
|
||||
3: string method_name;
|
||||
}
|
||||
|
||||
enum ProtocolErrorCode
|
||||
|
|
Загрузка…
Ссылка в новой задаче