-
Purpose:
Develop a Node.js application that runs once per day, retrieves events from a PostgreSQL database older than a configurable threshold (default one year), groups them by their UTC-created date, and exports each group as a CSV file. Each CSV is named in the formatevents_YYYY-MM-DD.csv
and stored in an Azure Data Lake under the foldertitan-pulse-event-archive
. After successful upload, the corresponding events are deleted from the database in one transaction. -
Deployment Environment:
The application will run in a Docker container (using a base imagenode:20-alpine3.18
) deployed as a Kubernetes CronJob scheduled daily at 02:00 AM UTC in an Azure Kubernetes Cluster.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result | start_position | date | circuit | name | constructor | |
---|---|---|---|---|---|---|
1.0 | 1.0 | 2008-03-16 | Albert Park Grand Prix Circuit | Lewis Hamilton | McLaren | |
2.0 | 5.0 | 2008-03-16 | Albert Park Grand Prix Circuit | Nick Heidfeld | BMW Sauber | |
3.0 | 7.0 | 2008-03-16 | Albert Park Grand Prix Circuit | Nico Rosberg | Williams | |
4.0 | 12.0 | 2008-03-16 | Albert Park Grand Prix Circuit | Fernando Alonso | Renault | |
5.0 | 3.0 | 2008-03-16 | Albert Park Grand Prix Circuit | Heikki Kovalainen | McLaren |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Column Name | Data Type | Constraints | |
---|---|---|---|
id | INTEGER | UNIQUE | |
scan_id | INTEGER | UNIQUE | |
created | TEXT | ||
updated | TEXT | ||
progress | INTEGER | ||
high_alerts | INTEGER | ||
medium_alerts | INTEGER | ||
low_alerts | INTEGER | ||
info_alerts | INTEGER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources: | |
requests: | |
cpu: 1500m | |
memory: 1024Mi | |
limits: | |
cpu: 8000m | |
memory: 2524Mi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (encodingInstructions.videoEncoder === constants.ENCODER_TYPES.X265) { | |
const ffmpegCommand = ffmpeg() | |
.input(inputAsset) | |
.videoBitrate(encodingInstructions.videoBitrate) | |
.videoCodec(encodingInstructions.videoEncoder) | |
.size(encodingInstructions.videoSize) | |
.audioCodec(encodingInstructions.audioEncoder) | |
.audioBitrate(encodingInstructions.audioBitrate) | |
.audioFrequency(encodingInstructions.audioFrequency) | |
.withOutputOptions('-force_key_frames "expr:gte(t,n_forced*2)"') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.processEncodingTasks = function processEncodingTasks() { | |
encoderEngine.searchTasks((searchErr, encoderInstructions) => { | |
if (!searchErr && encoderInstructions) { | |
log.info(`Got encoder instructions, started encoder for task '${encoderInstructions.name}' id:${encoderInstructions._id}`); | |
encoderEngine.startEncoder(encoderInstructions, (startErr) => { | |
if (!startErr) { | |
encoderEngine.setTaskToFinished(encoderInstructions._id, (finishErr) => { | |
if (finishErr) { | |
log.error(`An error occurred while trying to set the task to finished. ${finishErr.message}`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalingEngine.getNumberOfNeededEncoders = (numberOfEncodingTasks, numberOfEncoders) => { | |
if (numberOfEncodingTasks >= 0 && numberOfEncodingTasks <= 10) { | |
if (numberOfEncoders >= 1 && numberOfEncodingTasks < 1) { | |
return 0; | |
} | |
return numberOfEncoders; | |
} | |
if (numberOfEncodingTasks > 10 && numberOfEncodingTasks <= 50) { | |
if (numberOfEncoders < 4) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: encoderscaler | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: encoderscaler | |
strategy: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import k8s from '@kubernetes/client-node'; | |
import log from './log.js'; | |
const kubernetesClient = {}; | |
kubernetesClient.setNumberOfEncoders = async (numberOfEncoders) => { | |
try { | |
const kubeconfig = new k8s.KubeConfig(); | |
if (process.env.NODE_ENV === 'production') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16:9 aspect ratio | Bitrate | Frame rate | |
---|---|---|---|
416 x 234 | 145 | ≤ 30 fps | |
640 x 360 | 365 | ≤ 30 fps | |
768 x 432 | 730 | ≤ 30 fps | |
768 x 432 | 1100 | ≤ 30 fps | |
960 x 540 | 2000 | Same as source | |
1280 x 720 | 3000 | Same as source | |
1280 x 720 | 4500 | Same as source | |
1920 x 1080 | 6000 | Same as source | |
1920 x 1080 | 7800 | Same as source |
NewerOlder