diff --git a/packages/db-client/generated/streams_grpc_pb.d.ts b/packages/db-client/generated/streams_grpc_pb.d.ts index 6c19e610..40bba4a6 100644 --- a/packages/db-client/generated/streams_grpc_pb.d.ts +++ b/packages/db-client/generated/streams_grpc_pb.d.ts @@ -8,6 +8,7 @@ import * as grpc from "@grpc/grpc-js"; import * as streams_pb from "./streams_pb"; import * as shared_pb from "./shared_pb"; import * as status_pb from "./status_pb"; +import * as google_protobuf_duration_pb from "google-protobuf/google/protobuf/duration_pb"; import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; diff --git a/packages/db-client/generated/streams_grpc_pb.js b/packages/db-client/generated/streams_grpc_pb.js index dc06ccf3..429f3147 100644 --- a/packages/db-client/generated/streams_grpc_pb.js +++ b/packages/db-client/generated/streams_grpc_pb.js @@ -5,6 +5,7 @@ var grpc = require('@grpc/grpc-js'); var streams_pb = require('./streams_pb.js'); var shared_pb = require('./shared_pb.js'); var status_pb = require('./status_pb.js'); +var google_protobuf_duration_pb = require('google-protobuf/google/protobuf/duration_pb.js'); var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); diff --git a/packages/db-client/generated/streams_pb.d.ts b/packages/db-client/generated/streams_pb.d.ts index 6c09d095..58c13289 100644 --- a/packages/db-client/generated/streams_pb.d.ts +++ b/packages/db-client/generated/streams_pb.d.ts @@ -7,6 +7,7 @@ import * as jspb from "google-protobuf"; import * as shared_pb from "./shared_pb"; import * as status_pb from "./status_pb"; +import * as google_protobuf_duration_pb from "google-protobuf/google/protobuf/duration_pb"; import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; @@ -493,6 +494,21 @@ export namespace ReadResp { export class CaughtUp extends jspb.Message { + hasTimestamp(): boolean; + clearTimestamp(): void; + getTimestamp(): google_protobuf_timestamp_pb.Timestamp | undefined; + setTimestamp(value?: google_protobuf_timestamp_pb.Timestamp): CaughtUp; + + hasStreamRevision(): boolean; + clearStreamRevision(): void; + getStreamRevision(): string | undefined; + setStreamRevision(value: string): CaughtUp; + + hasPosition(): boolean; + clearPosition(): void; + getPosition(): ReadResp.Position | undefined; + setPosition(value?: ReadResp.Position): CaughtUp; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): CaughtUp.AsObject; static toObject(includeInstance: boolean, msg: CaughtUp): CaughtUp.AsObject; @@ -505,11 +521,29 @@ export namespace ReadResp { export namespace CaughtUp { export type AsObject = { + timestamp?: google_protobuf_timestamp_pb.Timestamp.AsObject, + streamRevision?: string, + position?: ReadResp.Position.AsObject, } } export class FellBehind extends jspb.Message { + hasTimestamp(): boolean; + clearTimestamp(): void; + getTimestamp(): google_protobuf_timestamp_pb.Timestamp | undefined; + setTimestamp(value?: google_protobuf_timestamp_pb.Timestamp): FellBehind; + + hasStreamRevision(): boolean; + clearStreamRevision(): void; + getStreamRevision(): string | undefined; + setStreamRevision(value: string): FellBehind; + + hasPosition(): boolean; + clearPosition(): void; + getPosition(): ReadResp.Position | undefined; + setPosition(value?: ReadResp.Position): FellBehind; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): FellBehind.AsObject; static toObject(includeInstance: boolean, msg: FellBehind): FellBehind.AsObject; @@ -522,6 +556,9 @@ export namespace ReadResp { export namespace FellBehind { export type AsObject = { + timestamp?: google_protobuf_timestamp_pb.Timestamp.AsObject, + streamRevision?: string, + position?: ReadResp.Position.AsObject, } } @@ -656,6 +693,11 @@ export namespace ReadResp { getPreparePosition(): string; setPreparePosition(value: string): Checkpoint; + hasTimestamp(): boolean; + clearTimestamp(): void; + getTimestamp(): google_protobuf_timestamp_pb.Timestamp | undefined; + setTimestamp(value?: google_protobuf_timestamp_pb.Timestamp): Checkpoint; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Checkpoint.AsObject; static toObject(includeInstance: boolean, msg: Checkpoint): Checkpoint.AsObject; @@ -667,6 +709,30 @@ export namespace ReadResp { } export namespace Checkpoint { + export type AsObject = { + commitPosition: string, + preparePosition: string, + timestamp?: google_protobuf_timestamp_pb.Timestamp.AsObject, + } + } + + export class Position extends jspb.Message { + getCommitPosition(): string; + setCommitPosition(value: string): Position; + getPreparePosition(): string; + setPreparePosition(value: string): Position; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Position.AsObject; + static toObject(includeInstance: boolean, msg: Position): Position.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Position, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Position; + static deserializeBinaryFromReader(message: Position, reader: jspb.BinaryReader): Position; + } + + export namespace Position { export type AsObject = { commitPosition: string, preparePosition: string, @@ -1148,12 +1214,18 @@ export namespace BatchAppendReq { getStreamExists(): google_protobuf_empty_pb.Empty | undefined; setStreamExists(value?: google_protobuf_empty_pb.Empty): Options; + hasDeadline21100(): boolean; + clearDeadline21100(): void; + getDeadline21100(): google_protobuf_timestamp_pb.Timestamp | undefined; + setDeadline21100(value?: google_protobuf_timestamp_pb.Timestamp): Options; + hasDeadline(): boolean; clearDeadline(): void; - getDeadline(): google_protobuf_timestamp_pb.Timestamp | undefined; - setDeadline(value?: google_protobuf_timestamp_pb.Timestamp): Options; + getDeadline(): google_protobuf_duration_pb.Duration | undefined; + setDeadline(value?: google_protobuf_duration_pb.Duration): Options; getExpectedStreamPositionCase(): Options.ExpectedStreamPositionCase; + getDeadlineOptionCase(): Options.DeadlineOptionCase; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Options.AsObject; @@ -1172,7 +1244,8 @@ export namespace BatchAppendReq { noStream?: google_protobuf_empty_pb.Empty.AsObject, any?: google_protobuf_empty_pb.Empty.AsObject, streamExists?: google_protobuf_empty_pb.Empty.AsObject, - deadline?: google_protobuf_timestamp_pb.Timestamp.AsObject, + deadline21100?: google_protobuf_timestamp_pb.Timestamp.AsObject, + deadline?: google_protobuf_duration_pb.Duration.AsObject, } export enum ExpectedStreamPositionCase { @@ -1183,6 +1256,12 @@ export namespace BatchAppendReq { STREAM_EXISTS = 5, } + export enum DeadlineOptionCase { + DEADLINE_OPTION_NOT_SET = 0, + DEADLINE_21_10_0 = 6, + DEADLINE = 7, + } + } export class ProposedMessage extends jspb.Message { diff --git a/packages/db-client/generated/streams_pb.js b/packages/db-client/generated/streams_pb.js index fd02ee83..05e64f97 100644 --- a/packages/db-client/generated/streams_pb.js +++ b/packages/db-client/generated/streams_pb.js @@ -25,6 +25,8 @@ var shared_pb = require('./shared_pb.js'); goog.object.extend(proto, shared_pb); var status_pb = require('./status_pb.js'); goog.object.extend(proto, status_pb); +var google_protobuf_duration_pb = require('google-protobuf/google/protobuf/duration_pb.js'); +goog.object.extend(proto, google_protobuf_duration_pb); var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); goog.object.extend(proto, google_protobuf_empty_pb); var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); @@ -47,6 +49,7 @@ goog.exportSymbol('proto.event_store.client.streams.AppendResp.WrongExpectedVers goog.exportSymbol('proto.event_store.client.streams.AppendResp.WrongExpectedVersion.ExpectedRevisionOptionCase', null, global); goog.exportSymbol('proto.event_store.client.streams.BatchAppendReq', null, global); goog.exportSymbol('proto.event_store.client.streams.BatchAppendReq.Options', null, global); +goog.exportSymbol('proto.event_store.client.streams.BatchAppendReq.Options.DeadlineOptionCase', null, global); goog.exportSymbol('proto.event_store.client.streams.BatchAppendReq.Options.ExpectedStreamPositionCase', null, global); goog.exportSymbol('proto.event_store.client.streams.BatchAppendReq.ProposedMessage', null, global); goog.exportSymbol('proto.event_store.client.streams.BatchAppendResp', null, global); @@ -85,6 +88,7 @@ goog.exportSymbol('proto.event_store.client.streams.ReadResp.CaughtUp', null, gl goog.exportSymbol('proto.event_store.client.streams.ReadResp.Checkpoint', null, global); goog.exportSymbol('proto.event_store.client.streams.ReadResp.ContentCase', null, global); goog.exportSymbol('proto.event_store.client.streams.ReadResp.FellBehind', null, global); +goog.exportSymbol('proto.event_store.client.streams.ReadResp.Position', null, global); goog.exportSymbol('proto.event_store.client.streams.ReadResp.ReadEvent', null, global); goog.exportSymbol('proto.event_store.client.streams.ReadResp.ReadEvent.PositionCase', null, global); goog.exportSymbol('proto.event_store.client.streams.ReadResp.ReadEvent.RecordedEvent', null, global); @@ -453,6 +457,27 @@ if (goog.DEBUG && !COMPILED) { */ proto.event_store.client.streams.ReadResp.Checkpoint.displayName = 'proto.event_store.client.streams.ReadResp.Checkpoint'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.event_store.client.streams.ReadResp.Position = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.event_store.client.streams.ReadResp.Position, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.event_store.client.streams.ReadResp.Position.displayName = 'proto.event_store.client.streams.ReadResp.Position'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -3749,7 +3774,9 @@ proto.event_store.client.streams.ReadResp.CaughtUp.prototype.toObject = function */ proto.event_store.client.streams.ReadResp.CaughtUp.toObject = function(includeInstance, msg) { var f, obj = { - + timestamp: (f = msg.getTimestamp()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), + streamRevision: jspb.Message.getFieldWithDefault(msg, 2, "0"), + position: (f = msg.getPosition()) && proto.event_store.client.streams.ReadResp.Position.toObject(includeInstance, f) }; if (includeInstance) { @@ -3786,6 +3813,20 @@ proto.event_store.client.streams.ReadResp.CaughtUp.deserializeBinaryFromReader = } var field = reader.getFieldNumber(); switch (field) { + case 1: + var value = new google_protobuf_timestamp_pb.Timestamp; + reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setTimestamp(value); + break; + case 2: + var value = /** @type {string} */ (reader.readInt64String()); + msg.setStreamRevision(value); + break; + case 3: + var value = new proto.event_store.client.streams.ReadResp.Position; + reader.readMessage(value,proto.event_store.client.streams.ReadResp.Position.deserializeBinaryFromReader); + msg.setPosition(value); + break; default: reader.skipField(); break; @@ -3815,6 +3856,139 @@ proto.event_store.client.streams.ReadResp.CaughtUp.prototype.serializeBinary = f */ proto.event_store.client.streams.ReadResp.CaughtUp.serializeBinaryToWriter = function(message, writer) { var f = undefined; + f = message.getTimestamp(); + if (f != null) { + writer.writeMessage( + 1, + f, + google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeInt64String( + 2, + f + ); + } + f = message.getPosition(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.event_store.client.streams.ReadResp.Position.serializeBinaryToWriter + ); + } +}; + + +/** + * optional google.protobuf.Timestamp timestamp = 1; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.getTimestamp = function() { + return /** @type{?proto.google.protobuf.Timestamp} */ ( + jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 1)); +}; + + +/** + * @param {?proto.google.protobuf.Timestamp|undefined} value + * @return {!proto.event_store.client.streams.ReadResp.CaughtUp} returns this +*/ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.setTimestamp = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.event_store.client.streams.ReadResp.CaughtUp} returns this + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.clearTimestamp = function() { + return this.setTimestamp(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.hasTimestamp = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional int64 stream_revision = 2; + * @return {string} + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.getStreamRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.event_store.client.streams.ReadResp.CaughtUp} returns this + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.setStreamRevision = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.event_store.client.streams.ReadResp.CaughtUp} returns this + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.clearStreamRevision = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.hasStreamRevision = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional Position position = 3; + * @return {?proto.event_store.client.streams.ReadResp.Position} + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.getPosition = function() { + return /** @type{?proto.event_store.client.streams.ReadResp.Position} */ ( + jspb.Message.getWrapperField(this, proto.event_store.client.streams.ReadResp.Position, 3)); +}; + + +/** + * @param {?proto.event_store.client.streams.ReadResp.Position|undefined} value + * @return {!proto.event_store.client.streams.ReadResp.CaughtUp} returns this +*/ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.setPosition = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.event_store.client.streams.ReadResp.CaughtUp} returns this + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.clearPosition = function() { + return this.setPosition(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.ReadResp.CaughtUp.prototype.hasPosition = function() { + return jspb.Message.getField(this, 3) != null; }; @@ -3850,7 +4024,9 @@ proto.event_store.client.streams.ReadResp.FellBehind.prototype.toObject = functi */ proto.event_store.client.streams.ReadResp.FellBehind.toObject = function(includeInstance, msg) { var f, obj = { - + timestamp: (f = msg.getTimestamp()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), + streamRevision: jspb.Message.getFieldWithDefault(msg, 2, "0"), + position: (f = msg.getPosition()) && proto.event_store.client.streams.ReadResp.Position.toObject(includeInstance, f) }; if (includeInstance) { @@ -3887,6 +4063,20 @@ proto.event_store.client.streams.ReadResp.FellBehind.deserializeBinaryFromReader } var field = reader.getFieldNumber(); switch (field) { + case 1: + var value = new google_protobuf_timestamp_pb.Timestamp; + reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setTimestamp(value); + break; + case 2: + var value = /** @type {string} */ (reader.readInt64String()); + msg.setStreamRevision(value); + break; + case 3: + var value = new proto.event_store.client.streams.ReadResp.Position; + reader.readMessage(value,proto.event_store.client.streams.ReadResp.Position.deserializeBinaryFromReader); + msg.setPosition(value); + break; default: reader.skipField(); break; @@ -3916,6 +4106,139 @@ proto.event_store.client.streams.ReadResp.FellBehind.prototype.serializeBinary = */ proto.event_store.client.streams.ReadResp.FellBehind.serializeBinaryToWriter = function(message, writer) { var f = undefined; + f = message.getTimestamp(); + if (f != null) { + writer.writeMessage( + 1, + f, + google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeInt64String( + 2, + f + ); + } + f = message.getPosition(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.event_store.client.streams.ReadResp.Position.serializeBinaryToWriter + ); + } +}; + + +/** + * optional google.protobuf.Timestamp timestamp = 1; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.getTimestamp = function() { + return /** @type{?proto.google.protobuf.Timestamp} */ ( + jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 1)); +}; + + +/** + * @param {?proto.google.protobuf.Timestamp|undefined} value + * @return {!proto.event_store.client.streams.ReadResp.FellBehind} returns this +*/ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.setTimestamp = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.event_store.client.streams.ReadResp.FellBehind} returns this + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.clearTimestamp = function() { + return this.setTimestamp(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.hasTimestamp = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional int64 stream_revision = 2; + * @return {string} + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.getStreamRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.event_store.client.streams.ReadResp.FellBehind} returns this + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.setStreamRevision = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.event_store.client.streams.ReadResp.FellBehind} returns this + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.clearStreamRevision = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.hasStreamRevision = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional Position position = 3; + * @return {?proto.event_store.client.streams.ReadResp.Position} + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.getPosition = function() { + return /** @type{?proto.event_store.client.streams.ReadResp.Position} */ ( + jspb.Message.getWrapperField(this, proto.event_store.client.streams.ReadResp.Position, 3)); +}; + + +/** + * @param {?proto.event_store.client.streams.ReadResp.Position|undefined} value + * @return {!proto.event_store.client.streams.ReadResp.FellBehind} returns this +*/ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.setPosition = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.event_store.client.streams.ReadResp.FellBehind} returns this + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.clearPosition = function() { + return this.setPosition(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.ReadResp.FellBehind.prototype.hasPosition = function() { + return jspb.Message.getField(this, 3) != null; }; @@ -4842,7 +5165,8 @@ proto.event_store.client.streams.ReadResp.Checkpoint.prototype.toObject = functi proto.event_store.client.streams.ReadResp.Checkpoint.toObject = function(includeInstance, msg) { var f, obj = { commitPosition: jspb.Message.getFieldWithDefault(msg, 1, "0"), - preparePosition: jspb.Message.getFieldWithDefault(msg, 2, "0") + preparePosition: jspb.Message.getFieldWithDefault(msg, 2, "0"), + timestamp: (f = msg.getTimestamp()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f) }; if (includeInstance) { @@ -4887,6 +5211,11 @@ proto.event_store.client.streams.ReadResp.Checkpoint.deserializeBinaryFromReader var value = /** @type {string} */ (reader.readUint64String()); msg.setPreparePosition(value); break; + case 3: + var value = new google_protobuf_timestamp_pb.Timestamp; + reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setTimestamp(value); + break; default: reader.skipField(); break; @@ -4930,6 +5259,14 @@ proto.event_store.client.streams.ReadResp.Checkpoint.serializeBinaryToWriter = f f ); } + f = message.getTimestamp(); + if (f != null) { + writer.writeMessage( + 3, + f, + google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter + ); + } }; @@ -4969,6 +5306,203 @@ proto.event_store.client.streams.ReadResp.Checkpoint.prototype.setPreparePositio }; +/** + * optional google.protobuf.Timestamp timestamp = 3; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.event_store.client.streams.ReadResp.Checkpoint.prototype.getTimestamp = function() { + return /** @type{?proto.google.protobuf.Timestamp} */ ( + jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 3)); +}; + + +/** + * @param {?proto.google.protobuf.Timestamp|undefined} value + * @return {!proto.event_store.client.streams.ReadResp.Checkpoint} returns this +*/ +proto.event_store.client.streams.ReadResp.Checkpoint.prototype.setTimestamp = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.event_store.client.streams.ReadResp.Checkpoint} returns this + */ +proto.event_store.client.streams.ReadResp.Checkpoint.prototype.clearTimestamp = function() { + return this.setTimestamp(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.ReadResp.Checkpoint.prototype.hasTimestamp = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.event_store.client.streams.ReadResp.Position.prototype.toObject = function(opt_includeInstance) { + return proto.event_store.client.streams.ReadResp.Position.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.event_store.client.streams.ReadResp.Position} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.event_store.client.streams.ReadResp.Position.toObject = function(includeInstance, msg) { + var f, obj = { + commitPosition: jspb.Message.getFieldWithDefault(msg, 1, "0"), + preparePosition: jspb.Message.getFieldWithDefault(msg, 2, "0") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.event_store.client.streams.ReadResp.Position} + */ +proto.event_store.client.streams.ReadResp.Position.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.event_store.client.streams.ReadResp.Position; + return proto.event_store.client.streams.ReadResp.Position.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.event_store.client.streams.ReadResp.Position} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.event_store.client.streams.ReadResp.Position} + */ +proto.event_store.client.streams.ReadResp.Position.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setCommitPosition(value); + break; + case 2: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setPreparePosition(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.event_store.client.streams.ReadResp.Position.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.event_store.client.streams.ReadResp.Position.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.event_store.client.streams.ReadResp.Position} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.event_store.client.streams.ReadResp.Position.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCommitPosition(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 1, + f + ); + } + f = message.getPreparePosition(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 2, + f + ); + } +}; + + +/** + * optional uint64 commit_position = 1; + * @return {string} + */ +proto.event_store.client.streams.ReadResp.Position.prototype.getCommitPosition = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.event_store.client.streams.ReadResp.Position} returns this + */ +proto.event_store.client.streams.ReadResp.Position.prototype.setCommitPosition = function(value) { + return jspb.Message.setProto3StringIntField(this, 1, value); +}; + + +/** + * optional uint64 prepare_position = 2; + * @return {string} + */ +proto.event_store.client.streams.ReadResp.Position.prototype.getPreparePosition = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.event_store.client.streams.ReadResp.Position} returns this + */ +proto.event_store.client.streams.ReadResp.Position.prototype.setPreparePosition = function(value) { + return jspb.Message.setProto3StringIntField(this, 2, value); +}; + + @@ -7979,7 +8513,7 @@ proto.event_store.client.streams.BatchAppendReq.serializeBinaryToWriter = functi * @private {!Array>} * @const */ -proto.event_store.client.streams.BatchAppendReq.Options.oneofGroups_ = [[2,3,4,5]]; +proto.event_store.client.streams.BatchAppendReq.Options.oneofGroups_ = [[2,3,4,5],[6,7]]; /** * @enum {number} @@ -7999,6 +8533,22 @@ proto.event_store.client.streams.BatchAppendReq.Options.prototype.getExpectedStr return /** @type {proto.event_store.client.streams.BatchAppendReq.Options.ExpectedStreamPositionCase} */(jspb.Message.computeOneofCase(this, proto.event_store.client.streams.BatchAppendReq.Options.oneofGroups_[0])); }; +/** + * @enum {number} + */ +proto.event_store.client.streams.BatchAppendReq.Options.DeadlineOptionCase = { + DEADLINE_OPTION_NOT_SET: 0, + DEADLINE_21_10_0: 6, + DEADLINE: 7 +}; + +/** + * @return {proto.event_store.client.streams.BatchAppendReq.Options.DeadlineOptionCase} + */ +proto.event_store.client.streams.BatchAppendReq.Options.prototype.getDeadlineOptionCase = function() { + return /** @type {proto.event_store.client.streams.BatchAppendReq.Options.DeadlineOptionCase} */(jspb.Message.computeOneofCase(this, proto.event_store.client.streams.BatchAppendReq.Options.oneofGroups_[1])); +}; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -8035,7 +8585,8 @@ proto.event_store.client.streams.BatchAppendReq.Options.toObject = function(incl noStream: (f = msg.getNoStream()) && google_protobuf_empty_pb.Empty.toObject(includeInstance, f), any: (f = msg.getAny()) && google_protobuf_empty_pb.Empty.toObject(includeInstance, f), streamExists: (f = msg.getStreamExists()) && google_protobuf_empty_pb.Empty.toObject(includeInstance, f), - deadline: (f = msg.getDeadline()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f) + deadline21100: (f = msg.getDeadline21100()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), + deadline: (f = msg.getDeadline()) && google_protobuf_duration_pb.Duration.toObject(includeInstance, f) }; if (includeInstance) { @@ -8099,6 +8650,11 @@ proto.event_store.client.streams.BatchAppendReq.Options.deserializeBinaryFromRea case 6: var value = new google_protobuf_timestamp_pb.Timestamp; reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setDeadline21100(value); + break; + case 7: + var value = new google_protobuf_duration_pb.Duration; + reader.readMessage(value,google_protobuf_duration_pb.Duration.deserializeBinaryFromReader); msg.setDeadline(value); break; default: @@ -8169,7 +8725,7 @@ proto.event_store.client.streams.BatchAppendReq.Options.serializeBinaryToWriter google_protobuf_empty_pb.Empty.serializeBinaryToWriter ); } - f = message.getDeadline(); + f = message.getDeadline21100(); if (f != null) { writer.writeMessage( 6, @@ -8177,6 +8733,14 @@ proto.event_store.client.streams.BatchAppendReq.Options.serializeBinaryToWriter google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter ); } + f = message.getDeadline(); + if (f != null) { + writer.writeMessage( + 7, + f, + google_protobuf_duration_pb.Duration.serializeBinaryToWriter + ); + } }; @@ -8365,10 +8929,10 @@ proto.event_store.client.streams.BatchAppendReq.Options.prototype.hasStreamExist /** - * optional google.protobuf.Timestamp deadline = 6; + * optional google.protobuf.Timestamp deadline_21_10_0 = 6; * @return {?proto.google.protobuf.Timestamp} */ -proto.event_store.client.streams.BatchAppendReq.Options.prototype.getDeadline = function() { +proto.event_store.client.streams.BatchAppendReq.Options.prototype.getDeadline21100 = function() { return /** @type{?proto.google.protobuf.Timestamp} */ ( jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 6)); }; @@ -8378,8 +8942,45 @@ proto.event_store.client.streams.BatchAppendReq.Options.prototype.getDeadline = * @param {?proto.google.protobuf.Timestamp|undefined} value * @return {!proto.event_store.client.streams.BatchAppendReq.Options} returns this */ +proto.event_store.client.streams.BatchAppendReq.Options.prototype.setDeadline21100 = function(value) { + return jspb.Message.setOneofWrapperField(this, 6, proto.event_store.client.streams.BatchAppendReq.Options.oneofGroups_[1], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.event_store.client.streams.BatchAppendReq.Options} returns this + */ +proto.event_store.client.streams.BatchAppendReq.Options.prototype.clearDeadline21100 = function() { + return this.setDeadline21100(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.event_store.client.streams.BatchAppendReq.Options.prototype.hasDeadline21100 = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional google.protobuf.Duration deadline = 7; + * @return {?proto.google.protobuf.Duration} + */ +proto.event_store.client.streams.BatchAppendReq.Options.prototype.getDeadline = function() { + return /** @type{?proto.google.protobuf.Duration} */ ( + jspb.Message.getWrapperField(this, google_protobuf_duration_pb.Duration, 7)); +}; + + +/** + * @param {?proto.google.protobuf.Duration|undefined} value + * @return {!proto.event_store.client.streams.BatchAppendReq.Options} returns this +*/ proto.event_store.client.streams.BatchAppendReq.Options.prototype.setDeadline = function(value) { - return jspb.Message.setWrapperField(this, 6, value); + return jspb.Message.setOneofWrapperField(this, 7, proto.event_store.client.streams.BatchAppendReq.Options.oneofGroups_[1], value); }; @@ -8397,7 +8998,7 @@ proto.event_store.client.streams.BatchAppendReq.Options.prototype.clearDeadline * @return {boolean} */ proto.event_store.client.streams.BatchAppendReq.Options.prototype.hasDeadline = function() { - return jspb.Message.getField(this, 6) != null; + return jspb.Message.getField(this, 7) != null; }; diff --git a/packages/db-client/protos/streams.proto b/packages/db-client/protos/streams.proto index 3fcca639..800f0768 100644 --- a/packages/db-client/protos/streams.proto +++ b/packages/db-client/protos/streams.proto @@ -1,315 +1,353 @@ -syntax = "proto3"; -package event_store.client.streams; -option java_package = "com.eventstore.dbclient.proto.streams"; - -import "shared.proto"; -import "status.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; - -service Streams { - rpc Read (ReadReq) returns (stream ReadResp); - rpc Append (stream AppendReq) returns (AppendResp); - rpc Delete (DeleteReq) returns (DeleteResp); - rpc Tombstone (TombstoneReq) returns (TombstoneResp); - rpc BatchAppend (stream BatchAppendReq) returns (stream BatchAppendResp); -} - -message ReadReq { - Options options = 1; - - message Options { - oneof stream_option { - StreamOptions stream = 1; - AllOptions all = 2; - } - ReadDirection read_direction = 3; - bool resolve_links = 4; - oneof count_option { - uint64 count = 5 [jstype = JS_STRING]; - SubscriptionOptions subscription = 6; - } - oneof filter_option { - FilterOptions filter = 7; - event_store.client.Empty no_filter = 8; - } - UUIDOption uuid_option = 9; - ControlOption control_option = 10 [deprecated = true]; - - enum ReadDirection { - Forwards = 0; - Backwards = 1; - } - message StreamOptions { - event_store.client.StreamIdentifier stream_identifier = 1; - oneof revision_option { - uint64 revision = 2 [jstype = JS_STRING]; - event_store.client.Empty start = 3; - event_store.client.Empty end = 4; - } - } - message AllOptions { - oneof all_option { - Position position = 1; - event_store.client.Empty start = 2; - event_store.client.Empty end = 3; - } - } - message SubscriptionOptions { - } - message Position { - uint64 commit_position = 1 [jstype = JS_STRING]; - uint64 prepare_position = 2 [jstype = JS_STRING]; - } - message FilterOptions { - oneof filter { - Expression stream_identifier = 1; - Expression event_type = 2; - } - oneof window { - uint32 max = 3; - event_store.client.Empty count = 4; - } - uint32 checkpointIntervalMultiplier = 5; - - message Expression { - string regex = 1; - repeated string prefix = 2; - } - } - message UUIDOption { - oneof content { - event_store.client.Empty structured = 1; - event_store.client.Empty string = 2; - } - } - message ControlOption { - option deprecated = true; - - uint32 compatibility = 1; - } - } -} - -message ReadResp { - oneof content { - ReadEvent event = 1; - SubscriptionConfirmation confirmation = 2; - Checkpoint checkpoint = 3; - StreamNotFound stream_not_found = 4; - uint64 first_stream_position = 5 [jstype = JS_STRING, deprecated = true]; - uint64 last_stream_position = 6 [jstype = JS_STRING, deprecated = true]; - AllStreamPosition last_all_stream_position = 7 [deprecated = true]; - CaughtUp caught_up = 8; - FellBehind fell_behind = 9; - } - - message CaughtUp {} - - message FellBehind {} - - message ReadEvent { - RecordedEvent event = 1; - RecordedEvent link = 2; - oneof position { - uint64 commit_position = 3 [jstype = JS_STRING]; - event_store.client.Empty no_position = 4; - } - - message RecordedEvent { - event_store.client.UUID id = 1; - event_store.client.StreamIdentifier stream_identifier = 2; - uint64 stream_revision = 3 [jstype = JS_STRING]; - uint64 prepare_position = 4 [jstype = JS_STRING]; - uint64 commit_position = 5 [jstype = JS_STRING]; - map metadata = 6; - bytes custom_metadata = 7; - bytes data = 8; - } - } - message SubscriptionConfirmation { - string subscription_id = 1; - } - message Checkpoint { - uint64 commit_position = 1 [jstype = JS_STRING]; - uint64 prepare_position = 2 [jstype = JS_STRING]; - } - message StreamNotFound { - event_store.client.StreamIdentifier stream_identifier = 1; - } -} - -message AppendReq { - oneof content { - Options options = 1; - ProposedMessage proposed_message = 2; - } - - message Options { - event_store.client.StreamIdentifier stream_identifier = 1; - oneof expected_stream_revision { - uint64 revision = 2 [jstype = JS_STRING]; - event_store.client.Empty no_stream = 3; - event_store.client.Empty any = 4; - event_store.client.Empty stream_exists = 5; - } - } - message ProposedMessage { - event_store.client.UUID id = 1; - map metadata = 2; - bytes custom_metadata = 3; - bytes data = 4; - } -} - -message AppendResp { - oneof result { - Success success = 1; - WrongExpectedVersion wrong_expected_version = 2; - } - - message Position { - uint64 commit_position = 1 [jstype = JS_STRING]; - uint64 prepare_position = 2 [jstype = JS_STRING]; - } - - message Success { - oneof current_revision_option { - uint64 current_revision = 1 [jstype = JS_STRING]; - event_store.client.Empty no_stream = 2; - } - oneof position_option { - Position position = 3; - event_store.client.Empty no_position = 4; - } - } - - message WrongExpectedVersion { - oneof current_revision_option_20_6_0 { - uint64 current_revision_20_6_0 = 1 [deprecated = true]; - event_store.client.Empty no_stream_20_6_0 = 2 [deprecated = true]; - } - oneof expected_revision_option_20_6_0 { - uint64 expected_revision_20_6_0 = 3 [deprecated = true]; - event_store.client.Empty any_20_6_0 = 4 [deprecated = true]; - event_store.client.Empty stream_exists_20_6_0 = 5 [deprecated = true]; - } - oneof current_revision_option { - uint64 current_revision = 6 [jstype = JS_STRING]; - event_store.client.Empty current_no_stream = 7; - } - oneof expected_revision_option { - uint64 expected_revision = 8 [jstype = JS_STRING]; - event_store.client.Empty expected_any = 9; - event_store.client.Empty expected_stream_exists = 10; - event_store.client.Empty expected_no_stream = 11; - } - - } -} - -message BatchAppendReq { - event_store.client.UUID correlation_id = 1; - Options options = 2; - repeated ProposedMessage proposed_messages = 3; - bool is_final = 4; - - message Options { - event_store.client.StreamIdentifier stream_identifier = 1; - oneof expected_stream_position { - uint64 stream_position = 2 [jstype = JS_STRING]; - google.protobuf.Empty no_stream = 3; - google.protobuf.Empty any = 4; - google.protobuf.Empty stream_exists = 5; - } - google.protobuf.Timestamp deadline = 6; - } - - message ProposedMessage { - event_store.client.UUID id = 1; - map metadata = 2; - bytes custom_metadata = 3; - bytes data = 4; - } -} - -message BatchAppendResp { - event_store.client.UUID correlation_id = 1; - oneof result { - google.rpc.Status error = 2; - Success success = 3; - } - - event_store.client.StreamIdentifier stream_identifier = 4; - - oneof expected_stream_position { - uint64 stream_position = 5 [jstype = JS_STRING]; - google.protobuf.Empty no_stream = 6; - google.protobuf.Empty any = 7; - google.protobuf.Empty stream_exists = 8; - } - - message Success { - oneof current_revision_option { - uint64 current_revision = 1 [jstype = JS_STRING]; - google.protobuf.Empty no_stream = 2; - } - oneof position_option { - event_store.client.AllStreamPosition position = 3; - google.protobuf.Empty no_position = 4; - } - } -} - -message DeleteReq { - Options options = 1; - - message Options { - event_store.client.StreamIdentifier stream_identifier = 1; - oneof expected_stream_revision { - uint64 revision = 2 [jstype = JS_STRING]; - event_store.client.Empty no_stream = 3; - event_store.client.Empty any = 4; - event_store.client.Empty stream_exists = 5; - } - } -} - -message DeleteResp { - oneof position_option { - Position position = 1; - event_store.client.Empty no_position = 2; - } - - message Position { - uint64 commit_position = 1 [jstype = JS_STRING]; - uint64 prepare_position = 2 [jstype = JS_STRING]; - } -} - -message TombstoneReq { - Options options = 1; - - message Options { - event_store.client.StreamIdentifier stream_identifier = 1; - oneof expected_stream_revision { - uint64 revision = 2 [jstype = JS_STRING]; - event_store.client.Empty no_stream = 3; - event_store.client.Empty any = 4; - event_store.client.Empty stream_exists = 5; - } - } -} - -message TombstoneResp { - oneof position_option { - Position position = 1; - event_store.client.Empty no_position = 2; - } - - message Position { - uint64 commit_position = 1 [jstype = JS_STRING]; - uint64 prepare_position = 2 [jstype = JS_STRING]; - } -} - +syntax = "proto3"; +package event_store.client.streams; +option java_package = "com.eventstore.dbclient.proto.streams"; + +import "shared.proto"; +import "status.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; + +service Streams { + rpc Read (ReadReq) returns (stream ReadResp); + rpc Append (stream AppendReq) returns (AppendResp); + rpc Delete (DeleteReq) returns (DeleteResp); + rpc Tombstone (TombstoneReq) returns (TombstoneResp); + rpc BatchAppend (stream BatchAppendReq) returns (stream BatchAppendResp); +} + +message ReadReq { + Options options = 1; + + message Options { + oneof stream_option { + StreamOptions stream = 1; + AllOptions all = 2; + } + ReadDirection read_direction = 3; + bool resolve_links = 4; + oneof count_option { + uint64 count = 5 [jstype = JS_STRING]; + SubscriptionOptions subscription = 6; + } + oneof filter_option { + FilterOptions filter = 7; + event_store.client.Empty no_filter = 8; + } + UUIDOption uuid_option = 9; + ControlOption control_option = 10 [deprecated = true]; + + enum ReadDirection { + Forwards = 0; + Backwards = 1; + } + message StreamOptions { + event_store.client.StreamIdentifier stream_identifier = 1; + oneof revision_option { + uint64 revision = 2 [jstype = JS_STRING]; + event_store.client.Empty start = 3; + event_store.client.Empty end = 4; + } + } + message AllOptions { + oneof all_option { + Position position = 1; + event_store.client.Empty start = 2; + event_store.client.Empty end = 3; + } + } + message SubscriptionOptions { + } + message Position { + uint64 commit_position = 1 [jstype = JS_STRING]; + uint64 prepare_position = 2 [jstype = JS_STRING]; + } + message FilterOptions { + oneof filter { + Expression stream_identifier = 1; + Expression event_type = 2; + } + oneof window { + uint32 max = 3; + event_store.client.Empty count = 4; + } + uint32 checkpointIntervalMultiplier = 5; + + message Expression { + string regex = 1; + repeated string prefix = 2; + } + } + message UUIDOption { + oneof content { + event_store.client.Empty structured = 1; + event_store.client.Empty string = 2; + } + } + message ControlOption { + uint32 compatibility = 1; + } + } +} + +message ReadResp { + oneof content { + ReadEvent event = 1; + SubscriptionConfirmation confirmation = 2; + Checkpoint checkpoint = 3; + StreamNotFound stream_not_found = 4; + uint64 first_stream_position = 5 [jstype = JS_STRING, deprecated = true]; + uint64 last_stream_position = 6 [jstype = JS_STRING, deprecated = true]; + AllStreamPosition last_all_stream_position = 7 [deprecated = true]; + CaughtUp caught_up = 8; + FellBehind fell_behind = 9; + } + + // The $all or stream subscription has caught up and become live. + message CaughtUp { + // Current time in the server when the subscription caught up + google.protobuf.Timestamp timestamp = 1; + + // Checkpoint for resuming a stream subscription. + // For stream subscriptions it is populated unless the stream is empty. + // For $all subscriptions it is not populated. + optional int64 stream_revision = 2 [jstype = JS_STRING]; + + // Checkpoint for resuming a $all subscription. + // For stream subscriptions it is not populated. + // For $all subscriptions it is populated unless the database is empty. + optional Position position = 3; + } + + // The $all or stream subscription has fallen back into catchup mode and is no longer live. + message FellBehind { + // Current time in the server when the subscription fell behind + google.protobuf.Timestamp timestamp = 1; + + // Checkpoint for resuming a stream subscription. + // For stream subscriptions it is populated unless the stream is empty. + // For $all subscriptions it is not populated. + optional int64 stream_revision = 2 [jstype = JS_STRING]; + + // Checkpoint for resuming a $all subscription. + // For stream subscriptions it is not populated. + // For $all subscriptions it is populated unless the database is empty. + optional Position position = 3; + } + + message ReadEvent { + RecordedEvent event = 1; + RecordedEvent link = 2; + oneof position { + uint64 commit_position = 3 [jstype = JS_STRING]; + event_store.client.Empty no_position = 4; + } + + message RecordedEvent { + event_store.client.UUID id = 1; + event_store.client.StreamIdentifier stream_identifier = 2; + uint64 stream_revision = 3 [jstype = JS_STRING]; + uint64 prepare_position = 4 [jstype = JS_STRING]; + uint64 commit_position = 5 [jstype = JS_STRING]; + map metadata = 6; + bytes custom_metadata = 7; + bytes data = 8; + } + } + message SubscriptionConfirmation { + string subscription_id = 1; + } + message Checkpoint { + uint64 commit_position = 1 [jstype = JS_STRING]; + uint64 prepare_position = 2 [jstype = JS_STRING]; + + // Current time in the server when the checkpoint was reached + google.protobuf.Timestamp timestamp = 3; + } + + message Position { + uint64 commit_position = 1 [jstype = JS_STRING]; + uint64 prepare_position = 2 [jstype = JS_STRING]; + } + + message StreamNotFound { + event_store.client.StreamIdentifier stream_identifier = 1; + } +} + +message AppendReq { + oneof content { + Options options = 1; + ProposedMessage proposed_message = 2; + } + + message Options { + event_store.client.StreamIdentifier stream_identifier = 1; + oneof expected_stream_revision { + uint64 revision = 2 [jstype = JS_STRING]; + event_store.client.Empty no_stream = 3; + event_store.client.Empty any = 4; + event_store.client.Empty stream_exists = 5; + } + } + message ProposedMessage { + event_store.client.UUID id = 1; + map metadata = 2; + bytes custom_metadata = 3; + bytes data = 4; + } +} + +message AppendResp { + oneof result { + Success success = 1; + WrongExpectedVersion wrong_expected_version = 2; + } + + message Position { + uint64 commit_position = 1 [jstype = JS_STRING]; + uint64 prepare_position = 2 [jstype = JS_STRING]; + } + + message Success { + oneof current_revision_option { + uint64 current_revision = 1 [jstype = JS_STRING]; + event_store.client.Empty no_stream = 2; + } + oneof position_option { + Position position = 3; + event_store.client.Empty no_position = 4; + } + } + + message WrongExpectedVersion { + oneof current_revision_option_20_6_0 { + uint64 current_revision_20_6_0 = 1 [deprecated = true]; + event_store.client.Empty no_stream_20_6_0 = 2 [deprecated = true]; + } + oneof expected_revision_option_20_6_0 { + uint64 expected_revision_20_6_0 = 3 [deprecated = true]; + event_store.client.Empty any_20_6_0 = 4 [deprecated = true]; + event_store.client.Empty stream_exists_20_6_0 = 5 [deprecated = true]; + } + oneof current_revision_option { + uint64 current_revision = 6 [jstype = JS_STRING]; + event_store.client.Empty current_no_stream = 7; + } + oneof expected_revision_option { + uint64 expected_revision = 8 [jstype = JS_STRING]; + event_store.client.Empty expected_any = 9; + event_store.client.Empty expected_stream_exists = 10; + event_store.client.Empty expected_no_stream = 11; + } + + } +} + +message BatchAppendReq { + event_store.client.UUID correlation_id = 1; + Options options = 2; + repeated ProposedMessage proposed_messages = 3; + bool is_final = 4; + + message Options { + event_store.client.StreamIdentifier stream_identifier = 1; + oneof expected_stream_position { + uint64 stream_position = 2 [jstype = JS_STRING]; + google.protobuf.Empty no_stream = 3; + google.protobuf.Empty any = 4; + google.protobuf.Empty stream_exists = 5; + } + oneof deadline_option { + google.protobuf.Timestamp deadline_21_10_0 = 6; + google.protobuf.Duration deadline = 7; + } + } + + message ProposedMessage { + event_store.client.UUID id = 1; + map metadata = 2; + bytes custom_metadata = 3; + bytes data = 4; + } +} + +message BatchAppendResp { + event_store.client.UUID correlation_id = 1; + oneof result { + google.rpc.Status error = 2; + Success success = 3; + } + + event_store.client.StreamIdentifier stream_identifier = 4; + + oneof expected_stream_position { + uint64 stream_position = 5 [jstype = JS_STRING]; + google.protobuf.Empty no_stream = 6; + google.protobuf.Empty any = 7; + google.protobuf.Empty stream_exists = 8; + } + + message Success { + oneof current_revision_option { + uint64 current_revision = 1 [jstype = JS_STRING]; + google.protobuf.Empty no_stream = 2; + } + oneof position_option { + event_store.client.AllStreamPosition position = 3; + google.protobuf.Empty no_position = 4; + } + } +} + +message DeleteReq { + Options options = 1; + + message Options { + event_store.client.StreamIdentifier stream_identifier = 1; + oneof expected_stream_revision { + uint64 revision = 2 [jstype = JS_STRING]; + event_store.client.Empty no_stream = 3; + event_store.client.Empty any = 4; + event_store.client.Empty stream_exists = 5; + } + } +} + +message DeleteResp { + oneof position_option { + Position position = 1; + event_store.client.Empty no_position = 2; + } + + message Position { + uint64 commit_position = 1 [jstype = JS_STRING]; + uint64 prepare_position = 2 [jstype = JS_STRING]; + } +} + +message TombstoneReq { + Options options = 1; + + message Options { + event_store.client.StreamIdentifier stream_identifier = 1; + oneof expected_stream_revision { + uint64 revision = 2 [jstype = JS_STRING]; + event_store.client.Empty no_stream = 3; + event_store.client.Empty any = 4; + event_store.client.Empty stream_exists = 5; + } + } +} + +message TombstoneResp { + oneof position_option { + Position position = 1; + event_store.client.Empty no_position = 2; + } + + message Position { + uint64 commit_position = 1 [jstype = JS_STRING]; + uint64 prepare_position = 2 [jstype = JS_STRING]; + } +} diff --git a/packages/db-client/src/streams/appendToStream/batchAppend.ts b/packages/db-client/src/streams/appendToStream/batchAppend.ts index ff359fbd..4407e261 100644 --- a/packages/db-client/src/streams/appendToStream/batchAppend.ts +++ b/packages/db-client/src/streams/appendToStream/batchAppend.ts @@ -129,7 +129,7 @@ export const batchAppend = async function ( ); options.setStreamIdentifier(identifier); - options.setDeadline(deadline); + options.setDeadline21100(deadline); switch (streamState) { case "any": { diff --git a/packages/db-client/src/streams/utils/Subscription.ts b/packages/db-client/src/streams/utils/Subscription.ts index cdee322f..e401b159 100644 --- a/packages/db-client/src/streams/utils/Subscription.ts +++ b/packages/db-client/src/streams/utils/Subscription.ts @@ -4,7 +4,13 @@ import type { ClientReadableStream, ServiceError } from "@grpc/grpc-js"; import type { ReadResp } from "../../../generated/streams_pb"; -import type { Filter, Position, ReadableSubscription } from "../../types"; +import type { + CaughtUp, + FellBehind, + Filter, + Position, + ReadableSubscription, +} from "../../types"; import { ConvertGrpcEvent, convertToCommandError, @@ -60,11 +66,43 @@ export class Subscription } if (resp.hasCaughtUp?.()) { - this.emit("caughtUp"); + const info: CaughtUp = {}; + const grpc = resp.getCaughtUp()!; + + if (grpc.hasTimestamp()) { + info.date = grpc.getTimestamp()!.toDate(); + if (grpc.hasStreamRevision()) { + info.revision = BigInt(grpc.getStreamRevision()!); + } else if (grpc.hasPosition()) { + const position = grpc.getPosition()!; + info.position = { + commit: BigInt(position.getCommitPosition()), + prepare: BigInt(position.getPreparePosition()), + }; + } + } + + this.emit("caughtUp", info); } if (resp.hasFellBehind?.()) { - this.emit("fellBehind"); + const info: FellBehind = {}; + const grpc = resp.getFellBehind()!; + + if (grpc.hasTimestamp()) { + info.date = grpc.getTimestamp()!.toDate(); + if (grpc.hasStreamRevision()) { + info.revision = BigInt(grpc.getStreamRevision()!); + } else if (grpc.hasPosition()) { + const position = grpc.getPosition()!; + info.position = { + commit: BigInt(position.getCommitPosition()), + prepare: BigInt(position.getPreparePosition()), + }; + } + } + + this.emit("fellBehind", info); } if (resp.hasCheckpoint?.() && this.#checkpointReached) { diff --git a/packages/db-client/src/types/index.ts b/packages/db-client/src/types/index.ts index c17c7de3..6047d43f 100644 --- a/packages/db-client/src/types/index.ts +++ b/packages/db-client/src/types/index.ts @@ -479,25 +479,85 @@ export interface PersistentSubscriptionBase extends ReadableSubscription { ): Promise; } +/** + * The $all or stream subscription has caught up and become live. + */ +export interface CaughtUp { + /** + * Current time in the server when the subscription caught up. + */ + date?: Date; + + /** + * Checkpoint for resuming a stream subscription. + * For stream subscriptions it is populated unless the stream is empty. + * For $all subscriptions it is not populated. + */ + revision?: bigint; + + /** + * Checkpoint for resuming a $all subscription. + * For stream subscriptions it is not populated. + * For $all subscriptions it is populated unless the database is empty. + */ + position?: Position; +} + +/** + * The $all or stream subscription has fallen back into catchup mode and is no longer live. + */ +export interface FellBehind { + /** + * Current time in the server when the subscription fell behind. + */ + date?: Date; + + /** + * Checkpoint for resuming a stream subscription. + * For stream subscriptions it is populated unless the stream is empty. + * For $all subscriptions it is not populated. + */ + revision?: bigint; + + /** + * Checkpoint for resuming an $all subscription. + * For stream subscriptions it is not populated. + * For $all subscriptions it is populated unless the database is empty. + */ + position?: Position; +} + // Other listeners that are only supported in catch-up subscriptions export interface CatchupSubscription { - addListener(event: "caughtUp", listener: () => void): this; - addListener(event: "fellBehind", listener: () => void): this; + addListener(event: "caughtUp", listener: (info: CaughtUp) => void): this; + addListener(event: "fellBehind", listener: (info: FellBehind) => void): this; - on(event: "caughtUp", listener: () => void): this; - on(event: "fellBehind", listener: () => void): this; + on(event: "caughtUp", listener: (info: CaughtUp) => void): this; + on(event: "fellBehind", listener: (info: FellBehind) => void): this; - once(event: "caughtUp", listener: () => void): this; - once(event: "fellBehind", listener: () => void): this; + once(event: "caughtUp", listener: (info: CaughtUp) => void): this; + once(event: "fellBehind", listener: (info: FellBehind) => void): this; - prependListener(event: "caughtUp", listener: () => void): this; - prependListener(event: "fellBehind", listener: () => void): this; + prependListener(event: "caughtUp", listener: (info: CaughtUp) => void): this; + prependListener( + event: "fellBehind", + listener: (info: FellBehind) => void + ): this; - prependOnceListener(event: "caughtUp", listener: () => void): this; - prependOnceListener(event: "fellBehind", listener: () => void): this; + prependOnceListener( + event: "caughtUp", + listener: (info: CaughtUp) => void + ): this; + prependOnceListener( + event: "fellBehind", + listener: (info: FellBehind) => void + ): this; - removeListener(event: "caughtUp", listener: () => void): this; - removeListener(event: "fellBehind", listener: () => void): this; + removeListener(event: "caughtUp", listener: (info: CaughtUp) => void): this; + removeListener( + event: "fellBehind", + listener: (info: FellBehind) => void + ): this; } export type PersistentSubscriptionToStream =