Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Motion Bank
Services
Transcoder
Commits
78e1e6d3
Commit
78e1e6d3
authored
Jun 07, 2019
by
Anton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add conversion responder
parent
d7a066ca
Pipeline
#12128
passed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
src/lib/responders/conversion.js
src/lib/responders/conversion.js
+42
-0
No files found.
src/lib/responders/conversion.js
0 → 100644
View file @
78e1e6d3
const
config
=
require
(
'
config
'
),
Queue
=
require
(
'
bull
'
),
{
DateTime
}
=
require
(
'
luxon
'
),
{
ObjectUtil
}
=
require
(
'
mbjs-utils
'
),
cote
=
require
(
'
cote
'
)
const
init
=
async
function
()
{
const
queue
=
new
Queue
(
'
conversions
'
,
config
.
conversions
.
redisURL
),
conversionService
=
new
cote
.
Responder
({
name
:
'
Conversion Service
'
})
queue
.
process
(
parseInt
(
config
.
conversions
.
concurrency
),
require
(
'
../workers/convert
'
))
conversionService
.
on
(
'
start
'
,
(
req
,
cb
)
=>
{
const
jobId
=
ObjectUtil
.
uuid4
()
queue
.
add
(
req
,
{
jobId
})
cb
({
jobId
})
})
conversionService
.
on
(
'
status
'
,
async
(
req
,
cb
)
=>
{
const
job
=
await
queue
.
getJob
(
req
.
id
)
if
(
!
job
)
return
cb
(
null
)
const
jobInfo
=
{
uuid
:
job
.
id
,
source
:
job
.
data
.
source
,
result
:
job
.
returnvalue
,
failed
:
typeof
job
.
failedReason
!==
'
undefined
'
,
attempts
:
job
.
attemptsMade
,
progress
:
job
.
progress
,
delay
:
job
.
delay
,
created
:
DateTime
.
fromMillis
(
job
.
timestamp
).
toISO
(),
processed
:
job
.
processedOn
?
DateTime
.
fromMillis
(
job
.
processedOn
).
toISO
()
:
undefined
,
finished
:
job
.
finishedOn
?
DateTime
.
fromMillis
(
job
.
finishedOn
).
toISO
()
:
undefined
}
cb
(
jobInfo
)
})
}
init
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment