Skip to content

ABI vNEXT: generic vs specialized context functions #9

Closed

Description

@PiotrSikora

The current version of the ABI defines generic proxy_on_context_create() and proxy_on_context_finalize() functions which are used for VM and plugin lifecycle, as well as for per-stream lifecycle, which makes "context" a bit overloaded and confusing.

For VM context:

proxy_on_context_create(VmContext, ...)
proxy_on_vm_start(...)
proxy_on_context_finalize(...)

For plugin context:

proxy_on_context_create(PluginContext, ...)
proxy_on_plugin_start(...)
proxy_on_context_finalize(...)

For HTTP per-stream context:

proxy_on_context_create(HttpContext, ...)
proxy_on_http_request_headers(...)
proxy_on_http_request_body(...)
proxy_on_http_response_headers(...)
proxy_on_http_response_body(...)
proxy_on_context_finalize(...)

Instead, we could have specialized "finalize" functions for each context type, and create context implicitly as part of each "start" function:

For VM context:

proxy_on_vm_start(...)
proxy_on_vm_shutdown(...)

For plugin context:

proxy_on_plugin_start(...)
proxy_on_plugin_shutdown(...)

For HTTP per-stream context:

proxy_on_http_request_headers(...)
proxy_on_http_request_body(...)
proxy_on_http_response_headers(...)
proxy_on_http_response_body(...)
proxy_on_http_finalize(...)

In case proxy_on_http_finalize() returns Action::Pause, the host would wait until proxy_resume() is called before calling proxy_on_http_finalize() again (which matches the behavior of other callbacks that have the ability to pause/resume processing).

@mattklein123 @htuch @yskopets @yuval-k @gbrail @jplevyak @kyessenov any thoughts?

Activity

  1. htuch commented on Aug 26, 2020

    @htuch

    Seems a slam dunk interface improvement.

  2. mattklein123 commented on Aug 26, 2020

    @mattklein123
    Collaborator

    Huge +1 from me. I think this is one of the things that I initially commented on.

  3. kyessenov commented on Aug 26, 2020

    @kyessenov

    +1 as a user. Using the same callback is really problematic when one plugin serves in different roles (which might be common to save on resources by reusing the VM/module).

    I think this will need pausable access log extensions in envoy.

  4. added this to the v0.3.0 milestone on Aug 11, 2024
  5. PiotrSikora commented on May 21, 2026

    @PiotrSikora
    MemberAuthor

    As discussed in the Proxy-Wasm meeting on 2/19, we're going to keep the generic interface with added context_type to avoid overloading "context" everywhere and to keep the ABI extensible with other context types in the future.

    Related: #80 (Consistent style in the ABI (expanded vs minimal)).

    cc @mpwarres @leonm1

  6. linked a pull request that will close this issueSplit up plugin and stream contexts. #110on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions