Skip to content

Expose a new invoke function via gRPC from Worker Executor for incoming HTTP requests #1184

@vigoo

Description

@vigoo

This is the first step in supporting workers implementing the wasi-http incoming-handler interface (https://wa.dev/wasi:http#incoming-handler).

The primary challenge is that this interface takes an incoming-request handle to a host resource, and returns with a outgoing-response handle to a host resource, which is not something we can directly invoke using Golem's existing invokation API.

Instead, as part of this ticket, we define:

  • A gRPC definition of HTTP request->response handler, using gRPC streaming for the request and response body
  • A special invocation mode in worker executor, wrapping the existing one (on the level of invocation.rs) that does the following:
    • Take the request information (coming via gRPC) and set up a host incoming-resource instance
    • Invoke the worker's exported wasi:http/incoming-handler:{handle} function with this resource
    • Take the returned outgoing-response resource and convert it back to the protobuf response structure
  • This new invocation mode needs to be implemented on all layers (Worker, including the invocation loop) and wired to the gRPC handler
  • To make the scope of the task smaller, it is enough for this ticket to NOT do actual request/response body streaming
  • Likely requires changes to the oplog too (to be decided by the implementor), some options:
    • Maybe it is possible to not introduce new invocation start/end entries, but instead use the existing ones, converting the request/response data to Value. Or maybe it is easier to have dedicated new ones. Think of the current ExportedFunctionInvoked, ExportedFunctionCompleted and PendingWorkerInvocation entries.
  • Support this new call in the test DSL
  • Write worker executor test(s) proving this works

With this ticket done we can call worker executor using a representation of a "http request" and get back a representation of a "http response", while the worker itself exports only the wasi-http incoming handler interface.

Follow-up tickets add streaming support and wires this functionality into the worker bridge.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions