wasm

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Layotto Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const AbiV2 = "proxy_abi_version_0_2_0"
View Source
const LayottoWasm = "Layotto"

Variables

This section is empty.

Functions

This section is empty.

Types

type AbiV2Impl

type AbiV2Impl struct {
	v1.ABIContext
}

easy for extension

func (*AbiV2Impl) GetABIExports added in v0.2.0

func (a *AbiV2Impl) GetABIExports() interface{}

Get abi

func (*AbiV2Impl) Name

func (a *AbiV2Impl) Name() string

Get abi name

func (*AbiV2Impl) ProxyGetID added in v0.2.0

func (a *AbiV2Impl) ProxyGetID() (string, error)

Get id

type Exports added in v0.2.0

type Exports interface {
	proxywasm.Exports

	// ProxyGetID return the id
	ProxyGetID() (string, error)
}

type Filter

type Filter struct {
	LayottoHandler
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter(ctx context.Context, factory *FilterConfigFactory) *Filter

NewFilter create the filter for a request

func (*Filter) Append

func (f *Filter) Append(ctx context.Context, headers api.HeaderMap, buf buffer.IoBuffer, trailers api.HeaderMap) api.StreamFilterStatus

Append ResponseData of filter

func (*Filter) GetHttpRequestBody

func (f *Filter) GetHttpRequestBody() common.IoBuffer

Get the HttpRequest body of proxy-wasm

func (*Filter) GetHttpRequestHeader

func (f *Filter) GetHttpRequestHeader() common.HeaderMap

Get the HttpRequest header of proxy-wasm

func (*Filter) GetHttpRequestTrailer

func (f *Filter) GetHttpRequestTrailer() common.HeaderMap

Get the HttpRequest trailer of proxy-wasm

func (*Filter) GetHttpResponseBody

func (f *Filter) GetHttpResponseBody() common.IoBuffer

Get the HttpResponse body of proxy-wasm

func (*Filter) GetHttpResponseHeader

func (f *Filter) GetHttpResponseHeader() common.HeaderMap

Get the HttpResponse header of proxy-wasm

func (*Filter) GetHttpResponseTrailer

func (f *Filter) GetHttpResponseTrailer() common.HeaderMap

Get the HttpResponse trailer of proxy-wasm

func (*Filter) GetPluginConfig

func (f *Filter) GetPluginConfig() common.IoBuffer

Get the used WasmPlugin config of filter

func (*Filter) GetRootContextID

func (f *Filter) GetRootContextID() int32

Get RootContext ID of filter's FilterConfigFactory

func (*Filter) GetVmConfig

func (f *Filter) GetVmConfig() common.IoBuffer

Get the used WasmPlugin VmConfig of filter

func (*Filter) OnDestroy

func (f *Filter) OnDestroy()

Destruction of filters

func (*Filter) OnReceive

func (f *Filter) OnReceive(ctx context.Context, headers api.HeaderMap, buf buffer.IoBuffer, trailers api.HeaderMap) api.StreamFilterStatus

Reset the filter when receiving then return StreamFilter status

func (*Filter) SetReceiveFilterHandler

func (f *Filter) SetReceiveFilterHandler(handler api.StreamReceiverFilterHandler)

Set ReceiveFilterHandler of filter

func (*Filter) SetSenderFilterHandler

func (f *Filter) SetSenderFilterHandler(handler api.StreamSenderFilterHandler)

Set SenderFilterHandler of filter

type FilterConfigFactory

type FilterConfigFactory struct {
	LayottoHandler

	RootContextID int32
	// contains filtered or unexported fields
}

FilterConfigFactory contains multi wasm-plugin configs its pointer implement api.StreamFilterChainFactory

func GetFactory added in v0.5.0

func GetFactory() *FilterConfigFactory

func (*FilterConfigFactory) CreateFilterChain

func (f *FilterConfigFactory) CreateFilterChain(context context.Context, callbacks api.StreamFilterChainFactoryCallbacks)

func (*FilterConfigFactory) GetRootContextID

func (f *FilterConfigFactory) GetRootContextID() int32

Get RootContext's ID

func (*FilterConfigFactory) Install added in v0.5.0

func (f *FilterConfigFactory) Install(conf map[string]interface{}) error

func (*FilterConfigFactory) IsRegister added in v0.5.0

func (f *FilterConfigFactory) IsRegister(id string) bool

func (*FilterConfigFactory) OnConfigUpdate

func (f *FilterConfigFactory) OnConfigUpdate(config v2.WasmPluginConfig)

update config of FilterConfigFactory

func (*FilterConfigFactory) OnPluginDestroy

func (f *FilterConfigFactory) OnPluginDestroy(types.WasmPlugin)

Destroy the plugin of FilterConfigFactory

func (*FilterConfigFactory) OnPluginStart

func (f *FilterConfigFactory) OnPluginStart(plugin types.WasmPlugin)

Execute the plugin of FilterConfigFactory

func (*FilterConfigFactory) UnInstall added in v0.5.0

func (f *FilterConfigFactory) UnInstall(id string) error

func (*FilterConfigFactory) UpdateInstanceNum added in v0.5.0

func (f *FilterConfigFactory) UpdateInstanceNum(id string, instanceNum int) error

type Group added in v0.2.0

type Group struct {
	// contains filtered or unexported fields
}

type LayottoHandler

type LayottoHandler struct {
	proxywasm010.DefaultImportsHandler

	IoBuffer common.IoBuffer
}

LayottoHandler implement proxywasm.ImportsHandler

func (*LayottoHandler) GetFuncCallData added in v0.2.0

func (d *LayottoHandler) GetFuncCallData() common.IoBuffer

Get the IoBuffer of LayottoHandler

func (*LayottoHandler) GetState added in v0.3.0

func (d *LayottoHandler) GetState(storeName string, key string) (string, proxywasm.WasmResult)

Obtains the state for a specific key

func (*LayottoHandler) InvokeService added in v0.3.0

func (d *LayottoHandler) InvokeService(id string, method string, param string) (string, proxywasm.WasmResult)

Do rpc calls

type Router added in v0.2.0

type Router struct {
	// contains filtered or unexported fields
}

func (*Router) GetRandomPluginByID added in v0.2.0

func (route *Router) GetRandomPluginByID(id string) (*WasmPlugin, error)

Get random plugin with rand id

func (*Router) RegisterRoute added in v0.2.0

func (route *Router) RegisterRoute(id string, plugin *WasmPlugin)

RegisterRoute register a group with id unsafe for concurrent

func (*Router) RemoveRoute added in v0.5.0

func (route *Router) RemoveRoute(id string)

type Wasm added in v0.5.0

type Wasm struct {
	// contains filtered or unexported fields
}

func GetDefault added in v0.5.0

func GetDefault() *Wasm

func New added in v0.5.0

func New() *Wasm

New init a Wasm.

func (*Wasm) AddEndpoint added in v0.5.0

func (wasm *Wasm) AddEndpoint(name string, ep http.Endpoint)

AddEndpoint add an Endpoint to Wasm。

func (*Wasm) GetEndpoint added in v0.5.0

func (wasm *Wasm) GetEndpoint(name string) (endpoint http.Endpoint, ok bool)

GetEndpoint get an Endpoint from Wasm with name.

type WasmPlugin added in v0.2.0

type WasmPlugin struct {
	// contains filtered or unexported fields
}

func (*WasmPlugin) GetPluginConfig added in v0.2.0

func (p *WasmPlugin) GetPluginConfig() common.IoBuffer

Get the plugin config of WasmPlugin

func (*WasmPlugin) GetVmConfig added in v0.2.0

func (p *WasmPlugin) GetVmConfig() common.IoBuffer

Get the VmConfig of WasmPlugin

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL