Skip to content

Instantly share code, notes, and snippets.

@fantasywind
Created April 25, 2021 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fantasywind/d65882f7cb3340c20715fcbb09ee2e94 to your computer and use it in GitHub Desktop.
Save fantasywind/d65882f7cb3340c20715fcbb09ee2e94 to your computer and use it in GitHub Desktop.
const YOUTUBE_DATA = {
kind: 'youtube#videoListResponse',
etag: 'QOJsG51Qlpq5TNrbq6faaKRqYg8',
items: [
{
kind: 'youtube#video',
etag: '5vsH01N8zX_GwP5J3tGFDlFmBRs',
id: 'E_hmPwk37ME',
snippet: {
publishedAt: '2020-10-02T13:00:10Z',
channelId: 'UCfanbLlFn7EB5fiJuR2Kmhw',
title: '魏如昀|queenwei《他們說我是沒有用的年輕人/好樂團》unplugged cover #6',
description: '一把吉他,一個我,一首歌,唱給你聽。\n\n/\n\n「你會不會和我一樣,把希望寄託在別人的身上。」\n__ 他們說我是沒用的年輕人(好樂團)。\n\n人生會為你找到各種出路,但環境不會。\n未來的你會幫助現在的你有各種解決和面對的方法,但環境不會。\n但環境會讓你以為一切都是因為這個環境。\n\n尼采說過,生命中最難的階段不是沒有人懂你,而是你不懂你自己。\n不管你什麼才開始懂你自己,至少你懂。\n\n只要開始,就不算晚。\n\n/\n\n#queenwei #guitarcover #cover #unplugged #acoustic #practice \n#acousticguitar #ag #sing #originalsound #filminonetake #onetake \n#唱得我聲嘶力竭 #他們說我是沒有用的年輕人 #好樂團 #魏如昀 \n#不插電 #木吉他 #原音 #一鏡到底',
thumbnails: {
default: {
url: 'https://i.ytimg.com/vi/E_hmPwk37ME/default.jpg',
width: 120,
height: 90
},
medium: {
url: 'https://i.ytimg.com/vi/E_hmPwk37ME/mqdefault.jpg',
width: 320,
height: 180
},
high: {
url: 'https://i.ytimg.com/vi/E_hmPwk37ME/hqdefault.jpg',
width: 480,
height: 360
},
standard: {
url: 'https://i.ytimg.com/vi/E_hmPwk37ME/sddefault.jpg',
width: 640,
height: 480
},
maxres: {
url: 'https://i.ytimg.com/vi/E_hmPwk37ME/maxresdefault.jpg',
width: 1280,
height: 720
}
},
channelTitle: '魏如昀 [QueenWei Official]',
categoryId: '22',
liveBroadcastContent: 'none',
localized: {
title: '魏如昀|queenwei《他們說我是沒有用的年輕人/好樂團》unplugged cover #6',
description: '一把吉他,一個我,一首歌,唱給你聽。\n\n/\n\n「你會不會和我一樣,把希望寄託在別人的身上。」\n__ 他們說我是沒用的年輕人(好樂團)。\n\n人生會為你找到各種出路,但環境不會。\n未來的你會幫助現在的你有各種解決和面對的方法,但環境不會。\n但環境會讓你以為一切都是因為這個環境。\n\n尼采說過,生命中最難的階段不是沒有人懂你,而是你不懂你自己。\n不管你什麼才開始懂你自己,至少你懂。\n\n只要開始,就不算晚。\n\n/\n\n#queenwei #guitarcover #cover #unplugged #acoustic #practice \n#acousticguitar #ag #sing #originalsound #filminonetake #onetake \n#唱得我聲嘶力竭 #他們說我是沒有用的年輕人 #好樂團 #魏如昀 \n#不插電 #木吉他 #原音 #一鏡到底'
}
}
}
],
pageInfo: {
totalResults: 1,
resultsPerPage: 1
}
};
const path = require('path');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const PROTO_PATH = path.resolve(__dirname, './grpc.proto');
const GRPC_HOST = '127.0.0.1:50099';
const packageDeginition = protoLoader.loadSync(PROTO_PATH);
const descriptor = grpc.loadPackageDefinition(packageDeginition);
const grpcClient = new descriptor.Test(
GRPC_HOST, grpc.credentials.createInsecure()
);
// Test GRPC
const grpcServer = new grpc.Server();
grpcServer.addService(descriptor.Test.service, {
YoutubeSend: (call, callback) => {
console.timeEnd('gRPC:Transmission');
callback(null, { done: true });
},
});
grpcServer.bindAsync(GRPC_HOST, grpc.ServerCredentials.createInsecure(), (err, s) => {
grpcServer.start();
console.time('gRPC:Transmission');
grpcClient.YoutubeSend(YOUTUBE_DATA, (err) => {
console.time('gRPC:Serialize');
console.log(`gRPC:Size:${grpcClient.YoutubeSend.requestSerialize(YOUTUBE_DATA).length}`);
console.timeEnd('gRPC:Serialize');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment