Skip to content

Commit

Permalink
feat(cdp): Track empty cyclotron batches (#25167)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Sep 24, 2024
1 parent 28dfcae commit 2b05544
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugin-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@
},
"cyclotron": {
"//This is a short term workaround to ensure that cyclotron changes trigger a rebuild": true,
"version": "0.1.5"
"version": "0.1.6"
}
}
1 change: 1 addition & 0 deletions plugin-server/src/cdp/cdp-consumers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ export class CdpCyclotronWorker extends CdpConsumerBase {
includeVmState: true,
batchMaxSize: this.hub.CDP_CYCLOTRON_BATCH_SIZE,
pollDelayMs: this.hub.CDP_CYCLOTRON_BATCH_DELAY_MS,
includeEmptyBatches: true,
})
await this.cyclotronWorker.connect((jobs) => this.handleJobBatch(jobs))
}
Expand Down
2 changes: 1 addition & 1 deletion rust/cyclotron-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@posthog/cyclotron",
"version": "0.1.5",
"version": "0.1.6",
"description": "Node bindings for cyclotron",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions rust/cyclotron-node/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type CyclotronWorkerConfig = {
pollDelayMs?: number
/** Heartbeat timeout. After this time without response from the worker loop the worker will be considered unhealthy. Default 30000 */
heartbeatTimeoutMs?: number
/** Include empty batches - useful if you want to track them. Default: false */
includeEmptyBatches?: boolean
}

export class CyclotronWorker {
Expand Down Expand Up @@ -93,6 +95,9 @@ export class CyclotronWorker {
if (!jobs.length) {
// Wait a bit before polling again
await new Promise((resolve) => setTimeout(resolve, pollDelayMs))
if (!this.config.includeEmptyBatches) {
await processBatch(jobs)
}
continue
}

Expand Down

0 comments on commit 2b05544

Please sign in to comment.