Permalink
Browse files

Changes necessary to work from generated code from a .proto file for TCP

Client Messages. Reorganized so that all messages intended to be
serialized over protobuf reside under the TcpClientMessageDto and DTOs for
HTTP live in HttpClientMessageDto, hence the large number of affected
files.

Includes custom XSLT for ProtoGen C# which generates message constructors
and deals with nullable value types.

Changes timestamp serialization "on-the-wire" over TCP to be number of
milliseconds from UNIX Epoch.
  • Loading branch information...
1 parent 90e9573 commit 4b568dc82ce05c20fd70fd8ccbe48a29f9574b95 James Nugent committed Nov 6, 2012
Showing with 1,476 additions and 2,150 deletions.
  1. +1 −1 src/EventStore/EventStore.ClientAPI/AllEventsSlice.cs
  2. +5 −5 src/EventStore/EventStore.ClientAPI/ClientOperations/AppendToStreamOperation.cs
  3. +4 −4 src/EventStore/EventStore.ClientAPI/ClientOperations/CommitTransactionOperation.cs
  4. +4 −4 src/EventStore/EventStore.ClientAPI/ClientOperations/CreateStreamOperation.cs
  5. +4 −4 src/EventStore/EventStore.ClientAPI/ClientOperations/DeleteStreamOperation.cs
  6. +3 −3 src/EventStore/EventStore.ClientAPI/ClientOperations/ReadAllEventsBackwardOperation.cs
  7. +3 −3 src/EventStore/EventStore.ClientAPI/ClientOperations/ReadAllEventsForwardOperation.cs
  8. +3 −3 src/EventStore/EventStore.ClientAPI/ClientOperations/ReadStreamEventsBackwardOperation.cs
  9. +7 −4 src/EventStore/EventStore.ClientAPI/ClientOperations/ReadStreamEventsForwardOperation.cs
  10. +4 −4 src/EventStore/EventStore.ClientAPI/ClientOperations/StartTransactionOperation.cs
  11. +5 −5 src/EventStore/EventStore.ClientAPI/ClientOperations/TransactionalWriteOperation.cs
  12. +5 −5 src/EventStore/EventStore.ClientAPI/Connection/SubscriptionsChannel.cs
  13. +1 −4 src/EventStore/EventStore.ClientAPI/EventStore.ClientAPI.csproj
  14. +1 −1 src/EventStore/EventStore.ClientAPI/EventStoreConnection.cs
  15. +1 −1 src/EventStore/EventStore.ClientAPI/EventStreamSlice.cs
  16. +0 −33 src/EventStore/EventStore.ClientAPI/Messages/ClientEvent.cs
  17. +93 −31 src/EventStore/EventStore.ClientAPI/Messages/{ClientMessages.cs → ClientMessage.cs}
  18. +29 −2 src/EventStore/EventStore.ClientAPI/Messages/ClientMessagesExtensions.cs
  19. +0 −26 src/EventStore/EventStore.ClientAPI/Messages/EventLinkPair.cs
  20. +0 −76 src/EventStore/EventStore.ClientAPI/Messages/EventRecord.cs
  21. +2 −2 src/EventStore/EventStore.ClientAPI/RecordedEvent.cs
  22. +4 −2 src/EventStore/EventStore.Core/EventStore.Core.csproj
  23. +0 −1,118 src/EventStore/EventStore.Core/Messages/ClientMessageDtos.cs
  24. +167 −0 src/EventStore/EventStore.Core/Messages/HttpClientMessageDto.cs
  25. +855 −0 src/EventStore/EventStore.Core/Messages/TcpClientMessageDto.cs
  26. +74 −0 src/EventStore/EventStore.Core/Messages/TcpClientMessageDtoExtensions.cs
  27. +4 −4 src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/AtomControllerDefinitions.cs
  28. +3 −3 src/EventStore/EventStore.Core/Services/Transport/Http/{EventConvertion.cs → EventConversion.cs}
  29. +3 −3 src/EventStore/EventStore.Core/Services/Transport/Http/Format.cs
  30. +60 −57 src/EventStore/EventStore.Core/Services/Transport/Tcp/ClientTcpDispatcher.cs
  31. +4 −3 src/EventStore/EventStore.TestClient/Commands/CreateStreamProcessor.cs
  32. +2 −2 src/EventStore/EventStore.TestClient/Commands/DeleteProcessor.cs
  33. +6 −5 src/EventStore/EventStore.TestClient/Commands/DvuBasic/DvuBasicProcessor.cs
  34. +8 −6 src/EventStore/EventStore.TestClient/Commands/MultiWriteFloodWaiting.cs
  35. +5 −4 src/EventStore/EventStore.TestClient/Commands/MultiWriteProcessor.cs
  36. +7 −7 src/EventStore/EventStore.TestClient/Commands/ReadAllProcessor.cs
  37. +1 −1 src/EventStore/EventStore.TestClient/Commands/ReadFloodProcessor.cs
  38. +2 −2 src/EventStore/EventStore.TestClient/Commands/ReadProcessor.cs
  39. +5 −5 src/EventStore/EventStore.TestClient/Commands/SubscribeToStreamProcessor.cs
  40. +9 −8 src/EventStore/EventStore.TestClient/Commands/TransactionWriteProcessor.cs
  41. +2 −2 src/EventStore/EventStore.TestClient/Commands/WriteFloodHttpProcessor.cs
  42. +10 −8 src/EventStore/EventStore.TestClient/Commands/WriteFloodProcessor.cs
  43. +2 −2 src/EventStore/EventStore.TestClient/Commands/WriteFloodWaitingHttpProcessor.cs
  44. +10 −8 src/EventStore/EventStore.TestClient/Commands/WriteFloodWaitingProcessor.cs
  45. +2 −2 src/EventStore/EventStore.TestClient/Commands/WriteHttpProcessor.cs
  46. +2 −2 src/EventStore/EventStore.TestClient/Commands/WriteLongTermHttpProcessor.cs
  47. +11 −9 src/EventStore/EventStore.TestClient/Commands/WriteLongTermProcessor.cs
  48. +10 −9 src/EventStore/EventStore.TestClient/Commands/WriteProcessor.cs
  49. +1 −0 src/EventStore/EventStore.TestClient/EventStore.TestClient.csproj
  50. +13 −0 src/EventStore/EventStore.TestClient/MessageUtil.cs
  51. +7 −7 src/EventStore/Protos/ClientAPI/ClientMessageDtos.proto
  52. +2 −1 src/EventStore/Scripts/ProtoGen/generate-clientmessages-from-proto.cmd
  53. +0 −645 tools/ProtoGen/Heavily Edited CSharp.xslt
  54. +10 −4 tools/ProtoGen/csharp.xslt
@@ -37,7 +37,7 @@ public class AllEventsSlice
public readonly Position Position;
public readonly RecordedEvent[] Events;
- internal AllEventsSlice(Position position, IEnumerable<ClientMessages.EventLinkPair> events)
+ internal AllEventsSlice(Position position, IEnumerable<ClientMessage.EventLinkPair> events)
{
Position = position;
Events = events == null ? EventStreamSlice.EmptyEvents : events.Select(x => new RecordedEvent(x.Event)).ToArray();
@@ -41,7 +41,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class AppendToStreamOperation : IClientOperation
{
private readonly TaskCompletionSource<object> _source;
- private ClientMessages.WriteEventsCompleted _result;
+ private ClientMessage.WriteEventsCompleted _result;
private int _completed;
private Guid _correlationId;
@@ -87,8 +87,8 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dtos = _events.Select(x => new ClientMessages.ClientEvent(x.EventId.ToByteArray(), x.Type, x.Data, x.Metadata)).ToArray();
- var write = new ClientMessages.WriteEvents(_stream, _expectedVersion, dtos, _forward);
+ var dtos = _events.Select(x => new ClientMessage.ClientEvent(x.EventId.ToByteArray(), x.Type, x.Data, x.Metadata)).ToArray();
+ var write = new ClientMessage.WriteEvents(_stream, _expectedVersion, dtos, _forward);
return new TcpPackage(TcpCommand.WriteEvents, _correlationId, write.Serialize());
}
}
@@ -99,7 +99,7 @@ public InspectionResult InspectPackage(TcpPackage package)
{
if (package.Command == TcpCommand.DeniedToRoute)
{
- var route = package.Data.Deserialize<ClientMessages.DeniedToRoute>();
+ var route = package.Data.Deserialize<ClientMessage.DeniedToRoute>();
return new InspectionResult(InspectionDecision.Reconnect,
data: new EndpointsPair(route.ExternalTcpEndPoint,
route.ExternalHttpEndPoint));
@@ -112,7 +112,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.WriteEventsCompleted>();
+ var dto = data.Deserialize<ClientMessage.WriteEventsCompleted>();
_result = dto;
switch ((OperationErrorCode)dto.ErrorCode)
@@ -39,7 +39,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class CommitTransactionOperation : IClientOperation
{
private readonly TaskCompletionSource<object> _source;
- private ClientMessages.TransactionCommitCompleted _result;
+ private ClientMessage.TransactionCommitCompleted _result;
private int _completed;
private Guid _corrId;
@@ -82,7 +82,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var commit = new ClientMessages.TransactionCommit(_transactionId, _stream, _forward);
+ var commit = new ClientMessage.TransactionCommit(_transactionId, _stream, _forward);
return new TcpPackage(TcpCommand.TransactionCommit, _corrId, commit.Serialize());
}
}
@@ -93,7 +93,7 @@ public InspectionResult InspectPackage(TcpPackage package)
{
if (package.Command == TcpCommand.DeniedToRoute)
{
- var route = package.Data.Deserialize<ClientMessages.DeniedToRoute>();
+ var route = package.Data.Deserialize<ClientMessage.DeniedToRoute>();
return new InspectionResult(InspectionDecision.Reconnect,
data: new EndpointsPair(route.ExternalTcpEndPoint,
route.ExternalHttpEndPoint));
@@ -106,7 +106,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.TransactionCommitCompleted>();
+ var dto = data.Deserialize<ClientMessage.TransactionCommitCompleted>();
_result = dto;
switch ((OperationErrorCode)dto.ErrorCode)
@@ -39,7 +39,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class CreateStreamOperation : IClientOperation
{
private readonly TaskCompletionSource<object> _source;
- private ClientMessages.CreateStreamCompleted _result;
+ private ClientMessage.CreateStreamCompleted _result;
private int _completed;
private Guid _correlationId;
@@ -82,7 +82,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dto = new ClientMessages.CreateStream(_stream, _metadata, _forward);
+ var dto = new ClientMessage.CreateStream(_stream, _metadata, _forward);
return new TcpPackage(TcpCommand.CreateStream, _correlationId, dto.Serialize());
}
}
@@ -93,7 +93,7 @@ public InspectionResult InspectPackage(TcpPackage package)
{
if (package.Command == TcpCommand.DeniedToRoute)
{
- var route = package.Data.Deserialize<ClientMessages.DeniedToRoute>();
+ var route = package.Data.Deserialize<ClientMessage.DeniedToRoute>();
return new InspectionResult(InspectionDecision.Reconnect,
data: new EndpointsPair(route.ExternalTcpEndPoint,
route.ExternalHttpEndPoint));
@@ -104,7 +104,7 @@ public InspectionResult InspectPackage(TcpPackage package)
package.Command.ToString()));
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.CreateStreamCompleted>();
+ var dto = data.Deserialize<ClientMessage.CreateStreamCompleted>();
_result = dto;
switch ((OperationErrorCode)dto.ErrorCode)
@@ -39,7 +39,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class DeleteStreamOperation : IClientOperation
{
private readonly TaskCompletionSource<object> _source;
- private ClientMessages.DeleteStreamCompleted _result;
+ private ClientMessage.DeleteStreamCompleted _result;
private int _completed;
private Guid _correlationId;
@@ -76,7 +76,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dto = new ClientMessages.DeleteStream(_stream, _expectedVersion, _forward);
+ var dto = new ClientMessage.DeleteStream(_stream, _expectedVersion, _forward);
return new TcpPackage(TcpCommand.DeleteStream, _correlationId, dto.Serialize());
}
}
@@ -93,7 +93,7 @@ public InspectionResult InspectPackage(TcpPackage package)
{
if (package.Command == TcpCommand.DeniedToRoute)
{
- var route = package.Data.Deserialize<ClientMessages.DeniedToRoute>();
+ var route = package.Data.Deserialize<ClientMessage.DeniedToRoute>();
return new InspectionResult(InspectionDecision.Reconnect,
data: new EndpointsPair(route.ExternalTcpEndPoint,
route.ExternalHttpEndPoint));
@@ -106,7 +106,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.DeleteStreamCompleted>();
+ var dto = data.Deserialize<ClientMessage.DeleteStreamCompleted>();
_result = dto;
switch ((OperationErrorCode)dto.ErrorCode)
@@ -11,7 +11,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class ReadAllEventsBackwardOperation : IClientOperation
{
private readonly TaskCompletionSource<AllEventsSlice> _source;
- private ClientMessages.ReadAllEventsBackwardCompleted _result;
+ private ClientMessage.ReadAllEventsBackwardCompleted _result;
private int _completed;
private Guid _corrId;
@@ -54,7 +54,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dto = new ClientMessages.ReadAllEventsBackward(_position.CommitPosition,
+ var dto = new ClientMessage.ReadAllEventsBackward(_position.CommitPosition,
_position.PreparePosition,
_maxCount,
_resolveLinkTos);
@@ -74,7 +74,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.ReadAllEventsBackwardCompleted>();
+ var dto = data.Deserialize<ClientMessage.ReadAllEventsBackwardCompleted>();
_result = dto;
return new InspectionResult(InspectionDecision.Succeed);
}
@@ -38,7 +38,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class ReadAllEventsForwardOperation : IClientOperation
{
private readonly TaskCompletionSource<AllEventsSlice> _source;
- private ClientMessages.ReadAllEventsForwardCompleted _result;
+ private ClientMessage.ReadAllEventsForwardCompleted _result;
private int _completed;
private Guid _corrId;
@@ -81,7 +81,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dto = new ClientMessages.ReadAllEventsForward(_position.CommitPosition,
+ var dto = new ClientMessage.ReadAllEventsForward(_position.CommitPosition,
_position.PreparePosition,
_maxCount,
_resolveLinkTos);
@@ -101,7 +101,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.ReadAllEventsForwardCompleted>();
+ var dto = data.Deserialize<ClientMessage.ReadAllEventsForwardCompleted>();
_result = dto;
return new InspectionResult(InspectionDecision.Succeed);
}
@@ -11,7 +11,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class ReadStreamEventsBackwardOperation : IClientOperation
{
private readonly TaskCompletionSource<EventStreamSlice> _source;
- private ClientMessages.ReadStreamEventsBackwardCompleted _result;
+ private ClientMessage.ReadStreamEventsBackwardCompleted _result;
private int _completed;
private Guid _correlationId;
@@ -57,7 +57,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dto = new ClientMessages.ReadStreamEventsBackward(_stream, _start, _count, _resolveLinkTos);
+ var dto = new ClientMessage.ReadStreamEventsBackward(_stream, _start, _count, _resolveLinkTos);
return new TcpPackage(TcpCommand.ReadStreamEventsBackward, _correlationId, dto.Serialize());
}
}
@@ -74,7 +74,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.ReadStreamEventsBackwardCompleted>();
+ var dto = data.Deserialize<ClientMessage.ReadStreamEventsBackwardCompleted>();
_result = dto;
switch ((RangeReadResult)dto.Result)
@@ -39,7 +39,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class ReadStreamEventsForwardOperation : IClientOperation
{
private readonly TaskCompletionSource<EventStreamSlice> _source;
- private ClientMessages.ReadStreamEventsForwardCompleted _result;
+ private ClientMessage.ReadStreamEventsForwardCompleted _result;
private int _completed;
private Guid _correlationId;
@@ -49,6 +49,7 @@ internal class ReadStreamEventsForwardOperation : IClientOperation
private readonly int _start;
private readonly int _count;
private readonly bool _resolveLinkTos;
+ private readonly bool _returnLastEventNumber;
public Guid CorrelationId
{
@@ -64,7 +65,8 @@ public Guid CorrelationId
string stream,
int start,
int count,
- bool resolveLinkTos)
+ bool resolveLinkTos,
+ bool returnLastEventNumber)
{
_source = source;
@@ -73,6 +75,7 @@ public Guid CorrelationId
_start = start;
_count = count;
_resolveLinkTos = resolveLinkTos;
+ _returnLastEventNumber = returnLastEventNumber;
}
public void SetRetryId(Guid correlationId)
@@ -85,7 +88,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dto = new ClientMessages.ReadStreamEventsForward(_stream, _start, _count, _resolveLinkTos);
+ var dto = new ClientMessage.ReadStreamEventsForward(_stream, _start, _count, _resolveLinkTos, _returnLastEventNumber);
return new TcpPackage(TcpCommand.ReadStreamEventsForward, _correlationId, dto.Serialize());
}
}
@@ -102,7 +105,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.ReadStreamEventsForwardCompleted>();
+ var dto = data.Deserialize<ClientMessage.ReadStreamEventsForwardCompleted>();
_result = dto;
switch ((RangeReadResult)dto.Result)
@@ -39,7 +39,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class StartTransactionOperation : IClientOperation
{
private readonly TaskCompletionSource<EventStoreTransaction> _source;
- private ClientMessages.TransactionStartCompleted _result;
+ private ClientMessage.TransactionStartCompleted _result;
private int _completed;
private Guid _corrId;
@@ -82,7 +82,7 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var startTransaction = new ClientMessages.TransactionStart(_stream, _expectedVersion, _forward);
+ var startTransaction = new ClientMessage.TransactionStart(_stream, _expectedVersion, _forward);
return new TcpPackage(TcpCommand.TransactionStart, _corrId, startTransaction.Serialize());
}
}
@@ -93,7 +93,7 @@ public InspectionResult InspectPackage(TcpPackage package)
{
if (package.Command == TcpCommand.DeniedToRoute)
{
- var route = package.Data.Deserialize<ClientMessages.DeniedToRoute>();
+ var route = package.Data.Deserialize<ClientMessage.DeniedToRoute>();
return new InspectionResult(InspectionDecision.Reconnect,
data: new EndpointsPair(route.ExternalTcpEndPoint,
route.ExternalHttpEndPoint));
@@ -106,7 +106,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.TransactionStartCompleted>();
+ var dto = data.Deserialize<ClientMessage.TransactionStartCompleted>();
_result = dto;
switch ((OperationErrorCode)dto.ErrorCode)
@@ -41,7 +41,7 @@ namespace EventStore.ClientAPI.ClientOperations
internal class TransactionalWriteOperation : IClientOperation
{
private readonly TaskCompletionSource<object> _source;
- private ClientMessages.TransactionWriteCompleted _result;
+ private ClientMessage.TransactionWriteCompleted _result;
private int _completed;
private Guid _corrId;
@@ -87,8 +87,8 @@ public TcpPackage CreateNetworkPackage()
{
lock (_corrIdLock)
{
- var dtos = _events.Select(x => new ClientMessages.ClientEvent(x.EventId.ToByteArray(), x.Type, x.Data, x.Metadata)).ToArray();
- var write = new ClientMessages.TransactionWrite(_transactionId, _stream, dtos, _forward);
+ var dtos = _events.Select(x => new ClientMessage.ClientEvent(x.EventId.ToByteArray(), x.Type, x.Data, x.Metadata)).ToArray();
+ var write = new ClientMessage.TransactionWrite(_transactionId, _stream, dtos, _forward);
return new TcpPackage(TcpCommand.TransactionWrite, _corrId, write.Serialize());
}
}
@@ -99,7 +99,7 @@ public InspectionResult InspectPackage(TcpPackage package)
{
if (package.Command == TcpCommand.DeniedToRoute)
{
- var route = package.Data.Deserialize<ClientMessages.DeniedToRoute>();
+ var route = package.Data.Deserialize<ClientMessage.DeniedToRoute>();
return new InspectionResult(InspectionDecision.Reconnect,
data: new EndpointsPair(route.ExternalTcpEndPoint,
route.ExternalHttpEndPoint));
@@ -112,7 +112,7 @@ public InspectionResult InspectPackage(TcpPackage package)
}
var data = package.Data;
- var dto = data.Deserialize<ClientMessages.TransactionWriteCompleted>();
+ var dto = data.Deserialize<ClientMessage.TransactionWriteCompleted>();
_result = dto;
switch ((OperationErrorCode)dto.ErrorCode)
Oops, something went wrong.

0 comments on commit 4b568dc

Please sign in to comment.