Skip to content

Commit

Permalink
added pseudo comments to client calls and server
Browse files Browse the repository at this point in the history
  • Loading branch information
iangeckeler committed Aug 5, 2019
1 parent b3cb017 commit 93ea51c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/callFactories/generateUnaryCall.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
const grpc = require("grpc");

// function serverUnaryDecorator(callClone, serverCall, callback) {
// callClone...
// }
// callClone.throw (err, trailers)
// check for err to be eror objects
// converts trailers to grpc Metadata class.
// passes them in the right place to callback
// callClone.on = ("data" |/& callback) => callback(callClone.body)
// callClone.set()
// calllClone.body = serverCall.request

function generateUnaryCall(ServerUnaryCall, callback) {
const ServerUnaryCallClone = Object.create(ServerUnaryCall);
ServerUnaryCallClone.callback = callback;
Expand Down
24 changes: 24 additions & 0 deletions lib/clientCalls/unaryCall.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
const generateMeta = require("../utils/generateMeta");

//create an object that extends the original call, redefine it's actual reference to be the following...

// create a function that takes in a interceptors and metadata
// returns an object with the following methods...

// catch --> connects and calls on error
// sets the catch function

// on --> receives a string "data" and a callback
//sets the onFunction for the object
// if function received as first param, also works...
// invokes callback on the data when it comes back

// send --> receives a message...
// if there is no "catch" or "on" throws an error OR
//(err,res)=>{console.log('warning, no catch or on clalback supplied for response.)}
// otherwise, calls the method, passing in interceptors, metadata, and message
// function(err,res) =>{
// if(err) this.catchFun(err)
// return this.onFun(res)
// }

//throw which will console.log(no throw on unary calls...)

module.exports = function unaryCall(that, methodName, ...args) {
if (typeof args[0] !== "object") {
throw new Error("First parameter required and must be of type: Message.");
Expand Down

0 comments on commit 93ea51c

Please sign in to comment.