Skip to content

Instantly share code, notes, and snippets.

💭
WIP

Mohak Puri mohak1712

💭
WIP
Block or report user

Report or block mohak1712

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cluster.yml
clusters:
- name: ping_pong_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
hosts: [{ socket_address: { address: host.docker.internal, port_value: 8080 }}]
View virtual_host.yml
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route:
cluster: ping_pong_service
max_grpc_timeout: 0s
cors:
allow_origin:
View listerner.yml
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 9090 }
View admin_portal.yml
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 9901 }
View server.js
var grpc = require('grpc');
var pingPongProto = grpc.load('ping_pong.proto');
var server = new grpc.Server();
server.addService(pingPongProto.pingpong.PingPongService.service, {
pingPong: function(call,callback) {
console.log("Request")
return callback(null,{pong:"Pong"})
}
});
View envoy.yaml
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 9901 }
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 9090 }
View Dockerfile
FROM envoyproxy/envoy-dev:latest
COPY ./envoy.yaml /etc/envoy/envoy.yaml
CMD /usr/local/bin/envoy -c /etc/envoy/envoy.yaml -l trace --log-path /tmp/envoy_info.log
View package.json
{
"name": "learn-react-grpc",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "2.1.8",
"@grpc/grpc-js": "^0.3.6",
"google-protobuf": "^3.7.1",
View App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
const { PingPongServiceClient } = require('./ping_pong_grpc_web_pb');
const { PingRequest, PongResponse } = require('./ping_pong_pb.js');
var client = new PingPongServiceClient('http://localhost:9090', null, null);
class App extends Component {
View ping_pong.proto
syntax = "proto3";
package pingpong;
message PingRequest {
string ping = 1;
}
message PongResponse {
string pong = 1;
You can’t perform that action at this time.