mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-09-04 09:13:21 +00:00
migrated grpc keyword to the newer monitoringtype (#4821)
Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
co-authored by
Louis Lam
parent
46b07953ad
commit
b230ab0a06
@@ -0,0 +1,7 @@
|
||||
syntax = "proto3";
|
||||
package echo;
|
||||
service EchoService {
|
||||
rpc Echo (EchoRequest) returns (EchoResponse);
|
||||
}
|
||||
message EchoRequest { string message = 1; }
|
||||
message EchoResponse { string message = 1; }
|
||||
@@ -0,0 +1,22 @@
|
||||
const grpc = require("@grpc/grpc-js");
|
||||
const protoLoader = require("@grpc/proto-loader");
|
||||
const packageDef = protoLoader.loadSync("echo.proto", {});
|
||||
const grpcObject = grpc.loadPackageDefinition(packageDef);
|
||||
const { echo } = grpcObject;
|
||||
|
||||
/**
|
||||
* Echo service implementation
|
||||
* @param {object} call Call object
|
||||
* @param {Function} callback Callback function
|
||||
* @returns {void}
|
||||
*/
|
||||
function Echo(call, callback) {
|
||||
callback(null, { message: call.request.message });
|
||||
}
|
||||
|
||||
const server = new grpc.Server();
|
||||
server.addService(echo.EchoService.service, { Echo });
|
||||
server.bindAsync("0.0.0.0:50051", grpc.ServerCredentials.createInsecure(), () => {
|
||||
console.log("gRPC server running on :50051");
|
||||
server.start();
|
||||
});
|
||||
Reference in New Issue
Block a user