wasm

package
v1.0.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NameVersion = "w3bstream@v0.0.1"

Functions

func InitConfiguration added in v1.1.0

func InitConfiguration(ctx context.Context, c Configuration) error

func LoggerFromContext added in v1.0.0

func LoggerFromContext(ctx context.Context) (log.Logger, bool)

func MustLoggerFromContext added in v1.0.0

func MustLoggerFromContext(ctx context.Context) log.Logger

func MustRedisPrefixFromContext added in v1.0.0

func MustRedisPrefixFromContext(ctx context.Context) string

func MustRuntimeEventTypesFromContext added in v1.1.0

func MustRuntimeEventTypesFromContext(ctx context.Context) *mapx.Map[uint32, []byte]

func MustRuntimeResourceFromContext added in v1.0.0

func MustRuntimeResourceFromContext(ctx context.Context) *mapx.Map[uint32, []byte]

func RedisPrefixFromContext added in v1.0.0

func RedisPrefixFromContext(ctx context.Context) (string, bool)

func RuntimeEventTypesFromContext added in v1.1.0

func RuntimeEventTypesFromContext(ctx context.Context) (*mapx.Map[uint32, []byte], bool)

func RuntimeResourceFromContext added in v1.0.0

func RuntimeResourceFromContext(ctx context.Context) (*mapx.Map[uint32, []byte], bool)

func UninitConfiguration added in v1.1.0

func UninitConfiguration(ctx context.Context, c Configuration) error

func WithChainClient added in v1.0.0

func WithChainClient(ctx context.Context, v *ChainClient) context.Context

func WithChainClientContext added in v1.0.0

func WithChainClientContext(v *ChainClient) contextx.WithContext

func WithEnv added in v1.0.0

func WithEnv(ctx context.Context, v *Env) context.Context

func WithEnvContext added in v1.0.0

func WithEnvContext(v *Env) contextx.WithContext

func WithKVStore added in v1.0.0

func WithKVStore(ctx context.Context, v KVStore) context.Context

func WithKVStoreContext added in v1.0.0

func WithKVStoreContext(v KVStore) contextx.WithContext

func WithLogger added in v1.0.0

func WithLogger(ctx context.Context, v log.Logger) context.Context

func WithLoggerContext added in v1.0.0

func WithLoggerContext(v log.Logger) contextx.WithContext

func WithMQTTClient added in v1.1.0

func WithMQTTClient(ctx context.Context, mq *MqttClient) context.Context

func WithMQTTClientContext added in v1.1.0

func WithMQTTClientContext(mq *MqttClient) contextx.WithContext

func WithRedisPrefix added in v1.0.0

func WithRedisPrefix(ctx context.Context, v string) context.Context

func WithRedisPrefixContext added in v1.0.0

func WithRedisPrefixContext(v string) contextx.WithContext

func WithRuntimeEventTypes added in v1.1.0

func WithRuntimeEventTypes(ctx context.Context, v *mapx.Map[uint32, []byte]) context.Context

func WithRuntimeEventTypesContext added in v1.1.0

func WithRuntimeEventTypesContext(v *mapx.Map[uint32, []byte]) contextx.WithContext

func WithRuntimeResource added in v1.0.0

func WithRuntimeResource(ctx context.Context, v *mapx.Map[uint32, []byte]) context.Context

func WithRuntimeResourceContext added in v1.0.0

func WithRuntimeResourceContext(v *mapx.Map[uint32, []byte]) contextx.WithContext

func WithSQLStore added in v1.0.0

func WithSQLStore(ctx context.Context, v SQLStore) context.Context

func WithSQLStoreContext added in v1.0.0

func WithSQLStoreContext(v SQLStore) contextx.WithContext

Types

type ABI

type ABI interface {
	Log(loglevel, ptr, size int32) int32
	GetData(rid, vmAddrPtr, vmSizePtr int32) int32
	SetData(rid, addr, size int32) int32
	GetDB(kAddr, kSize, vmAddrPtr, vmSizePtr int32) int32
	SetDB(kAddr, kSize, vAddr, vSize int32) int32
	SendTX(chainid int32, offset, size, vmAddrPtr, vmSizePtr int32) int32
	CallContract(chainid int32, offset, size, vmAddrPtr, vmSizePtr int32) int32
	SetSQLDB(addr, size int32) int32
	GetSQLDB(addr, size, vmAddrPtr, vmSizePtr int32) int32
	GetEnv(kAddr, kSize, vmAddrPtr, vmSizePtr int32) int32
	SendMqttMsg(topicAddr, topicSize, msgAddr, msgSize int32) int32
}

