Skip to content

Commit

Permalink
Update yorkie.proto changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins authored and parkeunae committed Jul 23, 2022
1 parent 15f2268 commit d09c255
Show file tree
Hide file tree
Showing 6 changed files with 947 additions and 385 deletions.
31 changes: 23 additions & 8 deletions src/api/yorkie.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ service Yorkie {
rpc PushPull (PushPullRequest) returns (PushPullResponse) {}
}

service Cluster {
rpc BroadcastEvent (BroadcastEventRequest) returns (BroadcastEventResponse) {}
}

/////////////////////////////////////////
// Messages for Cluster //
/////////////////////////////////////////

message BroadcastEventRequest {
bytes publisher_id = 1;
DocEvent event = 2;
}

message BroadcastEventResponse {}

/////////////////////////////////////////
// Messages for RPC //
/////////////////////////////////////////
Expand Down Expand Up @@ -78,15 +93,9 @@ message WatchDocumentsResponse {
map<string, Clients> peers_map_by_doc = 1;
}

message Event {
Client client = 1;
EventType event_type = 2;
repeated DocumentKey document_keys = 3;
}

oneof body {
Initialization initialization = 1;
Event event = 2;
DocEvent event = 2;
}
}

Expand Down Expand Up @@ -348,8 +357,14 @@ enum ValueType {
DOUBLE_CNT = 14;
}

enum EventType {
enum DocEventType {
DOCUMENTS_CHANGED = 0;
DOCUMENTS_WATCHED = 1;
DOCUMENTS_UNWATCHED = 2;
}

message DocEvent {
DocEventType type = 1;
Client publisher = 2;
repeated DocumentKey document_keys = 3;
}
26 changes: 26 additions & 0 deletions src/api/yorkie_grpc_web_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ export class YorkieClient {

}

export class ClusterClient {
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: any; });

broadcastEvent(
request: src_api_yorkie_pb.BroadcastEventRequest,
metadata: grpcWeb.Metadata | undefined,
callback: (err: grpcWeb.Error,
response: src_api_yorkie_pb.BroadcastEventResponse) => void
): grpcWeb.ClientReadableStream<src_api_yorkie_pb.BroadcastEventResponse>;

}

export class YorkiePromiseClient {
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
Expand Down Expand Up @@ -87,3 +101,15 @@ export class YorkiePromiseClient {

}

export class ClusterPromiseClient {
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: any; });

broadcastEvent(
request: src_api_yorkie_pb.BroadcastEventRequest,
metadata?: grpcWeb.Metadata
): Promise<src_api_yorkie_pb.BroadcastEventResponse>;

}

132 changes: 132 additions & 0 deletions src/api/yorkie_grpc_web_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,5 +545,137 @@ proto.api.YorkiePromiseClient.prototype.pushPull =
};


/**
* @param {string} hostname
* @param {?Object} credentials
* @param {?Object} options
* @constructor
* @struct
* @final
*/
proto.api.ClusterClient =
function(hostname, credentials, options) {
if (!options) options = {};
options['format'] = 'text';

/**
* @private @const {!grpc.web.GrpcWebClientBase} The client
*/
this.client_ = new grpc.web.GrpcWebClientBase(options);

/**
* @private @const {string} The hostname
*/
this.hostname_ = hostname;

};


/**
* @param {string} hostname
* @param {?Object} credentials
* @param {?Object} options
* @constructor
* @struct
* @final
*/
proto.api.ClusterPromiseClient =
function(hostname, credentials, options) {
if (!options) options = {};
options['format'] = 'text';

/**
* @private @const {!grpc.web.GrpcWebClientBase} The client
*/
this.client_ = new grpc.web.GrpcWebClientBase(options);

/**
* @private @const {string} The hostname
*/
this.hostname_ = hostname;

};


/**
* @const
* @type {!grpc.web.MethodDescriptor<
* !proto.api.BroadcastEventRequest,
* !proto.api.BroadcastEventResponse>}
*/
const methodDescriptor_Cluster_BroadcastEvent = new grpc.web.MethodDescriptor(
'/api.Cluster/BroadcastEvent',
grpc.web.MethodType.UNARY,
proto.api.BroadcastEventRequest,
proto.api.BroadcastEventResponse,
/**
* @param {!proto.api.BroadcastEventRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.api.BroadcastEventResponse.deserializeBinary
);


/**
* @const
* @type {!grpc.web.AbstractClientBase.MethodInfo<
* !proto.api.BroadcastEventRequest,
* !proto.api.BroadcastEventResponse>}
*/
const methodInfo_Cluster_BroadcastEvent = new grpc.web.AbstractClientBase.MethodInfo(
proto.api.BroadcastEventResponse,
/**
* @param {!proto.api.BroadcastEventRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.api.BroadcastEventResponse.deserializeBinary
);


/**
* @param {!proto.api.BroadcastEventRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @param {function(?grpc.web.Error, ?proto.api.BroadcastEventResponse)}
* callback The callback function(error, response)
* @return {!grpc.web.ClientReadableStream<!proto.api.BroadcastEventResponse>|undefined}
* The XHR Node Readable Stream
*/
proto.api.ClusterClient.prototype.broadcastEvent =
function(request, metadata, callback) {
return this.client_.rpcCall(this.hostname_ +
'/api.Cluster/BroadcastEvent',
request,
metadata || {},
methodDescriptor_Cluster_BroadcastEvent,
callback);
};


/**
* @param {!proto.api.BroadcastEventRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @return {!Promise<!proto.api.BroadcastEventResponse>}
* Promise that resolves to the response
*/
proto.api.ClusterPromiseClient.prototype.broadcastEvent =
function(request, metadata) {
return this.client_.unaryCall(this.hostname_ +
'/api.Cluster/BroadcastEvent',
request,
metadata || {},
methodDescriptor_Cluster_BroadcastEvent);
};


module.exports = proto.api;

109 changes: 74 additions & 35 deletions src/api/yorkie_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@ import * as jspb from 'google-protobuf'



export class BroadcastEventRequest extends jspb.Message {
getPublisherId(): Uint8Array | string;
getPublisherId_asU8(): Uint8Array;
getPublisherId_asB64(): string;
setPublisherId(value: Uint8Array | string): BroadcastEventRequest;

getEvent(): DocEvent | undefined;
setEvent(value?: DocEvent): BroadcastEventRequest;
hasEvent(): boolean;
clearEvent(): BroadcastEventRequest;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): BroadcastEventRequest.AsObject;
static toObject(includeInstance: boolean, msg: BroadcastEventRequest): BroadcastEventRequest.AsObject;
static serializeBinaryToWriter(message: BroadcastEventRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): BroadcastEventRequest;
static deserializeBinaryFromReader(message: BroadcastEventRequest, reader: jspb.BinaryReader): BroadcastEventRequest;
}

export namespace BroadcastEventRequest {
export type AsObject = {
publisherId: Uint8Array | string,
event?: DocEvent.AsObject,
}
}

export class BroadcastEventResponse extends jspb.Message {
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): BroadcastEventResponse.AsObject;
static toObject(includeInstance: boolean, msg: BroadcastEventResponse): BroadcastEventResponse.AsObject;
static serializeBinaryToWriter(message: BroadcastEventResponse, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): BroadcastEventResponse;
static deserializeBinaryFromReader(message: BroadcastEventResponse, reader: jspb.BinaryReader): BroadcastEventResponse;
}

