1
0
Fork 0

Remove unused cache API (#1907)

pull/1909/head
Josh Gross 2024-12-17 14:04:05 -05:00 committed by GitHub
parent 433f76091b
commit 26f8f84a96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 359 deletions

View File

@ -212,52 +212,6 @@ export interface ListCacheEntriesResponse {
*/
entries: CacheEntry[];
}
/**
* @generated from protobuf message github.actions.results.api.v1.LookupCacheEntryRequest
*/
export interface LookupCacheEntryRequest {
/**
* Scope and other metadata for the cache entry
*
* @generated from protobuf field: github.actions.results.entities.v1.CacheMetadata metadata = 1;
*/
metadata?: CacheMetadata;
/**
* An explicit key for a cache entry
*
* @generated from protobuf field: string key = 2;
*/
key: string;
/**
* Restore keys used for prefix searching
*
* @generated from protobuf field: repeated string restore_keys = 3;
*/
restoreKeys: string[];
/**
* Hash of the compression tool, runner OS and paths cached
*
* @generated from protobuf field: string version = 4;
*/
version: string;
}
/**
* @generated from protobuf message github.actions.results.api.v1.LookupCacheEntryResponse
*/
export interface LookupCacheEntryResponse {
/**
* Indicates whether the cache entry exists or not
*
* @generated from protobuf field: bool exists = 1;
*/
exists: boolean;
/**
* Matched cache entry metadata
*
* @generated from protobuf field: github.actions.results.entities.v1.CacheEntry entry = 2;
*/
entry?: CacheEntry;
}
// @generated message type with reflection information, may provide speed optimized methods
class CreateCacheEntryRequest$Type extends MessageType<CreateCacheEntryRequest> {
constructor() {
@ -840,128 +794,6 @@ class ListCacheEntriesResponse$Type extends MessageType<ListCacheEntriesResponse
* @generated MessageType for protobuf message github.actions.results.api.v1.ListCacheEntriesResponse
*/
export const ListCacheEntriesResponse = new ListCacheEntriesResponse$Type();
// @generated message type with reflection information, may provide speed optimized methods
class LookupCacheEntryRequest$Type extends MessageType<LookupCacheEntryRequest> {
constructor() {
super("github.actions.results.api.v1.LookupCacheEntryRequest", [
{ no: 1, name: "metadata", kind: "message", T: () => CacheMetadata },
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "restore_keys", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/ },
{ no: 4, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value?: PartialMessage<LookupCacheEntryRequest>): LookupCacheEntryRequest {
const message = { key: "", restoreKeys: [], version: "" };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial<LookupCacheEntryRequest>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: LookupCacheEntryRequest): LookupCacheEntryRequest {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* github.actions.results.entities.v1.CacheMetadata metadata */ 1:
message.metadata = CacheMetadata.internalBinaryRead(reader, reader.uint32(), options, message.metadata);
break;
case /* string key */ 2:
message.key = reader.string();
break;
case /* repeated string restore_keys */ 3:
message.restoreKeys.push(reader.string());
break;
case /* string version */ 4:
message.version = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: LookupCacheEntryRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* github.actions.results.entities.v1.CacheMetadata metadata = 1; */
if (message.metadata)
CacheMetadata.internalBinaryWrite(message.metadata, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
/* string key = 2; */
if (message.key !== "")
writer.tag(2, WireType.LengthDelimited).string(message.key);
/* repeated string restore_keys = 3; */
for (let i = 0; i < message.restoreKeys.length; i++)
writer.tag(3, WireType.LengthDelimited).string(message.restoreKeys[i]);
/* string version = 4; */
if (message.version !== "")
writer.tag(4, WireType.LengthDelimited).string(message.version);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message github.actions.results.api.v1.LookupCacheEntryRequest
*/
export const LookupCacheEntryRequest = new LookupCacheEntryRequest$Type();
// @generated message type with reflection information, may provide speed optimized methods
class LookupCacheEntryResponse$Type extends MessageType<LookupCacheEntryResponse> {
constructor() {
super("github.actions.results.api.v1.LookupCacheEntryResponse", [
{ no: 1, name: "exists", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
{ no: 2, name: "entry", kind: "message", T: () => CacheEntry }
]);
}
create(value?: PartialMessage<LookupCacheEntryResponse>): LookupCacheEntryResponse {
const message = { exists: false };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial<LookupCacheEntryResponse>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: LookupCacheEntryResponse): LookupCacheEntryResponse {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* bool exists */ 1:
message.exists = reader.bool();
break;
case /* github.actions.results.entities.v1.CacheEntry entry */ 2:
message.entry = CacheEntry.internalBinaryRead(reader, reader.uint32(), options, message.entry);
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: LookupCacheEntryResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* bool exists = 1; */
if (message.exists !== false)
writer.tag(1, WireType.Varint).bool(message.exists);
/* github.actions.results.entities.v1.CacheEntry entry = 2; */
if (message.entry)
CacheEntry.internalBinaryWrite(message.entry, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message github.actions.results.api.v1.LookupCacheEntryResponse
*/
export const LookupCacheEntryResponse = new LookupCacheEntryResponse$Type();
/**
* @generated ServiceType for protobuf service github.actions.results.api.v1.CacheService
*/
@ -970,6 +802,5 @@ export const CacheService = new ServiceType("github.actions.results.api.v1.Cache
{ name: "FinalizeCacheEntryUpload", options: {}, I: FinalizeCacheEntryUploadRequest, O: FinalizeCacheEntryUploadResponse },
{ name: "GetCacheEntryDownloadURL", options: {}, I: GetCacheEntryDownloadURLRequest, O: GetCacheEntryDownloadURLResponse },
{ name: "DeleteCacheEntry", options: {}, I: DeleteCacheEntryRequest, O: DeleteCacheEntryResponse },
{ name: "ListCacheEntries", options: {}, I: ListCacheEntriesRequest, O: ListCacheEntriesResponse },
{ name: "LookupCacheEntry", options: {}, I: LookupCacheEntryRequest, O: LookupCacheEntryResponse }
{ name: "ListCacheEntries", options: {}, I: ListCacheEntriesRequest, O: ListCacheEntriesResponse }
]);

View File

@ -19,8 +19,6 @@ import {
DeleteCacheEntryResponse,
ListCacheEntriesRequest,
ListCacheEntriesResponse,
LookupCacheEntryRequest,
LookupCacheEntryResponse,
} from "./cache";
//==================================//
@ -52,9 +50,6 @@ export interface CacheServiceClient {
ListCacheEntries(
request: ListCacheEntriesRequest
): Promise<ListCacheEntriesResponse>;
LookupCacheEntry(
request: LookupCacheEntryRequest
): Promise<LookupCacheEntryResponse>;
}
export class CacheServiceClientJSON implements CacheServiceClient {
@ -66,7 +61,6 @@ export class CacheServiceClientJSON implements CacheServiceClient {
this.GetCacheEntryDownloadURL.bind(this);
this.DeleteCacheEntry.bind(this);
this.ListCacheEntries.bind(this);
this.LookupCacheEntry.bind(this);
}
CreateCacheEntry(
request: CreateCacheEntryRequest
@ -167,26 +161,6 @@ export class CacheServiceClientJSON implements CacheServiceClient {
})
);
}
LookupCacheEntry(
request: LookupCacheEntryRequest
): Promise<LookupCacheEntryResponse> {
const data = LookupCacheEntryRequest.toJson(request, {
useProtoFieldName: true,
emitDefaultValues: false,
});
const promise = this.rpc.request(
"github.actions.results.api.v1.CacheService",
"LookupCacheEntry",
"application/json",
data as object
);
return promise.then((data) =>
LookupCacheEntryResponse.fromJson(data as any, {
ignoreUnknownFields: true,
})
);
}
}
export class CacheServiceClientProtobuf implements CacheServiceClient {
@ -198,7 +172,6 @@ export class CacheServiceClientProtobuf implements CacheServiceClient {
this.GetCacheEntryDownloadURL.bind(this);
this.DeleteCacheEntry.bind(this);
this.ListCacheEntries.bind(this);
this.LookupCacheEntry.bind(this);
}
CreateCacheEntry(
request: CreateCacheEntryRequest
@ -274,21 +247,6 @@ export class CacheServiceClientProtobuf implements CacheServiceClient {
ListCacheEntriesResponse.fromBinary(data as Uint8Array)
);
}
LookupCacheEntry(
request: LookupCacheEntryRequest
): Promise<LookupCacheEntryResponse> {
const data = LookupCacheEntryRequest.toBinary(request);
const promise = this.rpc.request(
"github.actions.results.api.v1.CacheService",
"LookupCacheEntry",
"application/protobuf",
data
);
return promise.then((data) =>
LookupCacheEntryResponse.fromBinary(data as Uint8Array)
);
}
}
//==================================//
@ -316,10 +274,6 @@ export interface CacheServiceTwirp<T extends TwirpContext = TwirpContext> {
ctx: T,
request: ListCacheEntriesRequest
): Promise<ListCacheEntriesResponse>;
LookupCacheEntry(
ctx: T,
request: LookupCacheEntryRequest
): Promise<LookupCacheEntryResponse>;
}
export enum CacheServiceMethod {
@ -328,7 +282,6 @@ export enum CacheServiceMethod {
GetCacheEntryDownloadURL = "GetCacheEntryDownloadURL",
DeleteCacheEntry = "DeleteCacheEntry",
ListCacheEntries = "ListCacheEntries",
LookupCacheEntry = "LookupCacheEntry",
}
export const CacheServiceMethodList = [
@ -337,7 +290,6 @@ export const CacheServiceMethodList = [
CacheServiceMethod.GetCacheEntryDownloadURL,
CacheServiceMethod.DeleteCacheEntry,
CacheServiceMethod.ListCacheEntries,
CacheServiceMethod.LookupCacheEntry,
];
export function createCacheServiceServer<T extends TwirpContext = TwirpContext>(
@ -457,26 +409,6 @@ function matchCacheServiceRoute<T extends TwirpContext = TwirpContext>(
interceptors
);
};
case "LookupCacheEntry":
return async (
ctx: T,
service: CacheServiceTwirp,
data: Buffer,
interceptors?: Interceptor<
T,
LookupCacheEntryRequest,
LookupCacheEntryResponse
>[]
) => {
ctx = { ...ctx, methodName: "LookupCacheEntry" };
await events.onMatch(ctx);
return handleCacheServiceLookupCacheEntryRequest(
ctx,
service,
data,
interceptors
);
};
default:
events.onNotFound();
const msg = `no handler found`;
@ -648,39 +580,6 @@ function handleCacheServiceListCacheEntriesRequest<
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
}
}
function handleCacheServiceLookupCacheEntryRequest<
T extends TwirpContext = TwirpContext
>(
ctx: T,
service: CacheServiceTwirp,
data: Buffer,
interceptors?: Interceptor<
T,
LookupCacheEntryRequest,
LookupCacheEntryResponse
>[]
): Promise<string | Uint8Array> {
switch (ctx.contentType) {
case TwirpContentType.JSON:
return handleCacheServiceLookupCacheEntryJSON<T>(
ctx,
service,
data,
interceptors
);
case TwirpContentType.Protobuf:
return handleCacheServiceLookupCacheEntryProtobuf<T>(
ctx,
service,
data,
interceptors
);
default:
const msg = "unexpected Content-Type";
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
}
}
async function handleCacheServiceCreateCacheEntryJSON<
T extends TwirpContext = TwirpContext
>(
@ -920,54 +819,6 @@ async function handleCacheServiceListCacheEntriesJSON<
}) as string
);
}
async function handleCacheServiceLookupCacheEntryJSON<
T extends TwirpContext = TwirpContext
>(
ctx: T,
service: CacheServiceTwirp,
data: Buffer,
interceptors?: Interceptor<
T,
LookupCacheEntryRequest,
LookupCacheEntryResponse
>[]
) {
let request: LookupCacheEntryRequest;
let response: LookupCacheEntryResponse;
try {
const body = JSON.parse(data.toString() || "{}");
request = LookupCacheEntryRequest.fromJson(body, {
ignoreUnknownFields: true,
});
} catch (e) {
if (e instanceof Error) {
const msg = "the json request could not be decoded";
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
}
}
if (interceptors && interceptors.length > 0) {
const interceptor = chainInterceptors(...interceptors) as Interceptor<
T,
LookupCacheEntryRequest,
LookupCacheEntryResponse
>;
response = await interceptor(ctx, request!, (ctx, inputReq) => {
return service.LookupCacheEntry(ctx, inputReq);
});
} else {
response = await service.LookupCacheEntry(ctx, request!);
}
return JSON.stringify(
LookupCacheEntryResponse.toJson(response, {
useProtoFieldName: true,
emitDefaultValues: false,
}) as string
);
}
async function handleCacheServiceCreateCacheEntryProtobuf<
T extends TwirpContext = TwirpContext
>(
@ -1167,43 +1018,3 @@ async function handleCacheServiceListCacheEntriesProtobuf<
return Buffer.from(ListCacheEntriesResponse.toBinary(response));
}
async function handleCacheServiceLookupCacheEntryProtobuf<
T extends TwirpContext = TwirpContext
>(
ctx: T,
service: CacheServiceTwirp,
data: Buffer,
interceptors?: Interceptor<
T,
LookupCacheEntryRequest,
LookupCacheEntryResponse
>[]
) {
let request: LookupCacheEntryRequest;
let response: LookupCacheEntryResponse;
try {
request = LookupCacheEntryRequest.fromBinary(data);
} catch (e) {
if (e instanceof Error) {
const msg = "the protobuf request could not be decoded";
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
}
}
if (interceptors && interceptors.length > 0) {
const interceptor = chainInterceptors(...interceptors) as Interceptor<
T,
LookupCacheEntryRequest,
LookupCacheEntryResponse
>;
response = await interceptor(ctx, request!, (ctx, inputReq) => {
return service.LookupCacheEntry(ctx, inputReq);
});
} else {
response = await service.LookupCacheEntry(ctx, request!);
}
return Buffer.from(LookupCacheEntryResponse.toBinary(response));
}