From 08086f16ca76a78438b92586cc24ba882c39ea6c Mon Sep 17 00:00:00 2001
From: IsolatedSushi <simen.vanherpt@gmail.com>
Date: Wed, 30 Sep 2020 23:46:01 +0200
Subject: [PATCH] Readme

---
 README.md                   | 22 ++++++++++
 WEBGRPCExample/.gitignore   |  4 --
 WEBGRPCExample/client.js    | 45 --------------------
 WEBGRPCExample/command.txt  |  1 -
 WEBGRPCExample/envoy.yaml   | 39 -----------------
 WEBGRPCExample/index.html   | 14 -------
 WEBGRPCExample/package.json | 19 ---------
 WEBGRPCExample/point.proto  | 20 ---------
 WEBGRPCExample/server.js    | 83 -------------------------------------
 backend/README.txt          |  2 +
 backend/point.proto         | 20 ---------
 backend/projector.proto     | 71 -------------------------------
 frontend/README.md          | 18 ++------
 13 files changed, 28 insertions(+), 330 deletions(-)
 create mode 100644 README.md
 delete mode 100644 WEBGRPCExample/.gitignore
 delete mode 100644 WEBGRPCExample/client.js
 delete mode 100644 WEBGRPCExample/command.txt
 delete mode 100644 WEBGRPCExample/envoy.yaml
 delete mode 100644 WEBGRPCExample/index.html
 delete mode 100644 WEBGRPCExample/package.json
 delete mode 100644 WEBGRPCExample/point.proto
 delete mode 100644 WEBGRPCExample/server.js
 delete mode 100644 backend/point.proto
 delete mode 100644 backend/projector.proto

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4aa109b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,22 @@
+TO RUN
+
+We need a ENVOY proxy to translate the grpc web http2 requests
+docker run -d -v <<insert path to directory here>>envoy.yaml:/etc/envoy/envoy.yaml:ro -p 8080:8080 -p 9090:9090 envoyproxy/envoy:v1.15.0
+
+NOTE you have to use complete path (sometimes it complains when using relative paths, no idea why)
+
+Start the vue application with the vue dashboard (probably easiest to use in cmd: vue ui)
+
+Start the server.js: node backend/server.js
+
+For the microservices for developing run the index.js file in  backend\microservices and load balancing\app
+
+(might have to install the packages first)
+
+For the entire microservices deployment build the docker image in that directory with
+docker build -t nodeapp .
+
+To run the deployment run:
+docker-compose up
+
+
diff --git a/WEBGRPCExample/.gitignore b/WEBGRPCExample/.gitignore
deleted file mode 100644
index 2b281a6..0000000
--- a/WEBGRPCExample/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-dist/
-*_pb.js
-node_modules/
-package-lock.json
diff --git a/WEBGRPCExample/client.js b/WEBGRPCExample/client.js
deleted file mode 100644
index 66fe143..0000000
--- a/WEBGRPCExample/client.js
+++ /dev/null
@@ -1,45 +0,0 @@
-
- const {voidNoParam} = require('./point_pb.js');
-const {PointClient} = require('./point_grpc_web_pb.js');
-
-var client = new PointClient('http://' + window.location.hostname + ':8080',null, null);
-var request = new voidNoParam();
-
-    
-function unaryResponseHandler(err,response){
-  if (err) {
-    console.log(`Unexpected error for readPoint: code = ${err.code}` +
-                `, message = "${err.message}"`);
-  } else {
-    console.log(pointToString(response));
-  }
-}
-
-function pointToString(point){
-  return "ID: " + point.getId() + "x: " + point.getX() + "y: " + point.getY();
-}
-
-                           
-// simple unary call
-client.readPoint(request, {}, unaryResponseHandler);
-window.uclicked = function(){
-  console.log("requested new point from client.js");
-  client.readPoint(request,{},unaryResponseHandler);
-}
-
-// server streaming call
-var streamRequest = new voidNoParam();
-
-var count = 10;
-console.log("Will send " + count);
-
-var stream = client.readPointsStream(streamRequest, {});
-stream.on('data', (response) => {
-  console.log(pointToString(response));
-});
-stream.on('error', (err) => {
-  console.log(`Unexpected stream error: code = ${err.code}` +
-              `, message = "${err.message}"`);
-});
-
-
diff --git a/WEBGRPCExample/command.txt b/WEBGRPCExample/command.txt
deleted file mode 100644
index 9cbc271..0000000
--- a/WEBGRPCExample/command.txt
+++ /dev/null
@@ -1 +0,0 @@
-docker run -d -v C:/Users/simen/Desktop/GRPCExample/grpc-web/net/grpc/gateway/examples/helloworld/envoy.yaml:/etc/envoy/envoy.yaml:ro -p 8080:8080 -p 9901:9901 envoyproxy/envoy:v1.15.0
\ No newline at end of file
diff --git a/WEBGRPCExample/envoy.yaml b/WEBGRPCExample/envoy.yaml
deleted file mode 100644
index b531033..0000000
--- a/WEBGRPCExample/envoy.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-static_resources:
-  listeners:
-  - name: listener_0
-    address:
-      socket_address: { address: 0.0.0.0, port_value: 8080 }
-    filter_chains:
-    - filters:
-      - name: envoy.http_connection_manager
-        config:
-          codec_type: auto
-          stat_prefix: ingress_http
-          route_config:
-            name: local_route
-            virtual_hosts:
-            - name: local_service
-              domains: ["*"]
-              routes:
-              - match: { prefix: "/" }
-                route:
-                  cluster: greeter_service
-                  max_grpc_timeout: 0s
-              cors:
-                allow_origin_string_match:
-                - prefix: "*"
-                allow_methods: GET, PUT, DELETE, POST, OPTIONS
-                allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
-                max_age: "1728000"
-                expose_headers: custom-header-1,grpc-status,grpc-message
-          http_filters:
-          - name: envoy.grpc_web
-          - name: envoy.cors
-          - name: envoy.router
-  clusters:
-  - name: greeter_service
-    connect_timeout: 0.25s
-    type: logical_dns
-    http2_protocol_options: {}
-    lb_policy: round_robin
-    hosts: [{ socket_address: { address: host.docker.internal, port_value: 9090 }}]
\ No newline at end of file
diff --git a/WEBGRPCExample/index.html b/WEBGRPCExample/index.html
deleted file mode 100644
index e11d3cb..0000000
--- a/WEBGRPCExample/index.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-<meta charset="UTF-8">
-<title>gRPC-Web Example</title>
-<script src="./dist/main.js"></script>
-</head>
-<body>
-  <div id="my_dataviz" name = "div1"></div>
-  <button id = "pointRequestButton" type="submit" name="PointRequester" value="activate" onclick="uclicked()">Click to request a point</button>
-</body>
-<!-- Load d3.js -->
-<script src="https://d3js.org/d3.v4.js"></script>
-</html>
diff --git a/WEBGRPCExample/package.json b/WEBGRPCExample/package.json
deleted file mode 100644
index 2946f8f..0000000
--- a/WEBGRPCExample/package.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
-  "name": "grpc-web-simple-example",
-  "version": "0.1.0",
-  "description": "gRPC-Web simple example",
-  "main": "server.js",
-  "devDependencies": {
-    "@grpc/grpc-js": "~1.0.5",
-    "@grpc/proto-loader": "~0.5.4",
-    "async": "~1.5.2",
-    "google-protobuf": "~3.12.0",
-    "grpc-web": "~1.2.1",
-    "lodash": "~4.17.0",
-    "webpack": "~4.43.0",
-    "webpack-cli": "~3.3.11"
-  },
-  "dependencies": {
-    "d3": "^5.16.0"
-  }
-}
diff --git a/WEBGRPCExample/point.proto b/WEBGRPCExample/point.proto
deleted file mode 100644
index 9072e34..0000000
--- a/WEBGRPCExample/point.proto
+++ /dev/null
@@ -1,20 +0,0 @@
-syntax = "proto3";
-
-package pointPackage;
-
-service Point {
-	rpc readPoint(voidNoParam) returns (PointItem);
-    rpc readPointsStream(voidNoParam) returns (stream PointItem);
-}
-
-message voidNoParam {}
-
-message PointItem {
-    int32 id = 1;
-    int32 x = 2;
-    int32 y = 3;
-}
-
-message PointItems {
-    repeated PointItem items = 1;
-}
\ No newline at end of file
diff --git a/WEBGRPCExample/server.js b/WEBGRPCExample/server.js
deleted file mode 100644
index dd4819c..0000000
--- a/WEBGRPCExample/server.js
+++ /dev/null
@@ -1,83 +0,0 @@
-//SETUP
-var PROTO_PATH = __dirname + '/point.proto';
-var assert = require('assert');
-var async = require('async');
-var _ = require('lodash');
-var grpc = require('@grpc/grpc-js');
-var protoLoader = require('@grpc/proto-loader');
-var packageDefinition = protoLoader.loadSync(
-    PROTO_PATH,
-    {keepCase: true,
-     longs: String,
-     enums: String,
-     defaults: true,
-     oneofs: true
-    });
-var protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
-var pointPackage = protoDescriptor.pointPackage;
-/**
- * @param {!Object} call
- * @param {function():?} callback
- */
-
- var count = 0;
-
-
-//Generate randomPoint
-function generatePoint(){
-  var xVal = Math.floor(Math.random()*20);
-  var yVal = Math.floor(Math.random()*20);
-  count++;
-  return {id:count, x:xVal,y:yVal};
-}
-//SERVICE
-function sendPoint(call, callback) {
-  callback(null, generatePoint());
-  console.log("sent point!");
-}
-/**
- * @param {!Object} call
- */
-function sendPointStream(call) {
-  
-  function sender(point) {
-    return (callback) => {
-      call.write(point);
-      _.delay(callback, 500); // in ms
-    };
-  }
-
-  var senders = [];
-  var count = 10;
-  console.log("Will send " + count);
-  for (var i = 0; i < count; i++) {
-    senders[i] = sender(generatePoint());
-  }
-  async.series(senders, () => {
-    call.end();
-  });
-}
-
-
-/**
- * @return {!Object} gRPC server
- */
-function getServer() {
-  var server = new grpc.Server();
-  server.addService(pointPackage.Point.service, {
-    readPoint: sendPoint,
-    readPointsStream: sendPointStream,
-  });
-  return server;
-}
-
-if (require.main === module) {
-  var server = getServer();
-  server.bindAsync(
-    '0.0.0.0:9090', grpc.ServerCredentials.createInsecure(), (err, port) => {
-      assert.ifError(err);
-      server.start();
-      console.log("connected");
-  });
-}
-exports.getServer = getServer;
diff --git a/backend/README.txt b/backend/README.txt
index ab495d4..e2a268c 100644
--- a/backend/README.txt
+++ b/backend/README.txt
@@ -2,6 +2,8 @@ Simple NODEjs based server with grpc. (runs on port 9090)
 
 Run with node server.js
 
