Skip to content

Commit

Permalink
Allow mapping of entrypoint arguments in bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiancook committed Dec 23, 2023
1 parent 68ae650 commit ad5559f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/worker/service-worker/configure/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface Service extends ScriptWorker, WorkerOptions {

export interface ServiceEntrypoint extends Service {
entrypoint?: string;
entrypointArguments?: string[];
}

export interface NamedService extends Service {
Expand Down Expand Up @@ -121,7 +122,8 @@ const example: Config = {
name: "./requested/resource.json",
service: {
name: "named",
entrypoint: "getRequestedResource"
entrypoint: "getRequestedResource",
entrypointArguments: ["request", "$event", "SPECIAL_CONTEXT_KEY"]
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/worker/service-worker/execute-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {ServiceWorkerWorkerData} from "./worker";
export interface ServiceWorkerFetchOptions {
tag?: string;
entrypoint?: string;
entrypointArguments?: string[];
dispatch?: string | DurableEventData;
}

Expand Down Expand Up @@ -66,6 +67,7 @@ export async function executeServiceWorkerFetch(registration: DurableServiceWork
virtual: true,
dispatch: options?.dispatch,
entrypoint: options?.entrypoint,
entrypointArguments: options?.entrypointArguments
}, serviceWorkerInit);
}

Expand Down
3 changes: 2 additions & 1 deletion src/worker/service-worker/worker-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export function createServiceWorkerWorkerFetch(data: ServiceWorkerWorkerData, se
const entrypoint = getBindingServiceEntrypoint(binding);
return fetch(input, {
...init,
entrypoint: entrypoint.entrypoint
entrypoint: entrypoint.entrypoint,
entrypointArguments: entrypoint.entrypointArguments
});
}

Expand Down

0 comments on commit ad5559f

Please sign in to comment.