@colabo-flow/s-go 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/DEVELOPMENT.md +38 -0
  2. package/README.md +110 -0
  3. package/__init__.py +0 -0
  4. package/__pycache__/__init__.cpython-39.pyc +0 -0
  5. package/create_client.py +84 -0
  6. package/create_host.py +91 -0
  7. package/create_host_terra.py +103 -0
  8. package/demo/__init__.py +0 -0
  9. package/demo/create-client.ts +51 -0
  10. package/demo/create-host.ts +136 -0
  11. package/demo/send-simple-recommended.py +26 -0
  12. package/demo/send-simple.py +50 -0
  13. package/demo/send.py +352 -0
  14. package/demo/send.ts +40 -0
  15. package/demo/threading/README.md +14 -0
  16. package/demo/threading/basic_consumer_connection_threaded.png +0 -0
  17. package/demo/threading/basic_consumer_connection_threaded.py +135 -0
  18. package/demo/threading/basic_consumer_threaded.py +100 -0
  19. package/demo/threading/long-running-publisher.py +68 -0
  20. package/docs/ColaboFlow-infrastructure-diagram.png +0 -0
  21. package/docs/workflow.md +35 -0
  22. package/index.ts +4 -0
  23. package/jest.config.ts +172 -0
  24. package/lib/__init__.py +0 -0
  25. package/lib/__pycache__/__init__.cpython-39.pyc +0 -0
  26. package/lib/__pycache__/config.cpython-39.pyc +0 -0
  27. package/lib/__pycache__/executor_operators.cpython-39.pyc +0 -0
  28. package/lib/__pycache__/executor_vos.cpython-39.pyc +0 -0
  29. package/lib/__pycache__/go_amqp_client.cpython-39.pyc +0 -0
  30. package/lib/__pycache__/go_amqp_client_threaded.cpython-39.pyc +0 -0
  31. package/lib/__pycache__/go_amqp_host.cpython-39.pyc +0 -0
  32. package/lib/__pycache__/operators.cpython-39.pyc +0 -0
  33. package/lib/__pycache__/vos.cpython-39.pyc +0 -0
  34. package/lib/config.py +21 -0
  35. package/lib/config.ts +22 -0
  36. package/lib/executor_operators.py +23 -0
  37. package/lib/executor_vos.py +318 -0
  38. package/lib/go.amqp.client-old-basic.py +50 -0
  39. package/lib/go.amqp.client.ts +100 -0
  40. package/lib/go.amqp.host-old-basic.py +48 -0
  41. package/lib/go.amqp.host.ts +269 -0
  42. package/lib/go.amqp.host_status.ts +81 -0
  43. package/lib/go.amqp.service.ts +272 -0
  44. package/lib/go_amqp_client.py +263 -0
  45. package/lib/go_amqp_client_non_threaded.py +152 -0
  46. package/lib/go_amqp_host.py +348 -0
  47. package/lib/operators.py +16 -0
  48. package/lib/operators.ts +17 -0
  49. package/lib/params.ts +1 -0
  50. package/lib/vos.py +232 -0
  51. package/lib/vos.ts +212 -0
  52. package/package.json +36 -0
  53. package/requirements.txt +4 -0
  54. package/tests/units/README.md +12 -0
  55. package/tests/units/chalk/index.ts +41 -0
  56. package/tests/units/go.amqp.host.test.ts +116 -0
  57. package/tests/units/tests-vos/tasks-and-flows.vos.ts +128 -0
  58. package/tsconfig.json +45 -0
  59. package/v1 - GRPC/README.md +18 -0
  60. package/v1 - GRPC/node/README.md +13 -0
  61. package/v1 - GRPC/node/colaboflow_go_actionhost_client.ts +91 -0
  62. package/v1 - GRPC/node/colaboflow_go_actionhost_server.ts +84 -0
  63. package/v1 - GRPC/node/colaboflow_go_client.ts +82 -0
  64. package/v1 - GRPC/node/colaboflow_go_server.ts +84 -0
  65. package/v1 - GRPC/node/demos/demo-colaboflow_go_actionhost_client.ts +21 -0
  66. package/v1 - GRPC/node/index.ts +3 -0
  67. package/v1 - GRPC/node/package-lock.json +770 -0
  68. package/v1 - GRPC/node/package.json +30 -0
  69. package/v1 - GRPC/node/tsconfig.json +32 -0
  70. package/v1 - GRPC/node/yarn.lock +642 -0
  71. package/v1 - GRPC/protos/colabo/flow/go/go.proto +135 -0
  72. package/v1 - GRPC/python/DEVELOPMENT.md +86 -0
  73. package/v1 - GRPC/python/DISCUSSION.md +8 -0
  74. package/v1 - GRPC/python/LICENSE.txt +21 -0
  75. package/v1 - GRPC/python/README.md +45 -0
  76. package/v1 - GRPC/python/__init__.py +1 -0
  77. package/v1 - GRPC/python/colabo/__init__.py +3 -0
  78. package/v1 - GRPC/python/colabo/flow/__init__.py +3 -0
  79. package/v1 - GRPC/python/colabo/flow/go/__init__.py +12 -0
  80. package/v1 - GRPC/python/colabo/flow/go/basic/PuzzleImporter.py +77 -0
  81. package/v1 - GRPC/python/colabo/flow/go/basic/__init__.py +5 -0
  82. package/v1 - GRPC/python/colabo/flow/go/basic/colaboflow_go_basic.py +66 -0
  83. package/v1 - GRPC/python/colabo/flow/go/basic/parseFlowJSON.py +32 -0
  84. package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_actionhost.py +44 -0
  85. package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_client.py +48 -0
  86. package/v1 - GRPC/python/colabo/flow/go/colaboflow_go_demo.py +168 -0
  87. package/v1 - GRPC/python/colabo/flow/go/go_pb2.py +976 -0
  88. package/v1 - GRPC/python/colabo/flow/go/go_pb2_grpc.py +139 -0
  89. package/v1 - GRPC/python/colabo.flow.go.egg-info/PKG-INFO +58 -0
  90. package/v1 - GRPC/python/colabo.flow.go.egg-info/SOURCES.txt +16 -0
  91. package/v1 - GRPC/python/colabo.flow.go.egg-info/dependency_links.txt +1 -0
  92. package/v1 - GRPC/python/colabo.flow.go.egg-info/requires.txt +3 -0
  93. package/v1 - GRPC/python/colabo.flow.go.egg-info/top_level.txt +2 -0
  94. package/v1 - GRPC/python/demo-0.py +69 -0
  95. package/v1 - GRPC/python/demo-1.py +146 -0
  96. package/v1 - GRPC/python/demo-actionhost.py +47 -0
  97. package/v1 - GRPC/python/demo-basic.md +13 -0
  98. package/v1 - GRPC/python/demo-basic.py +38 -0
  99. package/v1 - GRPC/python/demo-executeActionSync.py +32 -0
  100. package/v1 - GRPC/python/demo-flows/flow-demo.json +36 -0
  101. package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-a.py +19 -0
  102. package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-b.py +21 -0
  103. package/v1 - GRPC/python/demo-puzzles/puzzles/puzzle-c.py +20 -0
  104. package/v1 - GRPC/python/requirements.txt +7 -0
  105. package/v1 - GRPC/python/setup.py +39 -0
  106. package/v1 - GRPC/python/use-cases/__init__.py +0 -0