type Cache added in v1.0.0

type Cache struct {
	Mode   enums.CacheMode `json:"mode"`
	Prefix string          `json:"prefix,omitempty"`
}

func DefaultCache added in v1.0.0

func DefaultCache() *Cache

func (*Cache) ConfigType added in v1.0.0

func (c *Cache) ConfigType() enums.ConfigType

func (*Cache) NewKVStore added in v1.0.0

func (c *Cache) NewKVStore(ctx context.Context) KVStore

TODO use KVStore as a member and impl Cache.Init

func (*Cache) WithContext added in v1.0.0

func (c *Cache) WithContext(ctx context.Context) context.Context

type ChainClient added in v1.0.0

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

func ChainClientFromContext added in v1.0.0

func ChainClientFromContext(ctx context.Context) (*ChainClient, bool)

func MustChainClientFromContext added in v1.0.0

func MustChainClientFromContext(ctx context.Context) *ChainClient

func NewChainClient added in v1.0.0

func NewChainClient(ctx context.Context, pvk *string) *ChainClient

func (*ChainClient) CallContract added in v1.0.0

func (c *ChainClient) CallContract(chainID uint32, toStr, dataStr string) ([]byte, error)

func (*ChainClient) SendTX added in v1.0.0

func (c *ChainClient) SendTX(chainID uint32, toStr, valueStr, dataStr string) (string, error)

type Configuration added in v1.0.0

type Configuration interface {
	ConfigType() enums.ConfigType
	WithContext(context.Context) context.Context
}

func NewConfigurationByType added in v1.0.0

func NewConfigurationByType(t enums.ConfigType) (Configuration, error)

type ConfigurationWithInit added in v1.1.0

type ConfigurationWithInit interface {
	Configuration
	types.ValidatedInitializerWith
}

ConfigurationWithInit support recursive initialize

type ConfigurationWithUninit added in v1.1.0

type ConfigurationWithUninit interface {
	Configuration
	Uninit(context.Context) error
}

ConfigurationWithUninit support recursive uninitialize

type ContextHandler

type ContextHandler interface {
	Name() string
	GetImports() ImportsHandler
	SetImports(ImportsHandler)
	GetExports() ExportsHandler
	GetInstance() Instance
	SetInstance(Instance)
}

type CtxChainClient added in v1.0.0

type CtxChainClient struct{}

type CtxEnv added in v1.0.0

type CtxEnv struct{}

type CtxKVStore added in v1.0.0

type CtxKVStore struct{}

type CtxLogger added in v1.0.0

type CtxLogger struct{}

type CtxMqttClient added in v1.1.0

type CtxMqttClient struct{}

type CtxRedisPrefix added in v1.0.0

type CtxRedisPrefix struct{}

type CtxRuntimeEventTypes added in v1.1.0

type CtxRuntimeEventTypes struct{}

type CtxRuntimeResource added in v1.0.0

type CtxRuntimeResource struct{}

type CtxSQLStore added in v1.0.0

type CtxSQLStore struct{}

type Env added in v1.0.0

type Env struct {
	Env [][2]string `json:"env"`
	// contains filtered or unexported fields
}

func EnvFromContext added in v1.0.0

func EnvFromContext(ctx context.Context) (*Env, bool)

func MustEnvFromContext added in v1.0.0

func MustEnvFromContext(ctx context.Context) *Env

func (*Env) ConfigType added in v1.0.0

func (env *Env) ConfigType() enums.ConfigType

func (*Env) Get added in v1.0.0

func (env *Env) Get(k string) (v string, exists bool)

func (*Env) Init added in v1.1.0

func (env *Env) Init(ctx context.Context) (err error)

func (*Env) Key added in v1.1.0

func (env *Env) Key(k string) string

