Skip to content

Commit

Permalink
feat(#171): updated access to fileId during backup upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashornych committed Oct 16, 2024
1 parent 2147b69 commit f7977cb
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 12 deletions.
11 changes: 9 additions & 2 deletions src/modules/backup-viewer/components/BackupCatalogDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ const emit = defineEmits<{
(e: 'backup'): void
}>()
watch(
() => props.modelValue,
(newValue) => {
if (newValue) {
loadAvailableCatalogs().then()
}
}
)
const availableCatalogs = ref<string[]>([])
const availableCatalogsLoaded = ref<boolean>(false)
const minimalDate = ref<string | undefined>()
Expand Down Expand Up @@ -133,8 +142,6 @@ async function backup(): Promise<boolean> {
return false
}
}
loadAvailableCatalogs().then()
</script>

<template>
Expand Down
13 changes: 7 additions & 6 deletions src/modules/connection/driver/grpc/EvitaDBDriverGrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
GrpcDeleteFileToFetchResponse,
GrpcEvitaServerStatusResponse,
GrpcReservedKeywordsResponse,
GrpcRestoreCatalogResponse, GrpcRestoreCatalogUnaryRequest
GrpcRestoreCatalogUnaryRequest, GrpcRestoreCatalogUnaryResponse
} from '@/modules/connection/driver/grpc/gen/GrpcEvitaManagementAPI_pb'
import { ReservedKeywordsConverter } from '@/modules/connection/driver/grpc/service/ReservedKeywordsConverter'
import { splitStringWithCaseIntoWords } from '@/utils/string'
Expand All @@ -59,7 +59,7 @@ import { GrpcFile, GrpcTaskStatus } from '@/modules/connection/driver/grpc/gen/G
/**
* Chunk size for upload local backup files
*/
const chunkSize: number = 64 * 1024; // 64 KB chunks
const chunkSize: number = 2 * 1024 * 1024; // 2 MB chunks
/**
* Timeout in milliseconds in which a file chunks needs to be uploaded to server
*/
Expand Down Expand Up @@ -622,17 +622,18 @@ export class EvitaDBDriverGrpc implements EvitaDBDriver {
totalSizeInBytes: BigInt(file.size)
});

const chunkResponse: GrpcRestoreCatalogResponse = await this.clientProvider
const chunkResponse: GrpcRestoreCatalogUnaryResponse = await this.clientProvider
.getEvitaManagementClient(connection)
.restoreCatalogUnary(
chunkRequest,
{ timeoutMs: fileChunkUploadTimeout }
)
lastTaskStatus = chunkResponse.task
if (uploadedFileId == undefined) {
uploadedFileId = this.evitaValueConverter.convertUUID(
(chunkResponse.task?.result.value as GrpcFile).fileId!
)
if (chunkResponse.fileId == undefined) {
throw new UnexpectedError('No fileId was returned for uploaded chunk. Aborting...')
}
uploadedFileId = this.evitaValueConverter.convertUUID(chunkResponse.fileId)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @ts-nocheck

import { Empty, MethodKind } from "@bufbuild/protobuf";
import { GrpcCancelTaskRequest, GrpcCancelTaskResponse, GrpcDeleteFileToFetchRequest, GrpcDeleteFileToFetchResponse, GrpcEvitaCatalogStatisticsResponse, GrpcEvitaConfigurationResponse, GrpcEvitaServerStatusResponse, GrpcFetchFileRequest, GrpcFetchFileResponse, GrpcFilesToFetchRequest, GrpcFilesToFetchResponse, GrpcFileToFetchRequest, GrpcFileToFetchResponse, GrpcReservedKeywordsResponse, GrpcRestoreCatalogFromServerFileRequest, GrpcRestoreCatalogRequest, GrpcRestoreCatalogResponse, GrpcRestoreCatalogUnaryRequest, GrpcSpecifiedTaskStatusesRequest, GrpcSpecifiedTaskStatusesResponse, GrpcTaskStatusesRequest, GrpcTaskStatusesResponse, GrpcTaskStatusRequest, GrpcTaskStatusResponse } from "./GrpcEvitaManagementAPI_pb.js";
import { GrpcCancelTaskRequest, GrpcCancelTaskResponse, GrpcDeleteFileToFetchRequest, GrpcDeleteFileToFetchResponse, GrpcEvitaCatalogStatisticsResponse, GrpcEvitaConfigurationResponse, GrpcEvitaServerStatusResponse, GrpcFetchFileRequest, GrpcFetchFileResponse, GrpcFilesToFetchRequest, GrpcFilesToFetchResponse, GrpcFileToFetchRequest, GrpcFileToFetchResponse, GrpcReservedKeywordsResponse, GrpcRestoreCatalogFromServerFileRequest, GrpcRestoreCatalogRequest, GrpcRestoreCatalogResponse, GrpcRestoreCatalogUnaryRequest, GrpcRestoreCatalogUnaryResponse, GrpcSpecifiedTaskStatusesRequest, GrpcSpecifiedTaskStatusesResponse, GrpcTaskStatusesRequest, GrpcTaskStatusesResponse, GrpcTaskStatusRequest, GrpcTaskStatusResponse } from "./GrpcEvitaManagementAPI_pb.js";

/**
* This service contains RPCs that could be called by gRPC clients on evitaDB. Main purpose of this service is to provide
Expand Down Expand Up @@ -67,7 +67,7 @@ export const EvitaManagementService = {
restoreCatalogUnary: {
name: "RestoreCatalogUnary",
I: GrpcRestoreCatalogUnaryRequest,
O: GrpcRestoreCatalogResponse,
O: GrpcRestoreCatalogUnaryResponse,
kind: MethodKind.Unary,
},
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export class GrpcRestoreCatalogResponse extends Message<GrpcRestoreCatalogRespon
/**
* the task that is used to restore the catalog and getting its progress
*
* @generated from field: io.evitadb.externalApi.grpc.generated.GrpcTaskStatus task = 2;
* @generated from field: io.evitadb.externalApi.grpc.generated.GrpcTaskStatus task = 3;
*/
task?: GrpcTaskStatus;

Expand All @@ -513,7 +513,7 @@ export class GrpcRestoreCatalogResponse extends Message<GrpcRestoreCatalogRespon
static readonly typeName = "io.evitadb.externalApi.grpc.generated.GrpcRestoreCatalogResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "read", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 2, name: "task", kind: "message", T: GrpcTaskStatus },
{ no: 3, name: "task", kind: "message", T: GrpcTaskStatus },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GrpcRestoreCatalogResponse {
Expand All @@ -533,6 +533,63 @@ export class GrpcRestoreCatalogResponse extends Message<GrpcRestoreCatalogRespon
}
}

