sync mode on
This commit is contained in:
1 parent
1818932244
commit
1174b328e5
415 files changed
+44294
-1182
No files matched your search
+22
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
const build = require('../..')
|
||||
|
||||
module.exports = async function (threadStreamOpts) {
|
||||
const { port, opts = {} } = threadStreamOpts
|
||||
return build(
|
||||
async function (source) {
|
||||
for await (const obj of source) {
|
||||
port.postMessage({
|
||||
data: obj,
|
||||
pinoConfig: {
|
||||
levels: source.levels,
|
||||
messageKey: source.messageKey,
|
||||
errorKey: source.errorKey
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
opts
|
||||
)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
const build = require('../..')
|
||||
|
||||
module.exports = async function (threadStreamOpts) {
|
||||
const { port, opts = {} } = threadStreamOpts
|
||||
return build(
|
||||
function (source) {
|
||||
source.on('data', function (line) {
|
||||
port.postMessage({
|
||||
data: line,
|
||||
pinoConfig: {
|
||||
levels: source.levels,
|
||||
messageKey: source.messageKey,
|
||||
errorKey: source.errorKey
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
opts
|
||||
)
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
|
||||
const { Transform, pipeline } = require('stream')
|
||||
const build = require('../..')
|
||||
|
||||
module.exports = function (threadStreamOpts) {
|
||||
const { opts = {} } = threadStreamOpts
|
||||
return build(function (source) {
|
||||
const transform = new Transform({
|
||||
objectMode: true,
|
||||
autoDestroy: true,
|
||||
transform (chunk, enc, cb) {
|
||||
chunk.service = 'from transform'
|
||||
chunk.level = `${source.levels.labels[chunk.level]}(${chunk.level})`
|
||||
chunk[source.messageKey] = chunk[source.messageKey].toUpperCase()
|
||||
cb(null, JSON.stringify(chunk) + '\n')
|
||||
}
|
||||
})
|
||||
|
||||
pipeline(source, transform, () => {})
|
||||
|
||||
return transform
|
||||
}, { ...opts, enablePipelining: true })
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
'use strict'
|
||||
|
||||
const { pipeline, PassThrough } = require('stream')
|
||||
|
||||
module.exports = async function ({ targets }) {
|
||||
const streams = await Promise.all(targets.map(async (t) => {
|
||||
const fn = require(t.target)
|
||||
const stream = await fn(t.options)
|
||||
return stream
|
||||
}))
|
||||
|
||||
const stream = new PassThrough()
|
||||
pipeline(stream, ...streams, () => {})
|
||||
return stream
|
||||
}
|
||||
Reference in new issue
Block a user