export namespace BroadcastEventResponse {
export type AsObject = {
}
}

export class ActivateClientRequest extends jspb.Message {
getClientKey(): string;
setClientKey(value: string): ActivateClientRequest;
Expand Down Expand Up @@ -218,8 +258,8 @@ export class WatchDocumentsResponse extends jspb.Message {
hasInitialization(): boolean;
clearInitialization(): WatchDocumentsResponse;

getEvent(): WatchDocumentsResponse.Event | undefined;
setEvent(value?: WatchDocumentsResponse.Event): WatchDocumentsResponse;
getEvent(): DocEvent | undefined;
setEvent(value?: DocEvent): WatchDocumentsResponse;
hasEvent(): boolean;
clearEvent(): WatchDocumentsResponse;

Expand All @@ -236,7 +276,7 @@ export class WatchDocumentsResponse extends jspb.Message {
export namespace WatchDocumentsResponse {
export type AsObject = {
initialization?: WatchDocumentsResponse.Initialization.AsObject,
event?: WatchDocumentsResponse.Event.AsObject,
event?: DocEvent.AsObject,
}

export class Initialization extends jspb.Message {
Expand All @@ -258,37 +298,6 @@ export namespace WatchDocumentsResponse {
}


export class Event extends jspb.Message {
getClient(): Client | undefined;
setClient(value?: Client): Event;
hasClient(): boolean;
clearClient(): Event;

getEventType(): EventType;
setEventType(value: EventType): Event;

getDocumentKeysList(): Array<DocumentKey>;
setDocumentKeysList(value: Array<DocumentKey>): Event;
clearDocumentKeysList(): Event;
addDocumentKeys(value?: DocumentKey, index?: number): DocumentKey;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Event.AsObject;
static toObject(includeInstance: boolean, msg: Event): Event.AsObject;
static serializeBinaryToWriter(message: Event, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): Event;
static deserializeBinaryFromReader(message: Event, reader: jspb.BinaryReader): Event;
}

export namespace Event {
export type AsObject = {
client?: Client.AsObject,
eventType: EventType,
documentKeysList: Array<DocumentKey.AsObject>,
}
}


export enum BodyCase {
BODY_NOT_SET = 0,
INITIALIZATION = 1,
Expand Down Expand Up @@ -1562,6 +1571,36 @@ export namespace TimeTicket {
}
}

export class DocEvent extends jspb.Message {
getType(): DocEventType;
setType(value: DocEventType): DocEvent;

getPublisher(): Client | undefined;
setPublisher(value?: Client): DocEvent;
hasPublisher(): boolean;
clearPublisher(): DocEvent;

getDocumentKeysList(): Array<DocumentKey>;
setDocumentKeysList(value: Array<DocumentKey>): DocEvent;
clearDocumentKeysList(): DocEvent;
addDocumentKeys(value?: DocumentKey, index?: number): DocumentKey;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): DocEvent.AsObject;
static toObject(includeInstance: boolean, msg: DocEvent): DocEvent.AsObject;
static serializeBinaryToWriter(message: DocEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): DocEvent;
static deserializeBinaryFromReader(message: DocEvent, reader: jspb.BinaryReader): DocEvent;
}

export namespace DocEvent {
export type AsObject = {
type: DocEventType,
publisher?: Client.AsObject,
documentKeysList: Array<DocumentKey.AsObject>,
}
}

export enum ValueType {
NULL = 0,
BOOLEAN = 1,
Expand All @@ -1579,7 +1618,7 @@ export enum ValueType {
LONG_CNT = 13,
DOUBLE_CNT = 14,
}
export enum EventType {
export enum DocEventType {
DOCUMENTS_CHANGED = 0,
DOCUMENTS_WATCHED = 1,
DOCUMENTS_UNWATCHED = 2,
Expand Down
Loading

0 comments on commit d09c255

Please sign in to comment.