Skip to content

Commit 38bd6c1

Browse files
committed
reconcile merge conflicts
2 parents 7f8dba2 + 29ccd6b commit 38bd6c1

33 files changed

+442
-366
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,6 @@ yarn demo
120120
[downloads-image]: https://img.shields.io/npm/dm/@module-federation/aegis
121121
[downloads-url]: https://npmjs.org/package/@module-federation/aegis
122122
[gitpod-image]: https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod
123-
[gitpod-url]: https://gitpod.io/github.com/module-federation/aegis
123+
[gitpod-url]: https://gitpod.io/github.com/module-federation/aegis-app
124+
125+

__test__/use-cases/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exports.test = [
22
{
33
"name": "test",
44
"url": "http://localhost:8000/remmoteEntry.js",
5-
"path": "/Users/kylefahey/OCVIBE/module-federation/aegis/__test__/use-cases",
5+
"path": "/Users/tysonmidboe/aegis/__test__/use-cases",
66
"type": "model"
77
,
88
importRemote: () => import("test/models")

src/adapters/controllers/get-models.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
'use strict'
2+
import { Readable, Transform } from 'stream'
23
import getContent from './get-content'
34

5+
function isStream (models) {
6+
return (
7+
models?.length > 0 &&
8+
(models[0] instanceof Readable || models[0] instanceof Transform)
9+
)
10+
}
11+
412
/**
513
*
614
* @param {import("../use-cases/list-models").listModels} listModels
@@ -16,11 +24,8 @@ export default function getModelsFactory (listModels) {
1624
writable: httpRequest.res
1725
})
1826

19-
if (!models) {
20-
httpRequest.stream = true
21-
return
22-
}
23-
27+
if (isStream()) return
28+
2429
const { content, contentType } = getContent(httpRequest, models)
2530

2631
return {

src/adapters/controllers/http-adapter.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* @param {httpController} controller
1818
*/
19-
export default function buildCallback(controller) {
19+
export default function buildCallback (controller) {
2020
/**
2121
*/
2222
return async (req, res) => {
@@ -29,7 +29,7 @@ export default function buildCallback(controller) {
2929
path: req.path,
3030
res: res,
3131
headers: req.headers,
32-
log(func) {
32+
log (func) {
3333
console.info({
3434
function: func,
3535
ip: httpRequest.ip,
@@ -44,7 +44,6 @@ export default function buildCallback(controller) {
4444

4545
return controller(httpRequest)
4646
.then(httpResponse => {
47-
if (httpRequest.stream) return
4847
if (httpResponse.headers) {
4948
res.set(httpResponse.headers)
5049
}
@@ -55,4 +54,4 @@ export default function buildCallback(controller) {
5554
res.status(500).send({ error: 'An unkown error occurred.', e })
5655
)
5756
}
58-
}
57+
}

src/adapters/datasources/datasource-mongodb.js

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const connections = []
3434

3535
const mongoOpts = {
3636
//useNewUrlParser: true,
37-
useUnifiedTopology: true,
37+
//useUnifiedTopology: true
3838
}
3939

4040
/**
@@ -52,7 +52,7 @@ export class DataSourceMongoDb extends DataSource {
5252
this.url = url
5353
}
5454

55-
connect(client) {
55+
connect (client) {
5656
return async function () {
5757
let timeout = false
5858
const timerId = setTimeout(() => {
@@ -64,7 +64,24 @@ export class DataSourceMongoDb extends DataSource {
6464
}
6565
}
6666

67-
async connection() {
67+
async connectionPool () {
68+
return new Promise((resolve, reject) => {
69+
if (this.db) return resolve(this.db)
70+
MongoClient.connect(
71+
this.url,
72+
{
73+
...this.mongoOpts,
74+
poolSize: dsOptions.numConns || 2
75+
},
76+
(err, database) => {
77+
if (err) return reject(err)
78+
resolve((this.db = database.db(this.namespace)))
79+
}
80+
)
81+
})
82+
}
83+
84+
async connection () {
6885
try {
6986
while (connections.length < (dsOptions.numConns || 1)) {
7087
const client = new MongoClient(this.url, this.mongoOpts)
@@ -73,12 +90,12 @@ export class DataSourceMongoDb extends DataSource {
7390
errorRate: 1,
7491
callVolume: 1,
7592
intervalMs: 10000,
76-
testDelay: 300000,
93+
testDelay: 300000
7794
//fallbackFn: () => client.emit('connectionClosed')
78-
},
95+
}
7996
}
8097
const breaker = CircuitBreaker(
81-
'mongo.conn',
98+
'mongodb.connect',
8299
this.connect(client),
83100
thresholds
84101
)
@@ -224,15 +241,13 @@ export class DataSourceMongoDb extends DataSource {
224241
/**
225242
*
226243
* @param {Object} filter Supposed to be a valid Mongo Filter
227-
* @param {Object} options Options to sort limit aggregate etc...
228-
* @param {Object} options.sort a valid Mongo sort object
229-
* @param {Number} options.limit a valid Mongo limit
230-
* @param {Object} options.aggregate a valid Mongo aggregate object
244+
* @param {Object} sort a valid Mongo sort object
245+
* @param {Number} limit a valid Mongo limit
246+
* @param {Object} aggregate a valid Mongo aggregate object
231247
*
232-
* @returns
248+
* @returns {Promise<import('mongodb').AbstractCursor>}
233249
*/
234-
235-
async mongoFind({ filter, sort, limit, skip, aggregate } = {}) {
250+
async mongoFind ({ filter, sort, limit, aggregate, skip } = {}) {
236251
console.log({ fn: this.mongoFind.name, filter })
237252
let cursor = aggregate
238253
? (await this.collection()).aggregate(aggregate)
@@ -363,40 +378,12 @@ export class DataSourceMongoDb extends DataSource {
363378
}
364379

365380
/**
366-
* Returns the set of objects satisfying the `filter` if specified;
367-
* otherwise returns all objects. If a `writable`stream is provided and `cached`
368-
* is false, the list is streamed. Otherwise the list is returned in
369-
* an array. A custom transform can be specified to modify the streamed
370-
* results. Using {@link createWriteStream} updates can be streamed back
371-
* to the db. With streams, we can support queries of very large tables,
372-
* with minimal memory overhead on the node server.
373381
*
374382
* @override
375-
* @param {{key1:string, keyN:string}} filter - e.g. http query
376-
* @param {{
377-
* writable: WritableStream,
378-
* cached: boolean,
379-
* serialize: boolean,
380-
* transform: Transform
381-
* }} params
382-
* - details
383-
* - `serialize` seriailize input to writable
384-
* - `cached` list cache only
385-
* - `transform` transform stream before writing
386-
* - `writable` writable stream for output
383+
* @param {import('../../domain/datasource').listOptions} param
387384
*/
388-
async list(param = {}) {
389-
const {
390-
writable = null,
391-
transform = null,
392-
serialize = false,
393-
query = {},
394-
} = param
395-
let result
385+
async list (param) {
396386
try {
397-
if (query.__cached) return super.listSync(query)
398-
if (query.__count) return this.count()
399-
400387
const options = this.processOptions(param)
401388
if (0 < ~~query.__page) {
402389
// qpm > processOptions weeds out __page - add it back properly as an integer
@@ -433,7 +420,11 @@ export class DataSourceMongoDb extends DataSource {
433420
}
434421
}
435422

436-
async count() {
423+
/**
424+
*
425+
* @override
426+
*/
427+
async count () {
437428
return {
438429
total: await this.countDb(),
439430
cached: this.getCacheSize(),
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)