Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Hono } from "hono";

const INSTANCE_COUNT = 2;

export class MiniRuntimeContainer extends Container {
export class MiniRuntimeContainerEvenup extends Container {
// Port the container listens on (default: 8080)
defaultPort = 8080;
// Time before container sleeps due to inactivity (default: 30s)
Expand Down Expand Up @@ -40,8 +40,8 @@ export class MiniRuntimeContainer extends Container {

// Create Hono app with proper typing for Cloudflare Workers
type Environment = {
readonly MINI_RUNTIME_CONTAINER: DurableObjectNamespace<MiniRuntimeContainer>
readonly AKTO_TRAFFIC_QUEUE: Queue<any>
readonly MINI_RUNTIME_CONTAINER_EVENUP: DurableObjectNamespace<MiniRuntimeContainerEvenup>
readonly AKTO_TRAFFIC_QUEUE_EVENUP: Queue<any>
}
const app = new Hono<{
Bindings: Environment;
Expand Down Expand Up @@ -101,9 +101,9 @@ export default {
const normalized = normalizeBatchData({ batchData: payload })
const result = JSON.stringify(normalized)

const containerInstance = getRandom(env.MINI_RUNTIME_CONTAINER, INSTANCE_COUNT)
const containerId = env.MINI_RUNTIME_CONTAINER.idFromName(`/container/${containerInstance}`)
const container = env.MINI_RUNTIME_CONTAINER.get(containerId)
const containerInstance = getRandom(env.MINI_RUNTIME_CONTAINER_EVENUP, INSTANCE_COUNT)
const containerId = env.MINI_RUNTIME_CONTAINER_EVENUP.idFromName(`/container/${containerInstance}`)
const container = env.MINI_RUNTIME_CONTAINER_EVENUP.get(containerId)

const req = new Request("http://internal/upload", {
method: "POST",
Expand All @@ -126,14 +126,14 @@ export default {

// 🔒 requeue each message one by one before next batch
for (const m of batchSlice) {
await env.AKTO_TRAFFIC_QUEUE.send(m.body)
await env.AKTO_TRAFFIC_QUEUE_EVENUP.send(m.body)
}
}
} catch (err) {
console.error("Error sending messages to container:", err)

for (const m of batchSlice) {
await env.AKTO_TRAFFIC_QUEUE.send(m.body)
await env.AKTO_TRAFFIC_QUEUE_EVENUP.send(m.body)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "mini-runtime-worker",
"name": "mini-runtime-worker-evenup",
"main": "src/index.ts",
"compatibility_date": "2025-05-23",
"compatibility_flags": [
Expand All @@ -15,25 +15,25 @@
},
"containers": [
{
"class_name": "MiniRuntimeContainer",
"class_name": "MiniRuntimeContainerEvenup",
"image": "registry.cloudflare.com/53a10bdb35f546522193c9670ad3e7e5/mr:nayan",
"max_instances": 2,
"instance_type": "standard",
"name": "mini-runtime-containers"
"name": "mini-runtime-containers-evenup"
}
],
"durable_objects": {
"bindings": [
{
"class_name": "MiniRuntimeContainer",
"name": "MINI_RUNTIME_CONTAINER"
"class_name": "MiniRuntimeContainerEvenup",
"name": "MINI_RUNTIME_CONTAINER_EVENUP"
}
]
},
"queues": {
"consumers": [
{
"queue": "akto-traffic-queue",
"queue": "akto-traffic-queue-evenup",
"max_batch_size": 5,
"max_batch_timeout": 30,
"max_retries": 3,
Expand All @@ -43,7 +43,7 @@
"migrations": [
{
"new_sqlite_classes": [
"MiniRuntimeContainer"
"MiniRuntimeContainerEvenup"
],
"tag": "v1"
}
Expand Down