Skip to content
File

Blob: src/workerd/io/worker-entrypoint.h

cpp53 lines
1// Copyright (c) 2017-2022 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5#pragma once
6 
7#include <workerd/io/frankenvalue.h>
8#include <workerd/io/worker.h>
9 
10namespace workerd {
11 
12class IoChannelFactory;
13class LimitEnforcer;
14class RequestObserver;
15class ThreadContext;
16class WorkerInterface;
17class BaseTracer;
18 
19namespace tracing {
20class InvocationSpanContext;
21};
22 
23// Create and return a wrapper around a Worker that handles receiving a new event
24// from the outside. In particular,
25// this handles:
26// - Creating a IoContext and making it current.
27// - Executing the worker under lock.
28// - Catching exceptions and converting them to HTTP error responses.
29// - Or, falling back to proxying if passThroughOnException() was used.
30// - Finish waitUntil() tasks.
31kj::Own<WorkerInterface> newWorkerEntrypoint(ThreadContext& threadContext,
32 kj::Own<const Worker> worker,
33 kj::Maybe<kj::StringPtr> entrypointName,
34 Frankenvalue props,
35 kj::Maybe<kj::Own<Worker::Actor>> actor,
36 kj::Own<LimitEnforcer> limitEnforcer,
37 kj::Own<void> ioContextDependency,
38 kj::Own<IoChannelFactory> ioChannelFactory,
39 kj::Own<RequestObserver> metrics,
40 kj::TaskSet& waitUntilTasks,
41 bool tunnelExceptions,
42 kj::Maybe<kj::Own<BaseTracer>> workerTracer,
43 kj::Maybe<kj::String> cfBlobJson,
44 kj::Maybe<Worker::VersionInfo> versionInfo,
45 // The trigger invocation span may be propagated from other request. If it is provided,
46 // the implication is that this worker entrypoint is being created as a subrequest or
47 // subtask of another request. If it is kj::none, then this invocation is a top-level
48 // invocation.
49 kj::Maybe<tracing::InvocationSpanContext> maybeTriggerInvocationSpan = kj::none,
50 bool isDynamicDispatch = false);
51 
52} // namespace workerd