Skip to content

Commit 631b984

Browse files
committed
Add FFI documentation to api_overview.md
Signed-off-by: Michael Warres <[email protected]>
1 parent b3b6cd4 commit 631b984

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

docs/api_overview.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ plugin:
7474
7575
* `validateConfiguration`: May be called to validate the configuration data that
7676
will be passed to a plugin on startup, e.g. in the control plane.
77+
* `onCreate`: called when context is created.
7778
* `onStart`: called on plugin start.
7879
* `onConfigure`: called on plugin start, and any time configuration subsequently
7980
changes.
@@ -371,6 +372,22 @@ for representing and updating metrics:
371372
Metrics can be subdivided by tags, using similar structure to [Envoy
372373
statistics](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/statistics).
373374
375+
## Foreign function interface (FFI)
376+
377+
Hosts can make additional hostcalls available for plugins to call via the
378+
foreign function interface. Plugin code can invoke such hostcalls via the
379+
`proxy_call_foreign_function` hostcall defined in [proxy_wasm_externs.h], which
380+
specifies the foreign hostcall to invoke by a string name.
381+
382+
Hosts can also invoke callbacks for events outside of those defined by the
383+
Proxy-Wasm spec, which are dispatched to the plugin via calls to
384+
`ContextBase::onForeignFunction`. These calls use an integer function ID to
385+
identify the foreign callback to invoke.
386+
387+
With both foreign hostcalls and callbacks, the plugin and host must agree
388+
out-of-band on what hostcalls/callbacks will be available. For API details, see
389+
associated doc comments in [proxy_wasm_externs.h] and [proxy_wasm_api.h].
390+
374391
## Example
375392
376393
Some of the concepts and APIs described above are illustrated by the example
@@ -430,10 +447,9 @@ The main files containing the Proxy-Wasm C++ SDK API and implementation are
430447
listed below:
431448

432449
* [proxy_wasm_api.h]: main SDK API definition and implementation
450+
* [proxy_wasm_externs.h]: declarations for ABI-level hostcalls and callbacks
433451
* [proxy_wasm_common.h](../proxy_wasm_common.h): supporting types for the API
434452
* [proxy_wasm_enums.h](../proxy_wasm_enums.h): supporting enums for the API
435-
* [proxy_wasm_externs.h](../proxy_wasm_externs.h): declarations for ABI-level
436-
hostcalls and callbacks
437453
* [proxy_wasm_intrinsics.js](../proxy_wasm_intrinsics.js): list of Proxy-Wasm
438454
ABI hostcalls, for use by [Emscripten](https://emscripten.org)
439455
* [proxy_wasm_intrinsics.proto](../proxy_wasm_intrinsics.proto): protobuf types
@@ -451,4 +467,5 @@ listed below:
451467
[HTTP callouts]: #http-callouts
452468
[gRPC callouts]: #grpc-callouts
453469
[proxy_wasm_api.h]: ../proxy_wasm_api.h
470+
[proxy_wasm_externs.h]: ../proxy_wasm_externs.h
454471
[http_wasm_example.cc]: ../example/http_wasm_example.cc

0 commit comments

Comments
 (0)