Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add opt to remove TypeInstance's revision, fix update mutation #698

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions hub-js/proto/storage_backend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ message OnDeleteRequest {

message OnDeleteResponse {}

message OnDeleteRevisionRequest {
string type_instance_id = 1;
optional string owner_id = 3;
uint32 resource_version = 4;
}

message OnDeleteRevisionValueAndContextRequest {
string type_instance_id = 1;
optional bytes context = 2;
optional string owner_id = 3;
uint32 resource_version = 4;
}

message OnDeleteRevisionResponse {}

message GetValueRequest {
string type_instance_id = 1;
uint32 resource_version = 2;
Expand Down Expand Up @@ -110,6 +125,7 @@ service ValueAndContextStorageBackend {
rpc OnCreate(OnCreateValueAndContextRequest) returns (OnCreateResponse);
rpc OnUpdate(OnUpdateValueAndContextRequest) returns (OnUpdateResponse);
rpc OnDelete(OnDeleteValueAndContextRequest) returns (OnDeleteResponse);
rpc OnDeleteRevision(OnDeleteRevisionValueAndContextRequest) returns (OnDeleteRevisionResponse);

// lock
rpc GetLockedBy(GetLockedByRequest) returns (GetLockedByResponse);
Expand All @@ -125,9 +141,11 @@ service ContextStorageBackend {
rpc OnCreate(OnCreateRequest) returns (OnCreateResponse);
rpc OnUpdate(OnUpdateRequest) returns (OnUpdateResponse);
rpc OnDelete(OnDeleteRequest) returns (OnDeleteResponse);
rpc OnDeleteRevision(OnDeleteRevisionRequest) returns (OnDeleteRevisionResponse);

// lock
rpc GetLockedBy(GetLockedByRequest) returns (GetLockedByResponse);
rpc OnLock(OnLockRequest) returns (OnLockResponse);
rpc OnUnlock(OnUnlockRequest) returns (OnUnlockResponse);

}
260 changes: 260 additions & 0 deletions hub-js/src/generated/grpc/storage_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ export interface OnDeleteRequest {

export interface OnDeleteResponse {}

export interface OnDeleteRevisionRequest {
typeInstanceId: string;
ownerId?: string | undefined;
resourceVersion: number;
}

export interface OnDeleteRevisionValueAndContextRequest {
typeInstanceId: string;
context?: Uint8Array | undefined;
ownerId?: string | undefined;
resourceVersion: number;
}

export interface OnDeleteRevisionResponse {}

export interface GetValueRequest {
typeInstanceId: string;
resourceVersion: number;
Expand Down Expand Up @@ -985,6 +1000,235 @@ export const OnDeleteResponse = {
},
};

function createBaseOnDeleteRevisionRequest(): OnDeleteRevisionRequest {
return { typeInstanceId: "", ownerId: undefined, resourceVersion: 0 };
}

export const OnDeleteRevisionRequest = {
encode(
message: OnDeleteRevisionRequest,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.typeInstanceId !== "") {
writer.uint32(10).string(message.typeInstanceId);
}
if (message.ownerId !== undefined) {
writer.uint32(26).string(message.ownerId);
}
if (message.resourceVersion !== 0) {
writer.uint32(32).uint32(message.resourceVersion);
}
return writer;
},

decode(
input: _m0.Reader | Uint8Array,
length?: number
): OnDeleteRevisionRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOnDeleteRevisionRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.typeInstanceId = reader.string();
break;
case 3:
message.ownerId = reader.string();
break;
case 4:
message.resourceVersion = reader.uint32();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): OnDeleteRevisionRequest {
return {
typeInstanceId: isSet(object.typeInstanceId)
? String(object.typeInstanceId)
: "",
ownerId: isSet(object.ownerId) ? String(object.ownerId) : undefined,
resourceVersion: isSet(object.resourceVersion)
? Number(object.resourceVersion)
: 0,
};
},

toJSON(message: OnDeleteRevisionRequest): unknown {
const obj: any = {};
message.typeInstanceId !== undefined &&
(obj.typeInstanceId = message.typeInstanceId);
message.ownerId !== undefined && (obj.ownerId = message.ownerId);
message.resourceVersion !== undefined &&
(obj.resourceVersion = Math.round(message.resourceVersion));
return obj;
},

fromPartial(
object: DeepPartial<OnDeleteRevisionRequest>
): OnDeleteRevisionRequest {
const message = createBaseOnDeleteRevisionRequest();
message.typeInstanceId = object.typeInstanceId ?? "";
message.ownerId = object.ownerId ?? undefined;
message.resourceVersion = object.resourceVersion ?? 0;
return message;
},
};

function createBaseOnDeleteRevisionValueAndContextRequest(): OnDeleteRevisionValueAndContextRequest {
return {
typeInstanceId: "",
context: undefined,
ownerId: undefined,
resourceVersion: 0,
};
}

export const OnDeleteRevisionValueAndContextRequest = {
encode(
message: OnDeleteRevisionValueAndContextRequest,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.typeInstanceId !== "") {
writer.uint32(10).string(message.typeInstanceId);
}
if (message.context !== undefined) {
writer.uint32(18).bytes(message.context);
}
if (message.ownerId !== undefined) {
writer.uint32(26).string(message.ownerId);
}
if (message.resourceVersion !== 0) {
writer.uint32(32).uint32(message.resourceVersion);
}
return writer;
},

decode(
input: _m0.Reader | Uint8Array,
length?: number
): OnDeleteRevisionValueAndContextRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOnDeleteRevisionValueAndContextRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.typeInstanceId = reader.string();
break;
case 2:
message.context = reader.bytes();
break;
case 3:
message.ownerId = reader.string();
break;
case 4:
message.resourceVersion = reader.uint32();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): OnDeleteRevisionValueAndContextRequest {
return {
typeInstanceId: isSet(object.typeInstanceId)
? String(object.typeInstanceId)
: "",
context: isSet(object.context)
? bytesFromBase64(object.context)
: undefined,
ownerId: isSet(object.ownerId) ? String(object.ownerId) : undefined,
resourceVersion: isSet(object.resourceVersion)
? Number(object.resourceVersion)
: 0,
};
},

toJSON(message: OnDeleteRevisionValueAndContextRequest): unknown {
const obj: any = {};
message.typeInstanceId !== undefined &&
(obj.typeInstanceId = message.typeInstanceId);
message.context !== undefined &&
(obj.context =
message.context !== undefined
? base64FromBytes(message.context)
: undefined);
message.ownerId !== undefined && (obj.ownerId = message.ownerId);
message.resourceVersion !== undefined &&
(obj.resourceVersion = Math.round(message.resourceVersion));
return obj;
},

fromPartial(
object: DeepPartial<OnDeleteRevisionValueAndContextRequest>
): OnDeleteRevisionValueAndContextRequest {
const message = createBaseOnDeleteRevisionValueAndContextRequest();
message.typeInstanceId = object.typeInstanceId ?? "";
message.context = object.context ?? undefined;
message.ownerId = object.ownerId ?? undefined;
message.resourceVersion = object.resourceVersion ?? 0;
return message;
},
};

