Skip to content

Commit

Permalink
Remove unused handleQueue() function from entry worker (#678)
Browse files Browse the repository at this point in the history
With #656, the Queues dispatcher is now implemented as part of the
broker Durable Object. We no longer send message batches directly
from Node.js, so can remove queue handling from the entry worker.

Note the magic proxy enqueues messages through queue producer
bindings like regular workers, so never used this endpoint directly.
  • Loading branch information
mrbbot committed Nov 1, 2023
1 parent dafa328 commit 5d62f2b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26 deletions.
4 changes: 1 addition & 3 deletions packages/miniflare/src/plugins/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,7 @@ export function getGlobalServices({
durableObjectNamespace: { className: "ProxyServer" },
},
// Add `proxyBindings` here, they'll be added to the `ProxyServer` `env`.
// It would be nice if we didn't add all these bindings to the entry worker,
// but the entry worker shares lots of `devalue` code with the proxy, and
// we'd rather not duplicate that.
// TODO(someday): consider making the proxy server a separate worker
...proxyBindings,
];
if (sharedOptions.upstream !== undefined) {
Expand Down
1 change: 0 additions & 1 deletion packages/miniflare/src/workers/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const CoreHeaders = {
ORIGINAL_URL: "MF-Original-URL",
ERROR_STACK: "MF-Experimental-Error-Stack",
ROUTE_OVERRIDE: "MF-Route-Override",
CUSTOM_EVENT: "MF-Custom-Event",

// API Proxy
OP: "MF-Op",
Expand Down
22 changes: 0 additions & 22 deletions packages/miniflare/src/workers/core/entry.worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { unflatten } from "devalue";
import {
Colorize,
blue,
Expand All @@ -11,7 +10,6 @@ import {
} from "kleur/colors";
import { LogLevel, SharedHeaders } from "miniflare:shared";
import { CoreBindings, CoreHeaders } from "./constants";
import { structuredSerializableRevivers } from "./devalue";
import { STATUS_CODES } from "./http";
import { WorkerRoute, matchRoutes } from "./routing";

Expand Down Expand Up @@ -188,21 +186,6 @@ function handleProxy(request: Request, env: Env) {
return stub.fetch(request);
}

async function handleQueue(
request: Request,
url: URL,
service: Fetcher,
startTime: number
) {
const queueName = decodeURIComponent(url.pathname.substring(1));
const flattened = await request.json<number | unknown[]>();
const messages = unflatten(flattened, structuredSerializableRevivers);
const queueResponse = await service.queue(queueName, messages);
(queueResponse as FetcherQueueResult & { time: number }).time =
Date.now() - startTime;
return Response.json(queueResponse);
}

async function handleScheduled(
params: URLSearchParams,
service: Fetcher
Expand Down Expand Up @@ -243,11 +226,6 @@ export default <ExportedHandler<Env>>{
}

try {
const customEvent = request.headers.get(CoreHeaders.CUSTOM_EVENT);
if (customEvent === "queue") {
return await handleQueue(request, url, service, startTime);
}

if (url.pathname === "/cdn-cgi/mf/scheduled") {
return await handleScheduled(url.searchParams, service);
}
Expand Down

0 comments on commit 5d62f2b

Please sign in to comment.