envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.9k stars 4.79k forks source link

Envoy should be able to describe (Wasm) ABIs it supports #10395

Open yskopets opened 4 years ago

yskopets commented 4 years ago

Title: Envoy should be able to describe (Wasm) ABIs it supports

Context:

Proposal:

Example use cases:

Shikugawa commented 4 years ago

I think it is easy to implement this with a dynamic approach by fetching symbols with wasm_vm_->registerCallback and any other functionality to provide ABI support.

mattklein123 commented 4 years ago

Agreed. This is similar also for Envoy expressing what extensions it supports. cc @jpeach

yskopets commented 4 years ago

Here is the re-worked schema that is meant to meet the following requirements:

'@type': type.googleapis.com/envoy.data.abi.v3alpha.ABI
abis:
- name: proxy-wasm:0.1.0 # reference name 
  description: Wasm for Proxies (github.com/proxy-wasm/spec)

  abi: proxy-wasm # name of the ABI without a version component
  version:
    semantic:
      major: 0
      minor: 1
      patch: 0

  # ABI provided by host.
  host:
    # Module through which host ABI will be exposed to the extension.
    module: env

    functions: # use Wasm terms
    - name: proxy_log
      status: IMPLEMENTED # by default

    - name: proxy_get_configuration
      status: DEPRECATED # to flag the extensions that are still using this function

    - name: proxy_get_buffer

    - name: proxy_open_grpc_stream

  # ABI expected from the extension.
  extension:  
    functions: # use Wasm terms
    - name: proxy_abi_version_0_1_0
      implementation: MANDATORY # Envoy will reject those extensions that are not exposing this function

    - name: proxy_on_memory_allocate
      implementation: MANDATORY

    - name: proxy_on_vm_start
      implementation: OPTIONAL # by default

    - name: proxy_on_new_connection

- name: envoy.extensions.memory_management.basic.v1alpha0 # reference name 
  description: Wasm ABI for memory management in cross-boundary calls, i.e. Envoy => Extension and Extension => Envoy

  abi: envoy.extensions.memory_management.basic # name of the ABI without a version component
  version:
    grpc:
      major: v1
      stability: alpha0

  host: {} # ABI implemented only by the extension

  extension:
    functions:
    - name: envoy_extensions_memory_management_basic_v1alpha0_alloc # functions exposed by the extension must have fully qualified names
      implementation: MANDATORY

    - name: envoy_extensions_memory_management_basic_v1alpha0_realloc
      implementation: OPTIONAL

    - name: envoy_extensions_memory_management_basic_v1alpha0_free
      implementation: MANDATORY

- name: envoy.extensions.tracers.v1alpha0 # reference name 
  description: Wasm ABI for tracing providers

  abi: envoy.extensions.tracers # name of the ABI without a version component
  version:
    grpc:
      major: v1
      stability: alpha0

  memory:
    management: # memory management in cross-boundary calls, i.e. Envoy => Extension and Extension => Envoy
      abi: envoy.extensions.memory_management.basic.v1alpha0 # announces ABI for memory management (implicit dependency between ABIs)

  host: {} # ABI implemented only by the extension

  extension:
    functions:
    - name: envoy_extensions_tracers_v1alpha0_tracer_create # functions exposed by the extension must have fully qualified names
      implementation: MANDATORY

    - name: envoy_extensions_tracers_v1alpha0_tracer_destroy
      implementation: MANDATORY

    - name: envoy_extensions_tracers_v1alpha0_span_start
      implementation: MANDATORY

    - name: envoy_extensions_tracers_v1alpha0_span_set_operation

    - name: envoy_extensions_tracers_v1alpha0_span_set_tag

    - name: envoy_extensions_tracers_v1alpha0_span_finish
      implementation: MANDATORY

- name: envoy.sdk.udp.client.v1alpha0 # reference name 
  description: Wasm ABI for Envoys-specific features, such as UDP client

  abi: envoy.sdk.udp.client # name of the ABI without a version component
  version:
    grpc:
      major: v1
      stability: alpha0

  memory:
    management: # memory management in cross-boundary calls, i.e. Envoy => Extension and Extension => Envoy
      abi: envoy.extensions.memory_management.basic.v1alpha0 # announces ABI for memory management (implicit dependency between ABIs)

  host:
    # Module through which host ABI will be exposed to the extension.
    module: envoy.sdk.udp.client.v1alpha0

    functions:
    - name: create_client
      status: NOT_IMPLEMENTED # explicitly indicate that this ABI is not implemented yet

    - name: destroy_client
      status: NOT_IMPLEMENTED

    - name: send_message
      status: NOT_IMPLEMENTED

  extension: {} # ABI implemented only by the host