@@ -19,9 +19,57 @@ import (
1919 "github.com/proxy-wasm/proxy-wasm-go-sdk/proxywasm/types"
2020)
2121
22- // SetVMContext is the entrypoint for setting up the entire Wasm VM.
23- // Please make sure to call this entrypoint during "main()" function;
24- // otherwise, the VM fails.
22+ // SetVMContext is one possible entrypoint for setting up the entire Wasm VM.
23+ //
24+ // Subsequent calls to any entrypoint overwrite previous calls to any
25+ // entrypoint. Be sure to call exactly one entrypoint during `init()`,
26+ // otherwise the VM fails.
2527func SetVMContext (ctx types.VMContext ) {
2628 internal .SetVMContext (ctx )
2729}
30+
31+ // SetPluginContext is one possible entrypoint for setting up the Wasm VM.
32+ //
33+ // Subsequent calls to any entrypoint overwrite previous calls to any
34+ // entrypoint. Be sure to call exactly one entrypoint during `init()`,
35+ // otherwise the VM fails.
36+ //
37+ // Using SetPluginContext instead of SetVmContext is suitable iff the plugin
38+ // does not make use of the VM configuration provided during `VmContext`'s
39+ // `OnVmStart` call (plugin configuration data is still provided during
40+ // `PluginContext`'s `OnPluginStart` call).
41+ func SetPluginContext (newPluginContext func (contextID uint32 ) types.PluginContext ) {
42+ internal .SetPluginContext (newPluginContext )
43+ }
44+
45+ // SetHttpContext is one possible entrypoint for setting up the Wasm VM. It
46+ // allows plugin authors to provide an Http context implementation without
47+ // writing a VmContext or PluginContext.
48+ //
49+ // Subsequent calls to any entrypoint overwrite previous calls to any
50+ // entrypoint. Be sure to call exactly one entrypoint during `init()`,
51+ // otherwise the VM fails.
52+ //
53+ // SetHttpContext is suitable for stateless plugins that share no state between
54+ // HTTP requests, do not process TCP streams, have no expensive shared setup
55+ // requiring execution during `OnPluginStart`, and do not access the plugin
56+ // configuration data.
57+ func SetHttpContext (newHttpContext func (contextID uint32 ) types.HttpContext ) {
58+ internal .SetHttpContext (newHttpContext )
59+ }
60+
61+ // SetTcpContext is one possible entrypoint for setting up the Wasm VM. It
62+ // allows plugin authors to provide a TCP context implementation without
63+ // writing a VmContext or PluginContext.
64+ //
65+ // Subsequent calls to any entrypoint overwrite previous calls to any
66+ // entrypoint. Be sure to call exactly one entrypoint during `init()`,
67+ // otherwise the VM fails.
68+ //
69+ // SetTcpContext is suitable for stateless plugins that share no state between
70+ // TCP streams, do not process HTTP requests, have no expensive shared setup
71+ // requiring execution during `OnPluginStart`, and do not access the plugin
72+ // configuration data.
73+ func SetTcpContext (newTcpContext func (contextID uint32 ) types.TcpContext ) {
74+ internal .SetTcpContext (newTcpContext )
75+ }
0 commit comments