+The server(OLD).js file was for the previous proto, remove later
+
 Note:
 Might have to run the command npm install @grpc/grpc-js
 Somehow the package.json together with npm cant install it everytime? (Its a known bug posted on the grpc issue page)
\ No newline at end of file
diff --git a/backend/point.proto b/backend/point.proto
deleted file mode 100644
index 9072e34..0000000
--- a/backend/point.proto
+++ /dev/null
@@ -1,20 +0,0 @@
-syntax = "proto3";
-
-package pointPackage;
-
-service Point {
-	rpc readPoint(voidNoParam) returns (PointItem);
-    rpc readPointsStream(voidNoParam) returns (stream PointItem);
-}
-
-message voidNoParam {}
-
-message PointItem {
-    int32 id = 1;
-    int32 x = 2;
-    int32 y = 3;
-}
-
-message PointItems {
-    repeated PointItem items = 1;
-}
\ No newline at end of file
diff --git a/backend/projector.proto b/backend/projector.proto
deleted file mode 100644
index a2a1dab..0000000
--- a/backend/projector.proto
+++ /dev/null
@@ -1,71 +0,0 @@
-syntax = "proto3";
-
-package provee;
-
-import "google/protobuf/empty.proto";
-
-option java_multiple_files = true;
-option java_package = "nl.uuvig.provee";
-option java_outer_classname = "ProveProjectorGRCP";
-option objc_class_prefix = "PROVEE";
-
-
-// Interface exported by the server.
-service Projector {
-  // A simple RPC.
-  //
-  // Start the Projector calculation
-  rpc start(google.protobuf.Empty) returns (google.protobuf.Empty);
-
-  // Stop the Projector calculation
-  rpc stop(google.protobuf.Empty) returns (google.protobuf.Empty);
-
-  // A server-to-client streaming RPC.
-  //
-  // Obtains the Projection Points in 2D given the trainings values stored in a row format.  Results are
-  // streamed rather than returned at once (e.g. in a response message with a
-  // repeated field).
-  rpc getProjectionPoints(TrainingSet) returns (stream Point) {}
-
-  // A server-to-client streaming RPC.
-  //
-  // Obtains the Projection Points in 2D given the trainings values stored in a row format.  Results are
-  // streamed rather than returned at once (e.g. in a response message with a
-  // repeated field).
-  rpc getUpdates(google.protobuf.Empty) returns (stream Point) {}
-
-//   // A client-to-server streaming RPC.
-//   //
-//   // Accepts a stream of Points on a route being traversed, returning a
-//   // RouteSummary when traversal is completed.
-//   rpc RecordRoute(stream Point) returns (RouteSummary) {}
-
-//   // A Bidirectional streaming RPC.
-//   //
-//   // Accepts a stream of RouteNotes sent while a route is being traversed,
-//   // while receiving other RouteNotes (e.g. from other users).
-//   rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-}
-
-// Points are represented as x-y pairs
-message Point {
-  int32 id = 1;
-  int32 x = 2;
-  int32 y = 3;
-}
-
-// Needs description
-message TrainingSet {
-  string modelid = 1;
-  repeated TrainingSetRow rows = 2;
-}
-
-// Needs documentation
-message TrainingSetRow {
-  // The id of the row, e.g., row index.
-  string id = 1;
-
-  // The hd vector of the item.
-  repeated double hdvector = 2 [packed=true];
-}
-
diff --git a/frontend/README.md b/frontend/README.md
index 33f865c..27a96db 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -1,20 +1,10 @@
 FOR THE ENVOY PROXY (needed to translate from http1 to http2 otherwise grpcweb doesn't understand it):
-docker run -d -v <<insert path to directory here>>envoy.yaml:/etc/envoy/envoy.yaml:ro -p 8080:8080 -p 9090:9090 envoyproxy/envoy:v1.15.0
-NOTE you have to use complete path (sometimes it complains when using relative paths, no idea why)
-
-We have to run it with dapr so use:
-dapr run --port 5051 --app-id vuezfrontend npm run serve
-
-For some reason with vue it cant get the dapr.HTTP environment variable (even though it can with python) so add the port
-
 
+docker run -d -v <<insert path to directory here>>envoy.yaml:/etc/envoy/envoy.yaml:ro -p 8080:8080 -p 9090:9090 envoyproxy/envoy:v1.15.0
 
-docker run -d -v envoy.yaml:/etc/envoy/envoy.yaml:ro -p 7050:7050 -p 50460:50460 envoyproxy/envoy:v1.15.0
-
-
-docker run -d -v C:\Users\simen\OneDrive\Documents\GitHub\dummy-vue-grpc\envoy.yaml:/etc/envoy/envoy.yaml:ro -p 7050:7050 -p 50460:50460 envoyproxy/envoy:v1.15.0
-
+NOTE you have to use complete path (sometimes it complains when using relative paths, no idea why)
 
 
+Command with my path
 
-docker run -d -vC:\Users\simen\OneDrive\Documents\GitHub\dummy-vue-grpc\envoy.yaml:/etc/envoy/envoy.yaml:ro -p 8080:8080 -p 9090:9090 envoyproxy/envoy:v1.15.0
+docker run -d -v C:\Users\simen\OneDrive\Documents\GitHub\dummy-vue-grpc\envoy.yaml:/etc/envoy/envoy.yaml:ro -p 8080:8080 -p 9090:9090 envoyproxy/envoy:v1.15.0
-- 
GitLab