Updated protobufjs to latest version
This commit is contained in:
@ -27,16 +27,17 @@ util.inherits(AppendToStreamOperation, OperationBase);
|
||||
AppendToStreamOperation.prototype._createRequestDto = function() {
|
||||
var dtos = this._events.map(function(ev) {
|
||||
var eventId = new Buffer(uuidParse.parse(ev.eventId));
|
||||
return new ClientMessage.NewEvent({
|
||||
event_id: eventId, event_type: ev.type,
|
||||
data_content_type: ev.isJson ? 1 : 0, metadata_content_type: 0,
|
||||
data: ev.data, metadata: ev.metadata});
|
||||
return {
|
||||
eventId: eventId, eventType: ev.type,
|
||||
dataContentType: ev.isJson ? 1 : 0, metadataContentType: 0,
|
||||
data: ev.data, metadata: ev.metadata
|
||||
};
|
||||
});
|
||||
return new ClientMessage.WriteEvents({
|
||||
event_stream_id: this._stream,
|
||||
expected_version: this._expectedVersion,
|
||||
eventStreamId: this._stream,
|
||||
expectedVersion: this._expectedVersion,
|
||||
events: dtos,
|
||||
require_master: this._requireMaster});
|
||||
requireMaster: this._requireMaster});
|
||||
};
|
||||
|
||||
AppendToStreamOperation.prototype._inspectResponse = function(response) {
|
||||
@ -72,7 +73,7 @@ AppendToStreamOperation.prototype._inspectResponse = function(response) {
|
||||
};
|
||||
|
||||
AppendToStreamOperation.prototype._transformResponse = function(response) {
|
||||
return new WriteResult(response.last_event_number, new Position(response.prepare_position || -1, response.commit_position || -1));
|
||||
return new WriteResult(response.lastEventNumber, new Position(response.preparePosition || -1, response.commitPosition || -1));
|
||||
};
|
||||
|
||||
AppendToStreamOperation.prototype.toString = function() {
|
||||
|
@ -23,7 +23,10 @@ function CommitTransactionOperation(log, cb, requireMaster, transactionId, userC
|
||||
util.inherits(CommitTransactionOperation, OperationBase);
|
||||
|
||||
CommitTransactionOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.TransactionCommit(this._transactionId, this._requireMaster);
|
||||
return new ClientMessage.TransactionCommit({
|
||||
transactionId: this._transactionId,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
};
|
||||
|
||||
CommitTransactionOperation.prototype._inspectResponse = function(response) {
|
||||
@ -56,8 +59,8 @@ CommitTransactionOperation.prototype._inspectResponse = function(response) {
|
||||
};
|
||||
|
||||
CommitTransactionOperation.prototype._transformResponse = function(response) {
|
||||
var logPosition = new results.Position(response.prepare_position || -1, response.commit_position || -1);
|
||||
return new results.WriteResult(response.last_event_number, logPosition);
|
||||
var logPosition = new results.Position(response.preparePosition || -1, response.commitPosition || -1);
|
||||
return new results.WriteResult(response.lastEventNumber, logPosition);
|
||||
};
|
||||
|
||||
CommitTransactionOperation.prototype.toString = function() {
|
||||
|
@ -27,21 +27,25 @@ function ConnectToPersistentSubscriptionOperation(
|
||||
util.inherits(ConnectToPersistentSubscriptionOperation, SubscriptionOperation);
|
||||
|
||||
ConnectToPersistentSubscriptionOperation.prototype._createSubscriptionPackage = function() {
|
||||
var dto = new ClientMessage.ConnectToPersistentSubscription(this._groupName, this._streamId, this._bufferSize);
|
||||
var dto = new ClientMessage.ConnectToPersistentSubscription({
|
||||
subscriptionId: this._groupName,
|
||||
eventStreamId: this._streamId,
|
||||
allowedInFlightMessages: this._bufferSize
|
||||
});
|
||||
return new TcpPackage(TcpCommand.ConnectToPersistentSubscription,
|
||||
this._userCredentials !== null ? TcpFlags.Authenticated : TcpFlags.None,
|
||||
this._correlationId,
|
||||
this._userCredentials !== null ? this._userCredentials.username : null,
|
||||
this._userCredentials !== null ? this._userCredentials.password : null,
|
||||
createBufferSegment(dto.toBuffer()));
|
||||
createBufferSegment(ClientMessage.ConnectToPersistentSubscription.encode(dto).finish()));
|
||||
};
|
||||
|
||||
ConnectToPersistentSubscriptionOperation.prototype._inspectPackage = function(pkg) {
|
||||
if (pkg.command === TcpCommand.PersistentSubscriptionConfirmation)
|
||||
{
|
||||
var dto = ClientMessage.PersistentSubscriptionConfirmation.decode(pkg.data.toBuffer());
|
||||
this._confirmSubscription(dto.last_commit_position, dto.last_event_number);
|
||||
this._subscriptionId = dto.subscription_id;
|
||||
this._confirmSubscription(dto.lastCommitPosition, dto.lastEventNumber);
|
||||
this._subscriptionId = dto.subscriptionId;
|
||||
return new InspectionResult(InspectionDecision.Subscribed, "SubscriptionConfirmation");
|
||||
}
|
||||
if (pkg.command === TcpCommand.PersistentSubscriptionStreamEventAppeared)
|
||||
@ -86,8 +90,8 @@ ConnectToPersistentSubscriptionOperation.prototype._createSubscriptionObject = f
|
||||
ConnectToPersistentSubscriptionOperation.prototype.notifyEventsProcessed = function(processedEvents) {
|
||||
ensure.notNull(processedEvents, "processedEvents");
|
||||
var dto = new ClientMessage.PersistentSubscriptionAckEvents({
|
||||
subscription_id: this._subscriptionId,
|
||||
processed_event_ids: processedEvents.map(function (x) {
|
||||
subscriptionId: this._subscriptionId,
|
||||
processedEventIds: processedEvents.map(function (x) {
|
||||
return new Buffer(uuidParse.parse(x));
|
||||
})
|
||||
});
|
||||
@ -97,25 +101,26 @@ ConnectToPersistentSubscriptionOperation.prototype.notifyEventsProcessed = funct
|
||||
this._correlationId,
|
||||
this._userCredentials !== null ? this._userCredentials.username : null,
|
||||
this._userCredentials !== null ? this._userCredentials.password : null,
|
||||
createBufferSegment(dto.encode().toBuffer()));
|
||||
createBufferSegment(ClientMessage.PersistentSubscriptionAckEvents.encode(dto).finish()));
|
||||
this._enqueueSend(pkg);
|
||||
};
|
||||
|
||||
ConnectToPersistentSubscriptionOperation.prototype.notifyEventsFailed = function(processedEvents, action, reason) {
|
||||
ensure.notNull(processedEvents, "processedEvents");
|
||||
ensure.notNull(reason, "reason");
|
||||
var dto = new ClientMessage.PersistentSubscriptionNakEvents(
|
||||
this._subscriptionId,
|
||||
processedEvents.map(function(x) { return new Buffer(uuidParse.parse(x)); }),
|
||||
reason,
|
||||
action);
|
||||
var dto = new ClientMessage.PersistentSubscriptionNakEvents({
|
||||
subscriptionId: this._subscriptionId,
|
||||
processedEventIds: processedEvents.map(function(x) { return new Buffer(uuidParse.parse(x)); }),
|
||||
message: reason,
|
||||
action: action
|
||||
});
|
||||
|
||||
var pkg = new TcpPackage(TcpCommand.PersistentSubscriptionNakEvents,
|
||||
this._userCredentials !== null ? TcpFlags.Authenticated : TcpFlags.None,
|
||||
this._correlationId,
|
||||
this._userCredentials !== null ? this._userCredentials.username : null,
|
||||
this._userCredentials !== null ? this._userCredentials.password : null,
|
||||
createBufferSegment(dto.toBuffer()));
|
||||
createBufferSegment(ClientMessage.PersistentSubscriptionNakEvents.encode(dto).finish()));
|
||||
this._enqueueSend(pkg);
|
||||
};
|
||||
|
||||
|
@ -36,11 +36,24 @@ function CreatePersistentSubscriptionOperation(log, cb, stream, groupName, setti
|
||||
util.inherits(CreatePersistentSubscriptionOperation, OperationBase);
|
||||
|
||||
CreatePersistentSubscriptionOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.CreatePersistentSubscription(this._groupName, this._stream, this._resolveLinkTos,
|
||||
this._startFromBeginning, this._messageTimeoutMilliseconds, this._recordStatistics, this._liveBufferSize,
|
||||
this._readBatchSize, this._bufferSize, this._maxRetryCount,
|
||||
this._namedConsumerStrategy === SystemConsumerStrategies.RoundRobin, this._checkPointAfter,
|
||||
this._maxCheckPointCount, this._minCheckPointCount, this._maxSubscriberCount, this._namedConsumerStrategy);
|
||||
return new ClientMessage.CreatePersistentSubscription({
|
||||
subscriptionGroupName: this._groupName,
|
||||
eventStreamId: this._stream,
|
||||
resolveLinkTos: this._resolveLinkTos,
|
||||
startFrom: this._startFromBeginning,
|
||||
messageTimeoutMilliseconds: this._messageTimeoutMilliseconds,
|
||||
recordStatistics: this._recordStatistics,
|
||||
liveBufferSize: this._liveBufferSize,
|
||||
readBatchSize: this._readBatchSize,
|
||||
bufferSize: this._bufferSize,
|
||||
maxRetryCount: this._maxRetryCount,
|
||||
preferRoundRobin: this._namedConsumerStrategy === SystemConsumerStrategies.RoundRobin,
|
||||
checkpointAfterTime: this._checkPointAfter,
|
||||
checkpointMaxCount: this._maxCheckPointCount,
|
||||
checkpointMinCount: this._minCheckPointCount,
|
||||
subscriberMaxCount: this._maxSubscriberCount,
|
||||
namedConsumerStrategy: this._namedConsumerStrategy
|
||||
});
|
||||
};
|
||||
|
||||
CreatePersistentSubscriptionOperation.prototype._inspectResponse = function(response) {
|
||||
|
@ -21,7 +21,10 @@ function DeletePersistentSubscriptionOperation(log, cb, stream, groupName, userC
|
||||
util.inherits(DeletePersistentSubscriptionOperation, OperationBase);
|
||||
|
||||
DeletePersistentSubscriptionOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.DeletePersistentSubscription(this._groupName, this._stream);
|
||||
return new ClientMessage.DeletePersistentSubscription({
|
||||
subscriptionGroupName: this._groupName,
|
||||
eventStreamId: this._stream
|
||||
});
|
||||
};
|
||||
|
||||
DeletePersistentSubscriptionOperation.prototype._inspectResponse = function(response) {
|
||||
|
@ -25,7 +25,12 @@ function DeleteStreamOperation(log, cb, requireMaster, stream, expectedVersion,
|
||||
util.inherits(DeleteStreamOperation, OperationBase);
|
||||
|
||||
DeleteStreamOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.DeleteStream(this._stream, this._expectedVersion, this._requireMaster, this._hardDelete);
|
||||
return new ClientMessage.DeleteStream({
|
||||
eventStreamId: this._stream,
|
||||
expectedVersion: this._expectedVersion,
|
||||
requireMaster: this._requireMaster,
|
||||
hardDelete: this._hardDelete
|
||||
});
|
||||
};
|
||||
|
||||
DeleteStreamOperation.prototype._inspectResponse = function(response) {
|
||||
@ -58,7 +63,7 @@ DeleteStreamOperation.prototype._inspectResponse = function(response) {
|
||||
};
|
||||
|
||||
DeleteStreamOperation.prototype._transformResponse = function(response) {
|
||||
return new results.DeleteResult(new results.Position(response.prepare_position || -1, response.commit_position || -1));
|
||||
return new results.DeleteResult(new results.Position(response.preparePosition || -1, response.commitPosition || -1));
|
||||
};
|
||||
|
||||
DeleteStreamOperation.prototype.toString = function() {
|
||||
|
@ -51,7 +51,7 @@ OperationBase.prototype._succeed = function() {
|
||||
|
||||
OperationBase.prototype.createNetworkPackage = function(correlationId) {
|
||||
var dto = this._createRequestDto();
|
||||
var buf = dto.toBuffer();
|
||||
var buf = dto.constructor.encode(dto).finish();
|
||||
return new TcpPackage(
|
||||
this._requestCommand,
|
||||
this.userCredentials ? TcpFlags.Authenticated : TcpFlags.None,
|
||||
@ -117,10 +117,10 @@ OperationBase.prototype._inspectNotHandled = function(pkg)
|
||||
return new InspectionResult(InspectionDecision.Retry, "NotHandled - TooBusy");
|
||||
|
||||
case ClientMessage.NotHandled.NotHandledReason.NotMaster:
|
||||
var masterInfo = ClientMessage.NotHandled.MasterInfo.decode(message.additional_info);
|
||||
var masterInfo = ClientMessage.NotHandled.MasterInfo.decode(message.additionalInfo);
|
||||
return new InspectionResult(InspectionDecision.Reconnect, "NotHandled - NotMaster",
|
||||
{host: masterInfo.external_tcp_address, port: masterInfo.external_tcp_port},
|
||||
{host: masterInfo.external_secure_tcp_address, port: masterInfo.external_secure_tcp_port});
|
||||
{host: masterInfo.externalTcpAddress, port: masterInfo.externalTcpPort},
|
||||
{host: masterInfo.externalSecureTcpAddress, port: masterInfo.externalSecureTcpPort});
|
||||
|
||||
default:
|
||||
this.log.error("Unknown NotHandledReason: %s.", message.reason);
|
||||
|
@ -25,7 +25,13 @@ function ReadAllEventsBackwardOperation(
|
||||
util.inherits(ReadAllEventsBackwardOperation, OperationBase);
|
||||
|
||||
ReadAllEventsBackwardOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.ReadAllEvents(this._position.commitPosition, this._position.preparePosition, this._maxCount, this._resolveLinkTos, this._requireMaster);
|
||||
return new ClientMessage.ReadAllEvents({
|
||||
commitPosition: this._position.commitPosition,
|
||||
preparePosition: this._position.preparePosition,
|
||||
maxCount: this._maxCount,
|
||||
resolveLinkTos: this._resolveLinkTos,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
};
|
||||
|
||||
ReadAllEventsBackwardOperation.prototype._inspectResponse = function(response) {
|
||||
@ -48,8 +54,8 @@ ReadAllEventsBackwardOperation.prototype._inspectResponse = function(response) {
|
||||
ReadAllEventsBackwardOperation.prototype._transformResponse = function(response) {
|
||||
return new results.AllEventsSlice(
|
||||
ReadDirection.Backward,
|
||||
new results.Position(response.commit_position, response.prepare_position),
|
||||
new results.Position(response.next_commit_position, response.next_prepare_position),
|
||||
new results.Position(response.commitPosition, response.preparePosition),
|
||||
new results.Position(response.nextCommitPosition, response.nextPreparePosition),
|
||||
response.events
|
||||
)
|
||||
};
|
||||
|
@ -25,7 +25,13 @@ function ReadAllEventsForwardOperation(
|
||||
util.inherits(ReadAllEventsForwardOperation, OperationBase);
|
||||
|
||||
ReadAllEventsForwardOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.ReadAllEvents(this._position.commitPosition, this._position.preparePosition, this._maxCount, this._resolveLinkTos, this._requireMaster);
|
||||
return new ClientMessage.ReadAllEvents({
|
||||
commitPosition: this._position.commitPosition,
|
||||
preparePosition: this._position.preparePosition,
|
||||
maxCount: this._maxCount,
|
||||
resolveLinkTos: this._resolveLinkTos,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
};
|
||||
|
||||
ReadAllEventsForwardOperation.prototype._inspectResponse = function(response) {
|
||||
@ -48,8 +54,8 @@ ReadAllEventsForwardOperation.prototype._inspectResponse = function(response) {
|
||||
ReadAllEventsForwardOperation.prototype._transformResponse = function(response) {
|
||||
return new results.AllEventsSlice(
|
||||
ReadDirection.Forward,
|
||||
new results.Position(response.commit_position, response.prepare_position),
|
||||
new results.Position(response.next_commit_position, response.next_prepare_position),
|
||||
new results.Position(response.commitPosition, response.preparePosition),
|
||||
new results.Position(response.nextCommitPosition, response.nextPreparePosition),
|
||||
response.events
|
||||
)
|
||||
};
|
||||
|
@ -21,7 +21,12 @@ function ReadEventOperation(log, cb, stream, eventNumber, resolveLinkTos, requir
|
||||
util.inherits(ReadEventOperation, OperationBase);
|
||||
|
||||
ReadEventOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.ReadEvent(this._stream, this._eventNumber, this._resolveLinkTos, this._requireMaster);
|
||||
return new ClientMessage.ReadEvent({
|
||||
eventStreamId: this._stream,
|
||||
eventNumber: this._eventNumber,
|
||||
resolveLinkTos: this._resolveLinkTos,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
};
|
||||
|
||||
ReadEventOperation.prototype._inspectResponse = function(response) {
|
||||
|
@ -27,7 +27,13 @@ function ReadStreamEventsBackwardOperation(
|
||||
util.inherits(ReadStreamEventsBackwardOperation, OperationBase);
|
||||
|
||||
ReadStreamEventsBackwardOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.ReadStreamEvents(this._stream, this._fromEventNumber, this._maxCount, this._resolveLinkTos, this._requireMaster);
|
||||
return new ClientMessage.ReadStreamEvents({
|
||||
eventStreamId: this._stream,
|
||||
fromEventNumber: this._fromEventNumber,
|
||||
maxCount: this._maxCount,
|
||||
resolveLinkTos: this._resolveLinkTos,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
};
|
||||
|
||||
ReadStreamEventsBackwardOperation.prototype._inspectResponse = function(response) {
|
||||
@ -60,9 +66,9 @@ ReadStreamEventsBackwardOperation.prototype._transformResponse = function(respon
|
||||
this._fromEventNumber,
|
||||
ReadDirection.Backward,
|
||||
response.events,
|
||||
response.next_event_number,
|
||||
response.last_event_number,
|
||||
response.is_end_of_stream
|
||||
response.nextEventNumber,
|
||||
response.lastEventNumber,
|
||||
response.isEndOfStream
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,13 @@ function ReadStreamEventsForwardOperation(
|
||||
util.inherits(ReadStreamEventsForwardOperation, OperationBase);
|
||||
|
||||
ReadStreamEventsForwardOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.ReadStreamEvents(this._stream, this._fromEventNumber, this._maxCount, this._resolveLinkTos, this._requireMaster);
|
||||
return new ClientMessage.ReadStreamEvents({
|
||||
eventStreamId: this._stream,
|
||||
fromEventNumber: this._fromEventNumber,
|
||||
maxCount: this._maxCount,
|
||||
resolveLinkTos: this._resolveLinkTos,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
};
|
||||
|
||||
ReadStreamEventsForwardOperation.prototype._inspectResponse = function(response) {
|
||||
@ -60,9 +66,9 @@ ReadStreamEventsForwardOperation.prototype._transformResponse = function(respons
|
||||
this._fromEventNumber,
|
||||
ReadDirection.Forward,
|
||||
response.events,
|
||||
response.next_event_number,
|
||||
response.last_event_number,
|
||||
response.is_end_of_stream
|
||||
response.nextEventNumber,
|
||||
response.lastEventNumber,
|
||||
response.isEndOfStream
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,11 @@ function StartTransactionOperation(log, cb, requireMaster, stream, expectedVersi
|
||||
util.inherits(StartTransactionOperation, OperationBase);
|
||||
|
||||
StartTransactionOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.TransactionStart(this._stream, this._expectedVersion, this._requireMaster);
|
||||
return new ClientMessage.TransactionStart({
|
||||
eventStreamId: this._stream,
|
||||
expectedVersion: this._expectedVersion,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
};
|
||||
|
||||
StartTransactionOperation.prototype._inspectResponse = function(response) {
|
||||
@ -57,7 +61,7 @@ StartTransactionOperation.prototype._inspectResponse = function(response) {
|
||||
};
|
||||
|
||||
StartTransactionOperation.prototype._transformResponse = function(response) {
|
||||
return new EventStoreTransaction(response.transaction_id, this.userCredentials, this._parentConnection);
|
||||
return new EventStoreTransaction(response.transactionId, this.userCredentials, this._parentConnection);
|
||||
};
|
||||
|
||||
StartTransactionOperation.prototype.toString = function() {
|
||||
|
@ -64,7 +64,7 @@ SubscriptionOperation.prototype.unsubscribe = function() {
|
||||
|
||||
SubscriptionOperation.prototype._createUnsubscriptionPackage = function() {
|
||||
var msg = new ClientMessage.UnsubscribeFromStream();
|
||||
var data = new BufferSegment(msg.toBuffer());
|
||||
var data = new BufferSegment(ClientMessage.UnsubscribeFromStream.encode(msg).finish());
|
||||
return new TcpPackage(TcpCommand.UnsubscribeFromStream, TcpFlags.None, this._correlationId, null, null, data);
|
||||
};
|
||||
|
||||
@ -141,10 +141,10 @@ SubscriptionOperation.prototype.inspectPackage = function(pkg) {
|
||||
return new InspectionResult(InspectionDecision.Retry, "NotHandled - TooBusy");
|
||||
|
||||
case ClientMessage.NotHandled.NotHandledReason.NotMaster:
|
||||
var masterInfo = ClientMessage.NotHandled.MasterInfo.decode(message.additional_info);
|
||||
var masterInfo = ClientMessage.NotHandled.MasterInfo.decode(message.additionalInfo);
|
||||
return new InspectionResult(InspectionDecision.Reconnect, "NotHandled - NotMaster",
|
||||
{host: masterInfo.external_tcp_address, port: masterInfo.external_tcp_port},
|
||||
{host: masterInfo.external_secure_tcp_address, port: masterInfo.external_secure_tcp_port});
|
||||
{host: masterInfo.externalTcpAddress, port: masterInfo.externalTcpPort},
|
||||
{host: masterInfo.externalSecureTcpAddress, port: masterInfo.externalSecureTcpPort});
|
||||
|
||||
default:
|
||||
this._log.error("Unknown NotHandledReason: %s.", message.reason);
|
||||
|
@ -23,12 +23,17 @@ util.inherits(TransactionalWriteOperation, OperationBase);
|
||||
TransactionalWriteOperation.prototype._createRequestDto = function() {
|
||||
var dtos = this._events.map(function(ev) {
|
||||
var eventId = new Buffer(uuidParse.parse(ev.eventId));
|
||||
return new ClientMessage.NewEvent({
|
||||
event_id: eventId, event_type: ev.type,
|
||||
data_content_type: ev.isJson ? 1 : 0, metadata_content_type: 0,
|
||||
data: ev.data, metadata: ev.metadata});
|
||||
return {
|
||||
eventId: eventId, eventType: ev.type,
|
||||
dataContentType: ev.isJson ? 1 : 0, metadataContentType: 0,
|
||||
data: ev.data, metadata: ev.metadata
|
||||
};
|
||||
});
|
||||
return new ClientMessage.TransactionWrite({
|
||||
transactionId: this._transactionId,
|
||||
events: dtos,
|
||||
requireMaster: this._requireMaster
|
||||
});
|
||||
return new ClientMessage.TransactionWrite(this._transactionId, dtos, this._requireMaster);
|
||||
};
|
||||
|
||||
TransactionalWriteOperation.prototype._inspectResponse = function(response) {
|
||||
|
@ -36,11 +36,24 @@ function UpdatePersistentSubscriptionOperation(log, cb, stream, groupName, setti
|
||||
util.inherits(UpdatePersistentSubscriptionOperation, OperationBase);
|
||||
|
||||
UpdatePersistentSubscriptionOperation.prototype._createRequestDto = function() {
|
||||
return new ClientMessage.UpdatePersistentSubscription(this._groupName, this._stream, this._resolveLinkTos,
|
||||
this._startFromBeginning, this._messageTimeoutMilliseconds, this._recordStatistics, this._liveBufferSize,
|
||||
this._readBatchSize, this._bufferSize, this._maxRetryCount,
|
||||
this._namedConsumerStrategy === SystemConsumerStrategies.RoundRobin, this._checkPointAfter,
|
||||
this._maxCheckPointCount, this._minCheckPointCount, this._maxSubscriberCount, this._namedConsumerStrategy);
|
||||
return new ClientMessage.UpdatePersistentSubscription({
|
||||
subscriptionGroupName: this._groupName,
|
||||
eventStreamId: this._stream,
|
||||
resolveLinkTos: this._resolveLinkTos,
|
||||
startFrom: this._startFromBeginning,
|
||||
messageTimeoutMilliseconds: this._messageTimeoutMilliseconds,
|
||||
recordStatistics: this._recordStatistics,
|
||||
liveBufferSize: this._liveBufferSize,
|
||||
readBatchSize: this._readBatchSize,
|
||||
bufferSize: this._bufferSize,
|
||||
maxRetryCount: this._maxRetryCount,
|
||||
preferRoundRobin: this._namedConsumerStrategy === SystemConsumerStrategies.RoundRobin,
|
||||
checkpointAfterTime: this._checkPointAfter,
|
||||
checkpointMaxCount: this._maxCheckPointCount,
|
||||
checkpointMinCount: this._minCheckPointCount,
|
||||
subscriberMaxCount: this._maxSubscriberCount,
|
||||
namedConsumerStrategy: this._namedConsumerStrategy
|
||||
});
|
||||
};
|
||||
|
||||
UpdatePersistentSubscriptionOperation.prototype._inspectResponse = function(response) {
|
||||
|
@ -20,20 +20,23 @@ function VolatileSubscriptionOperation(
|
||||
util.inherits(VolatileSubscriptionOperation, SubscriptionOperation);
|
||||
|
||||
VolatileSubscriptionOperation.prototype._createSubscriptionPackage = function() {
|
||||
var dto = new ClientMessage.SubscribeToStream(this._streamId, this._resolveLinkTos);
|
||||
var dto = new ClientMessage.SubscribeToStream({
|
||||
eventStreamId: this._streamId,
|
||||
resolveLinkTos: this._resolveLinkTos
|
||||
});
|
||||
return new TcpPackage(TcpCommand.SubscribeToStream,
|
||||
this._userCredentials !== null ? TcpFlags.Authenticated : TcpFlags.None,
|
||||
this._correlationId,
|
||||
this._userCredentials !== null ? this._userCredentials.username : null,
|
||||
this._userCredentials !== null ? this._userCredentials.password : null,
|
||||
new BufferSegment(dto.toBuffer()));
|
||||
new BufferSegment(ClientMessage.SubscribeToStream.encode(dto).finish()));
|
||||
};
|
||||
|
||||
VolatileSubscriptionOperation.prototype._inspectPackage = function(pkg) {
|
||||
try {
|
||||
if (pkg.command === TcpCommand.SubscriptionConfirmation) {
|
||||
var dto = ClientMessage.SubscriptionConfirmation.decode(pkg.data.toBuffer());
|
||||
this._confirmSubscription(dto.last_commit_position, dto.last_event_number);
|
||||
this._confirmSubscription(dto.lastCommitPosition, dto.lastEventNumber);
|
||||
return new InspectionResult(InspectionDecision.Subscribed, "SubscriptionConfirmation");
|
||||
}
|
||||
if (pkg.command === TcpCommand.StreamEventAppeared) {
|
||||
|
12162
src/messages/messages.js
12162
src/messages/messages.js
File diff suppressed because it is too large
Load Diff
@ -53,15 +53,15 @@ Object.freeze(EventReadStatus);
|
||||
* @property {boolean} isJson
|
||||
*/
|
||||
function RecordedEvent(ev) {
|
||||
this.eventStreamId = ev.event_stream_id;
|
||||
this.eventId = uuidParse.unparse(ev.event_id.buffer, ev.event_id.offset);
|
||||
this.eventNumber = ev.event_number;
|
||||
this.eventType = ev.event_type;
|
||||
this.created = new Date(ev.created_epoch ? ev.created_epoch.toNumber() : 0);
|
||||
this.createdEpoch = ev.created_epoch ? ev.created_epoch.toNumber() : 0;
|
||||
this.data = ev.data ? ev.data.toBuffer() : new Buffer(0);
|
||||
this.metadata = ev.metadata ? ev.metadata.toBuffer() : new Buffer(0);
|
||||
this.isJson = ev.data_content_type === 1;
|
||||
this.eventStreamId = ev.eventStreamId;
|
||||
this.eventId = uuidParse.unparse(ev.eventId);
|
||||
this.eventNumber = ev.eventNumber;
|
||||
this.eventType = ev.eventType;
|
||||
this.created = new Date(ev.createdEpoch ? ev.createdEpoch.toNumber() : 0);
|
||||
this.createdEpoch = ev.createdEpoch ? ev.createdEpoch.toNumber() : 0;
|
||||
this.data = ev.data ? ev.data : new Buffer(0);
|
||||
this.metadata = ev.metadata ? ev.metadata : new Buffer(0);
|
||||
this.isJson = ev.dataContentType === 1;
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ function ResolvedEvent(ev) {
|
||||
this.link = ev.link === null ? null : new RecordedEvent(ev.link);
|
||||
this.originalEvent = this.link || this.event;
|
||||
this.isResolved = this.link !== null && this.event !== null;
|
||||
this.originalPosition = (ev.commit_position && ev.prepare_position) ? new Position(ev.commit_position, ev.prepare_position) : null;
|
||||
this.originalPosition = (ev.commitPosition && ev.preparePosition) ? new Position(ev.commitPosition, ev.preparePosition) : null;
|
||||
this.originalStreamId = this.originalEvent && this.originalEvent.eventStreamId;
|
||||
this.originalEventNumber = this.originalEvent && this.originalEvent.eventNumber;
|
||||
Object.freeze(this);
|
||||
|
Reference in New Issue
Block a user