func (*Env) Uninit added in v1.1.0

func (env *Env) Uninit(_ context.Context) error

func (*Env) WithContext added in v1.0.0

func (env *Env) WithContext(ctx context.Context) context.Context

type EventConsumer

type EventConsumer interface {
	HandleEvent(ctx context.Context, handler, eventType string, payload []byte) *EventHandleResult
}

type EventHandleResult

type EventHandleResult struct {
	InstanceID string           `json:"instanceID"`
	Rsp        []byte           `json:"-"`
	Code       ResultStatusCode `json:"code"`
	ErrMsg     string           `json:"errMsg"`
}

type ExportsHandler

type ExportsHandler interface {
	Start()
	Alloc()
	Free()
}

type Handler

type Handler interface {
	Name() string
	Call(context.Context, ...interface{})
}

type ImportsHandler

type ImportsHandler interface {
	GetDB(keyAddr, keySize, valAddr, valSize uint32) (code int32)
	SetDB()
	GetData()
	SetData()
	Log(level uint32)
}

type Instance

type Instance interface {
	ID() string
	Start(context.Context) error
	Stop(context.Context) error
	State() enums.InstanceState

	EventConsumer
}

type InstanceState

type InstanceState = enums.InstanceState

type KVStore

type KVStore interface {
	Get(string) ([]byte, error)
	Set(key string, value []byte) error
}

func KVStoreFromContext added in v1.0.0

func KVStoreFromContext(ctx context.Context) (KVStore, bool)

func MustKVStoreFromContext added in v1.0.0

func MustKVStoreFromContext(ctx context.Context) KVStore

type Memory

type Memory interface {
	Read(context.Context, uint32, uint32) ([]byte, error)
	Write(context.Context, []byte)
}

type Module

type Module interface {
	Init()
	NewInstance() Instance
	GetABI() []string
}

type MqttClient added in v1.1.0

type MqttClient struct {
	*mqtt.Client
}

func DefaultMQClient added in v1.1.0

func DefaultMQClient() *MqttClient

func MQTTClientFromContext added in v1.1.0

func MQTTClientFromContext(ctx context.Context) (*MqttClient, bool)

func MustMQTTClientFromContext added in v1.1.0

func MustMQTTClientFromContext(ctx context.Context) *MqttClient

func (*MqttClient) ConfigType added in v1.1.0

func (m *MqttClient) ConfigType() enums.ConfigType

func (*MqttClient) WithContext added in v1.1.0

func (m *MqttClient) WithContext(ctx context.Context) context.Context

type ResultStatusCode

type ResultStatusCode int32

ResultStatusCode wasm call result code

const (
	ResultStatusCode_OK ResultStatusCode = iota
	ResultStatusCode_UnexportedHandler
	ResultStatusCode_ResourceNotFound
	ResultStatusCode_ImportNotFound
	ResultStatusCode_ImportCallFailed
	ResultStatusCode_TransDataToVMFailed
	ResultStatusCode_TransDataFromVMFailed
	ResultStatusCode_HostInternal
	ResultStatusCode_EnvKeyNotFound
	ResultStatusCode_NoDBContext

	// TODO following result status
	ResultStatusCode_Failed = -1 // reserved for wasm invoke failed
)

type SQLStore added in v1.0.0

type SQLStore interface {
	sqlx.SqlExecutor
}

func MustSQLStoreFromContext added in v1.0.0

func MustSQLStoreFromContext(ctx context.Context) SQLStore

func SQLStoreFromContext added in v1.0.0

func SQLStoreFromContext(ctx context.Context) (SQLStore, bool)

type Schema added in v1.0.0

type Schema struct {
	schema.Schema
	// contains filtered or unexported fields
}

func (*Schema) ConfigType added in v1.0.0

func (s *Schema) ConfigType() enums.ConfigType

func (*Schema) ExecContext added in v1.0.0

func (s *Schema) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*Schema) QueryContext added in v1.0.0

func (s *Schema) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (*Schema) WithContext added in v1.0.0

func (s *Schema) WithContext(ctx context.Context) context.Context

type VM

type VM interface {
	Name() string
	Init()
	NewModule(code []byte) Module
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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