@@ -0,0 +1,91 @@
1
+ // var fs = require('fs');
2
+ import * as fs from "fs";
3
+
4
+ // var chalk = require('chalk');
5
+ // import * as chalk from 'chalk';
6
+ import chalk from "chalk";
7
+ const parseArgs = require("minimist");
8
+ const _ = require("lodash");
9
+ const async = require("async");
10
+ // var grpc = require('grpc');
11
+ import * as grpc from "grpc";
12
+ // var protoLoader = require('@grpc/proto-loader');
13
+ import * as protoLoader from "@grpc/proto-loader";
14
+ // load the `*.proto` file with gRPC service definition
15
+
16
+ import { ActionExecuteRequestInterface, ActionExecuteRequestClass } from "@colabo-flow/i-go";
17
+
18
+ export class ColaboFlowGoActionHostClient {
19
+ protected gRpcColaboFlow: any;
20
+ protected socketUrl: string;
21
+ protected client: any;
22
+
23
+ constructor(socketUrl: string = "localhost:50801") {
24
+ this.socketUrl = socketUrl;
25
+
26
+ // relative to the dist folder
27
+ let PROTO_PATH = __dirname + "/../../protos/colabo/flow/go/go.proto";
28
+ console.log("__dirname: %s, PROTO_PATH: %s", __dirname, PROTO_PATH);
29
+ PROTO_PATH = fs.realpathSync(PROTO_PATH);
30
+ console.log("after fs.realpathSync: PROTO_PATH: %s", PROTO_PATH);
31
+
32
+ const packageDefinition = protoLoader.loadSync(
33
+ PROTO_PATH,
34
+ // Suggested options for similarity to existing grpc.load behavior
35
+ {
36
+ keepCase: true,
37
+ longs: String,
38
+ enums: String,
39
+ defaults: true,
40
+ oneofs: true,
41
+ }
42
+ );
43
+ // The protoDescriptor object has the full package hierarchy
44
+ const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
45
+ // we are getting the colaboFlow descriptor ...
46
+ this.gRpcColaboFlow = (<any>protoDescriptor.colabo).flow;
47
+
48
+ // and building stub client from the `colaboFlow.Go` class
49
+ // (similarly the service class used to create a server is in the `colaboFlow.Go.service` class)
50
+ this.client = new this.gRpcColaboFlow.ActionsHost(this.socketUrl, grpc.credentials.createInsecure());
51
+ }
52
+
53
+ executeAction(actionExecuteRequest: ActionExecuteRequestClass, callback?: Function) {
54
+ function finished(error, result) {
55
+ console.log("[executeAction] Result: ", result);
56
+ if (typeof callback === "function") {
57
+ callback(error, result);
58
+ }
59
+ }
60
+
61
+ this.client.executeAction(actionExecuteRequest, finished);
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Run the getFeature demo. Calls getFeature with a point known to have a
67
+ * feature and a point known not to have a feature.
68
+ * @param {function} callback Called when this demo is complete
69
+ */
70
+ // function submit(callback) {
71
+ // var next = _.after(2, callback);
72
+
73
+ // function featureCallback(error, result) {
74
+ // if (error) {
75
+ // callback(error);
76
+ // return;
77
+ // }
78
+ // console.log('Result: ' , result);
79
+ // next();
80
+ // }
81
+ // let request1 = {
82
+ // n1: 2,
83
+ // n2: 3
84
+ // };
85
+ // client.submit(request1, featureCallback);
86
+ // let request2 = {
87
+ // n1: 4,
88
+ // n2: 3
89
+ // };
90
+ // client.submit(request2, featureCallback);
91
+ // }
@@ -0,0 +1,84 @@
1
+ const MODULE_NAME: string = "@colabo-flow/s-go";
2
+
3
+ // var fs = require('fs');
4
+ import * as fs from "fs";
5
+
6
+ // var chalk = require('chalk');
7
+ // import * as chalk from 'chalk';
8
+ import chalk from "chalk";
9
+ const parseArgs = require("minimist");
10
+ const _ = require("lodash");
11
+ // var grpc = require('grpc');
12
+ import * as grpc from "grpc";
13
+ // var protoLoader = require('@grpc/proto-loader');
14
+ import * as protoLoader from "@grpc/proto-loader";
15
+
16
+ import { GetPuzzle } from "@colabo-utils/i-config";
17
+
18
+ import { RpcMethods, ActionExecuteRequestInterface, ActionExecuteRequestClass } from "@colabo-flow/i-go";
19
+
20
+ export class ColaboFlowGoActionHostServer {
21
+ protected gRpcServer: any;
22
+ protected rpcMethods: RpcMethods;
23
+ protected gRpcColaboFlow: any;
24
+ protected puzzleConfig: any;
25
+
26
+ constructor() {
27
+ this.puzzleConfig = GetPuzzle(MODULE_NAME);
28
+
29
+ // relative to the dist folder
30
+ let PROTO_PATH = __dirname + "/../../protos/colabo/flow/go/go.proto";
31
+ console.log("__dirname: %s, PROTO_PATH: %s", __dirname, PROTO_PATH);
32
+ PROTO_PATH = fs.realpathSync(PROTO_PATH);
33
+ console.log("after fs.realpathSync: PROTO_PATH: %s", PROTO_PATH);
34
+
35
+ // load the `*.proto` file with gRPC service definition
36
+ const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
37
+ keepCase: true,
38
+ longs: String,
39
+ enums: String,
40
+ defaults: true,
41
+ oneofs: true,
42
+ });
43
+ // The protoDescriptor object has the full package hierarchy
44
+ const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
45
+ // we are getting the colaboFlow descriptor ...
46
+ this.gRpcColaboFlow = (<any>protoDescriptor.colabo).flow;
47
+ }
48
+
49
+ init(rpcMethods: RpcMethods) {
50
+ this.rpcMethods = rpcMethods;
51
+ }
52
+
53
+ /**
54
+ * Get a new server with the handler functions in this file bound to the methods
55
+ * it serves.
56
+ * @return {Server} The new server object
57
+ */
58
+ protected getServer(): any {
59
+ const server = new grpc.Server();
60
+ server.addService(this.gRpcColaboFlow.ActionsHost.service, {
61
+ executeAction: this.executeActionWrapper.bind(this),
62
+ });
63
+ return server;
64
+ }
65
+
66
+ /**
67
+ * executeAction request handler. Gets a request with a point, and responds with a
68
+ * feature object indicating whether there is a feature at that point.
69
+ * @param {EventEmitter} call Call object for the handler to process
70
+ * @param {function(Error, feature)} callback Response callback
71
+ */
72
+ protected executeActionWrapper(call, callback) {
73
+ // first parameter equal to null indicates that there is no error
74
+ this.rpcMethods.executeAction(call.request, callback);
75
+ }
76
+
77
+ start() {
78
+ this.gRpcServer = this.getServer();
79
+ const gRpcUrl: string = this.puzzleConfig.gRpcUrl;
80
+ console.info("[%s] Starting service at %s", MODULE_NAME, gRpcUrl);
81
+ this.gRpcServer.bind(gRpcUrl, grpc.ServerCredentials.createInsecure());
82
+ this.gRpcServer.start();
83
+ }
84
+ }
@@ -0,0 +1,82 @@
1
+ // var fs = require('fs');
2
+ import * as fs from "fs";
3
+
4
+ // relative to the dist folder
5
+ let PROTO_PATH = __dirname + "/../../protos/colabo/flow/go/go.proto";
6
+ console.log("__dirname: %s, PROTO_PATH: %s", __dirname, PROTO_PATH);
7
+ PROTO_PATH = fs.realpathSync(PROTO_PATH);
8
+ console.log("after fs.realpathSync: PROTO_PATH: %s", PROTO_PATH);
9
+
10
+ // var chalk = require('chalk');
11
+ // import * as chalk from 'chalk';
12
+ import chalk from "chalk";
13
+ const parseArgs = require("minimist");
14
+ const _ = require("lodash");
15
+ const async = require("async");
16
+ // var grpc = require('grpc');
17
+ import * as grpc from "grpc";
18
+ // var protoLoader = require('@grpc/proto-loader');
19
+ import * as protoLoader from "@grpc/proto-loader";
20
+ // load the `*.proto` file with gRPC service definition
21
+ const packageDefinition = protoLoader.loadSync(
22
+ PROTO_PATH,
23
+ // Suggested options for similarity to existing grpc.load behavior
24
+ {
25
+ keepCase: true,
26
+ longs: String,
27
+ enums: String,
28
+ defaults: true,
29
+ oneofs: true,
30
+ }
31
+ );
32
+ // The protoDescriptor object has the full package hierarchy
33
+ const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
34
+ // we are getting the colaboFlow descriptor ...
35
+ const colaboFlow = protoDescriptor.colabo.flow;
36
+
37
+ // and building stub client from the `colaboFlow.Go` class
38
+ // (similarly the service class used to create a server is in the `colaboFlow.Go.service` class)
39
+ const client = new colaboFlow.Go("localhost:50505", grpc.credentials.createInsecure());
40
+
41
+ const COORD_FACTOR = 1e7;
42
+
43
+ /**
44
+ * Run the getFeature demo. Calls getFeature with a point known to have a
45
+ * feature and a point known not to have a feature.
46
+ * @param {function} callback Called when this demo is complete
47
+ */
48
+ function submit(callback) {
49
+ const next = _.after(2, callback);
50
+
51
+ function featureCallback(error, result) {
52
+ if (error) {
53
+ callback(error);
54
+ return;
55
+ }
56
+ console.log("Result: ", result);
57
+ next();
58
+ }
59
+ const request1 = {
60
+ n1: 2,
61
+ n2: 3,
62
+ };
63
+ client.submit(request1, featureCallback);
64
+ const request2 = {
65
+ n1: 4,
66
+ n2: 3,
67
+ };
68
+ client.submit(request2, featureCallback);
69
+ }
70
+
71
+ /**
72
+ * Run all of the demos in order
73
+ */
74
+ function main() {
75
+ async.series([submit]);
76
+ }
77
+
78
+ if (require.main === module) {
79
+ main();
80
+ }
81
+
82
+ exports.submit = submit;
@@ -0,0 +1,84 @@
1
+ const MODULE_NAME: string = "@colabo-flow/s-go";
2
+
3
+ // var fs = require('fs');
4
+ import * as fs from "fs";
5
+
6
+ // var chalk = require('chalk');
7
+ // import * as chalk from 'chalk';
8
+ import chalk from "chalk";
9
+ const parseArgs = require("minimist");
10
+ const _ = require("lodash");
11
+ // var grpc = require('grpc');
12
+ import * as grpc from "grpc";
13
+ // var protoLoader = require('@grpc/proto-loader');
14
+ import * as protoLoader from "@grpc/proto-loader";
15
+
16
+ import { GetPuzzle } from "@colabo-utils/i-config";
17
+
18
+ import { RpcMethods } from "@colabo-flow/i-go";
19
+
20
+ export class ColaboFlowGoServer {
21
+ protected gRpcServer: any;
22
+ protected rpcMethods: RpcMethods;
23
+ protected gRpcColaboFlow: any;
24
+ protected puzzleConfig: any;
25
+
26
+ constructor() {
27
+ this.puzzleConfig = GetPuzzle(MODULE_NAME);
28
+
29
+ // relative to the dist folder
30
+ let PROTO_PATH = __dirname + "/../../protos/colabo/flow/go/go.proto";
31
+ console.log("__dirname: %s, PROTO_PATH: %s", __dirname, PROTO_PATH);
32
+ PROTO_PATH = fs.realpathSync(PROTO_PATH);
33
+ console.log("after fs.realpathSync: PROTO_PATH: %s", PROTO_PATH);
34
+
35
+ // load the `*.proto` file with gRPC service definition
36
+ const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
37
+ keepCase: true,
38
+ longs: String,
39
+ enums: String,
40
+ defaults: true,
41
+ oneofs: true,
42
+ });
43
+ // The protoDescriptor object has the full package hierarchy
44
+ const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
45
+ // we are getting the colaboFlow descriptor ...
46
+ this.gRpcColaboFlow = (<any>protoDescriptor.colabo).flow;
47
+ }
48
+
49
+ init(rpcMethods: RpcMethods) {
50
+ this.rpcMethods = rpcMethods;
51
+ }
52
+
53
+ /**
54
+ * Get a new server with the handler functions in this file bound to the methods
55
+ * it serves.
56
+ * @return {Server} The new server object
57
+ */
58
+ protected getServer(): any {
59
+ const server = new grpc.Server();
60
+ server.addService(this.gRpcColaboFlow.FlowsHost.service, {
61
+ executeActionSync: this.executeActionSyncWrapper.bind(this),
62
+ });
63
+ return server;
64
+ }
65
+
66
+ /**
67
+ * executeActionSync request handler. Gets a request with a point, and responds with a
68
+ * feature object indicating whether there is a feature at that point.
69
+ * @param {EventEmitter} call Call object for the handler to process
70
+ * @param {function(Error, feature)} callback Response callback
71
+ */
72
+ protected executeActionSyncWrapper(call, callback) {
73
+ // first parameter equal to null indicates that there is no error
74
+ this.rpcMethods.executeActionSync(call.request, callback);
75
+ }
76
+
77
+ start() {
78
+ this.gRpcServer = this.getServer();
79
+ const gRpcUrl: string = this.puzzleConfig.gRpcUrl;
80
+ console.info("[%s] Starting service at %s", MODULE_NAME, gRpcUrl);
81
+ this.gRpcServer.bind(gRpcUrl, grpc.ServerCredentials.createInsecure());
82
+ this.gRpcServer.start();
83
+ }
84
+ }
@@ -0,0 +1,21 @@
1
+ import { ColaboFlowGoActionHostClient} from '../index';
2
+
3
+ import { ActionExecuteRequestInterface, ActionExecuteRequestClass } from '@colabo-flow/i-go';
4
+
5
+ // test python
6
+ let socketUrl:string = "localhost:50801";
7
+ // check-credentials @ ACE
8
+ // let socketUrl: string = "localhost:50901";
9
+ let colaboFlowGoActionHostClient: ColaboFlowGoActionHostClient = new ColaboFlowGoActionHostClient(socketUrl);
10
+
11
+ let actionExecuteRequest: ActionExecuteRequestClass = new ActionExecuteRequestClass();
12
+ actionExecuteRequest.name = 'search-sounds';
13
+ // actionExecuteRequest.name = 'check-authorization';
14
+
15
+ function finished(error, result) {
16
+ if (!error){
17
+ console.log("[demo::finished] Result: ", result);
18
+ }
19
+ }
20
+
21
+ colaboFlowGoActionHostClient.executeAction(actionExecuteRequest, finished);
@@ -0,0 +1,3 @@
1
+ export { ColaboFlowGoServer } from "./colaboflow_go_server";
2
+ export { ColaboFlowGoActionHostClient } from "./colaboflow_go_actionhost_client";
3
+ export { ColaboFlowGoActionHostServer } from "./colaboflow_go_actionhost_server";