function createBaseOnDeleteRevisionResponse(): OnDeleteRevisionResponse {
return {};
}

export const OnDeleteRevisionResponse = {
encode(
_: OnDeleteRevisionResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
return writer;
},

decode(
input: _m0.Reader | Uint8Array,
length?: number
): OnDeleteRevisionResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOnDeleteRevisionResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(_: any): OnDeleteRevisionResponse {
return {};
},

toJSON(_: OnDeleteRevisionResponse): unknown {
const obj: any = {};
return obj;
},

fromPartial(
_: DeepPartial<OnDeleteRevisionResponse>
): OnDeleteRevisionResponse {
const message = createBaseOnDeleteRevisionResponse();
return message;
},
};

function createBaseGetValueRequest(): GetValueRequest {
return { typeInstanceId: "", resourceVersion: 0, context: new Uint8Array() };
}
Expand Down Expand Up @@ -1515,6 +1759,14 @@ export const ValueAndContextStorageBackendDefinition = {
responseStream: false,
options: {},
},
onDeleteRevision: {
name: "OnDeleteRevision",
requestType: OnDeleteRevisionValueAndContextRequest,
requestStream: false,
responseType: OnDeleteRevisionResponse,
responseStream: false,
options: {},
},
/** lock */
getLockedBy: {
name: "GetLockedBy",
Expand Down Expand Up @@ -1589,6 +1841,14 @@ export const ContextStorageBackendDefinition = {
responseStream: false,
options: {},
},
onDeleteRevision: {
name: "OnDeleteRevision",
requestType: OnDeleteRevisionRequest,
requestStream: false,
responseType: OnDeleteRevisionResponse,
responseStream: false,
options: {},
},
/** lock */
getLockedBy: {
name: "GetLockedBy",
Expand Down
2 changes: 0 additions & 2 deletions hub-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { config } from "./config";
import { logger } from "./logger";
import { ensureCoreStorageTypeInstance } from "./local/resolver/mutation/register-built-in-storage";
import DelegatedStorageService from "./local/storage/service";
import UpdateArgsContainer from "./local/storage/update-args-container";

async function main() {
logger.info("Using Neo4j database", { endpoint: config.neo4j.endpoint });
Expand Down Expand Up @@ -73,7 +72,6 @@ async function setupHttpServer(
return {
driver,
delegatedStorage,
updateArgs: new UpdateArgsContainer(),
};
},
});
Expand Down
Loading