/**
* Response to a catalog restore request.
*
* @generated from message io.evitadb.externalApi.grpc.generated.GrpcRestoreCatalogUnaryResponse
*/
export class GrpcRestoreCatalogUnaryResponse extends Message<GrpcRestoreCatalogUnaryResponse> {
/**
* returns the number of bytes read from the backup file
*
* @generated from field: int64 read = 1;
*/
read = protoInt64.zero;

/**
* The identification of the file on the server that should be restored
*
* @generated from field: io.evitadb.externalApi.grpc.generated.GrpcUuid fileId = 2;
*/
fileId?: GrpcUuid;

/**
* the task that is used to restore the catalog and getting its progress
*
* @generated from field: io.evitadb.externalApi.grpc.generated.GrpcTaskStatus task = 3;
*/
task?: GrpcTaskStatus;

constructor(data?: PartialMessage<GrpcRestoreCatalogUnaryResponse>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "io.evitadb.externalApi.grpc.generated.GrpcRestoreCatalogUnaryResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "read", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 2, name: "fileId", kind: "message", T: GrpcUuid },
{ no: 3, name: "task", kind: "message", T: GrpcTaskStatus },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GrpcRestoreCatalogUnaryResponse {
return new GrpcRestoreCatalogUnaryResponse().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GrpcRestoreCatalogUnaryResponse {
return new GrpcRestoreCatalogUnaryResponse().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GrpcRestoreCatalogUnaryResponse {
return new GrpcRestoreCatalogUnaryResponse().fromJsonString(jsonString, options);
}

static equals(a: GrpcRestoreCatalogUnaryResponse | PlainMessage<GrpcRestoreCatalogUnaryResponse> | undefined, b: GrpcRestoreCatalogUnaryResponse | PlainMessage<GrpcRestoreCatalogUnaryResponse> | undefined): boolean {
return proto3.util.equals(GrpcRestoreCatalogUnaryResponse, a, b);
}
}

/**
* Request to list task statuses in paginated form.
*
Expand Down
17 changes: 17 additions & 0 deletions src/modules/connection/driver/grpc/gen/GrpcEvitaSessionAPI_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,13 @@ export class GrpcPaginatedList extends Message<GrpcPaginatedList> {
*/
pageNumber = 0;

/**
* The number of the last page.
*
* @generated from field: int32 lastPageNumber = 3;
*/
lastPageNumber = 0;

constructor(data?: PartialMessage<GrpcPaginatedList>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -1021,6 +1028,7 @@ export class GrpcPaginatedList extends Message<GrpcPaginatedList> {
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pageSize", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
{ no: 2, name: "pageNumber", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
{ no: 3, name: "lastPageNumber", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GrpcPaginatedList {
Expand Down Expand Up @@ -2748,6 +2756,14 @@ export class GrpcQueryParam extends Message<GrpcQueryParam> {
*/
value: GrpcManagedReferencesBehaviour;
case: "managedReferencesBehaviour";
} | {
/**
* The expression
*
* @generated from field: string expressionValue = 23;
*/
value: string;
case: "expressionValue";
} | {
/**
* The string array value.
Expand Down Expand Up @@ -2946,6 +2962,7 @@ export class GrpcQueryParam extends Message<GrpcQueryParam> {
{ no: 20, name: "statisticsType", kind: "enum", T: proto3.getEnumType(GrpcStatisticsType), oneof: "queryParam" },
{ no: 21, name: "histogramBehavior", kind: "enum", T: proto3.getEnumType(GrpcHistogramBehavior), oneof: "queryParam" },
{ no: 22, name: "managedReferencesBehaviour", kind: "enum", T: proto3.getEnumType(GrpcManagedReferencesBehaviour), oneof: "queryParam" },
{ no: 23, name: "expressionValue", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "queryParam" },
{ no: 101, name: "stringArrayValue", kind: "message", T: GrpcStringArray, oneof: "queryParam" },
{ no: 102, name: "integerArrayValue", kind: "message", T: GrpcIntegerArray, oneof: "queryParam" },
{ no: 103, name: "longArrayValue", kind: "message", T: GrpcLongArray, oneof: "queryParam" },
Expand Down

0 comments on commit f7977cb

Please sign in to comment.