-
Notifications
You must be signed in to change notification settings - Fork 0
/
client-resource-pool.js
99 lines (73 loc) · 2.9 KB
/
client-resource-pool.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
define(['../../web/jsgui-html', './client-resource', './pool'],
function(jsgui, Resource, Resource_Pool) {
*/
// Got a lot of this code to delete / refresh / make more concise once things are more fully working.
// Especially regarding parse_mount and controls.
// Want to shrink down the package size a lot.
// Once the API is stable, could create a build that uses many local variables.
// Could make a build process that does that.
// Would be nice to make a core / small jsgui build that fits in 5KB compressed. 15 would be nice too etc.
// Much will be possible with abstractions over the patterns.
var jsgui = require('jsgui3-html');
//var Resource = require('./client-resource');
var Resource_Pool = jsgui.Resource_Pool;
const fnl = require('fnl');
const prom_or_cb = fnl.prom_or_cb;
// Client_Resource?
// I think that makes sense, so that we have something specific which has the URL attached.
// It is able to make HTTP requests to the server resource.
//const Data_Resource = require('./data-resource');
/*
var stringify = jsgui.stringify,
each = jsgui.each,
arrayify = jsgui.arrayify,
tof = jsgui.tof;
var filter_map_by_regex = jsgui.filter_map_by_regex;
var Class = jsgui.Class,
Data_Object = jsgui.Data_Object;
var fp = jsgui.fp,
is_defined = jsgui.is_defined;
var Collection = jsgui.Collection;
*/
//var exec = require('child_process').exec;
// Perhaps this will have HTTP endpoints as well?
// Maybe we can access it through url/resources/
// Perhaps a resource publisher, or a few of them could be useful.
// HTTP_Resource_Publisher?
// Generally publishes a resource over HTTP.
// Will have some authorization and authentication properties, hooked up with the proper providers.
// This may be the place in which remote access to the resources is given.
// It would make sense.
// Perhaps it is worth using a resource publisher? Then is that a resource?
// I think the resource pool may be the sensible point of access.
// Possibly all websocket communications for all client-side resources will go through the pool.
// May need to specify which server in particular we connect to over websocket.
// However, having front-end back-end servers could work well, that redirect to other servers, thereby providing one endpoint, and balance the load.
/*
var fields = {
'url': String
};
*/
class Client_Resource_Pool extends Resource_Pool {
//'fields': ,
constructor(spec) {
//this._super(spec);
super(spec);
// No need to start it in particular?
// Sometimes the data resource will operate over websockets
// Sometimes SSE would be better.
//let data_resource = new Data_Resource({
// 'name': 'Data Resource'
//});
//console.log('pre add data_resource', data_resource);
//this.add(data_resource);
}
'start'(callback) {
return prom_or_cb((resolve, reject) => {
//callback(null, true);
resolve(true);
}, callback);
}
}
module.exports = Client_Resource_Pool;