wasm

package
v1.6.5-rc8-deb Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func CustomMetricsFromContext added in v1.1.0

func CustomMetricsFromContext(ctx context.Context) (metrics.CustomMetrics, bool)

func InitConfiguration added in v1.1.0

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

func InitGlobalConfiguration added in v1.4.6

func InitGlobalConfiguration(parent context.Context, c GlobalConfiguration) error

func LoggerFromContext added in v1.0.0

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

func MQTTClientFromContext added in v1.1.0

func MQTTClientFromContext(ctx context.Context) (*mqtt.Client, bool)

func MustCustomMetricsFromContext added in v1.1.0

func MustCustomMetricsFromContext(ctx context.Context) metrics.CustomMetrics

func MustLoggerFromContext added in v1.0.0

func MustLoggerFromContext(ctx context.Context) log.Logger

func MustMQTTClientFromContext added in v1.1.0

func MustMQTTClientFromContext(ctx context.Context) *mqtt.Client

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(parent 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 WithCustomMetrics added in v1.1.0

func WithCustomMetrics(ctx context.Context, mt metrics.CustomMetrics) context.Context

func WithCustomMetricsContext added in v1.1.0

func WithCustomMetricsContext(mt metrics.CustomMetrics) 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 WithFlow added in v1.4.6

func WithFlow(ctx context.Context, flow *Flow) context.Context

func WithFlowContext added in v1.4.6

func WithFlowContext(flow *Flow) 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 *mqtt.Client) context.Context

func WithMQTTClientContext added in v1.1.0

func WithMQTTClientContext(mq *mqtt.Client) 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 *Database) context.Context

func WithSQLStoreContext added in v1.0.0

func WithSQLStoreContext(v *Database) 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 ApiServer added in v1.4.6

type ApiServer struct {
}

type CBInfo added in v1.4.6

type CBInfo struct {
	ChainID int `json:"chainID,omitempty"`
}

type Cache added in v1.0.0

type Cache struct {
	Mode   enums.CacheMode `json:"mode"`
	Prefix string          `json:"prefix,omitempty"`
	// contains filtered or unexported fields
}

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) Init added in v1.4.6

func (c *Cache) Init(parent context.Context) error

func (*Cache) WithContext added in v1.0.0

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

type CanBeInit added in v1.4.6

type CanBeInit interface {
	Init(context.Context) error
}

type CanBeUninit added in v1.4.6

type CanBeUninit interface {
	Uninit(context.Context) error
}

type ChainClient added in v1.0.0

type ChainClient struct {
	ProjectName string
	Operators   map[string]*PrivateKey
}

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, prj *models.Project, ops []models.Operator, op *models.ProjectOperator) *ChainClient

func (*ChainClient) CallContract added in v1.0.0

func (c *ChainClient) CallContract(conf *wsTypes.ChainConfig, chainID uint64, chainName enums.ChainName, toStr, dataStr string) ([]byte, error)

func (*ChainClient) GlobalConfigType added in v1.4.6

func (c *ChainClient) GlobalConfigType() ConfigType

func (*ChainClient) Init added in v1.4.6

func (c *ChainClient) Init(parent context.Context) error

func (*ChainClient) SendTX added in v1.0.0

func (c *ChainClient) SendTX(conf *wsTypes.ChainConfig, chainID uint64, chainName enums.ChainName, toStr, valueStr, dataStr string, opPool optypes.Pool, prj *models.Project) (string, error)

func (*ChainClient) SendTXWithOperator added in v1.1.0

func (c *ChainClient) SendTXWithOperator(conf *wsTypes.ChainConfig, chainID uint64, chainName enums.ChainName, toStr, valueStr, dataStr, operatorName string, opPool optypes.Pool, prj *models.Project) (*SendTxResp, error)

func (*ChainClient) WithContext added in v1.4.6

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

type Column added in v1.1.0

type Column struct {
	// Name column name
	Name string `json:"name"`
	// Constrains column constrains
	Constrains Constrains `json:"constrains"`
}

func (*Column) Build added in v1.1.0

func (c *Column) Build() *builder.Column

func (Column) Datatype added in v1.1.0

func (c Column) Datatype(t enums.WasmDBDatatype) string

type ConfigType added in v1.4.6

type ConfigType string
const (
	ConfigLogger     ConfigType = "LOGGER"
	ConfigMqttClient ConfigType = "MQTT_CLIENT"
	ConfigChains     ConfigType = "CHAINS"
	ConfigMetrics    ConfigType = "METRICS"
)

type Configuration added in v1.0.0

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

func NewUserConfigurationByType added in v1.4.6

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

type Constrains added in v1.1.0

type Constrains struct {
	Datatype      enums.WasmDBDatatype `json:"datatype"`
	Length        uint64               `json:"length,omitempty"`
	Decimal       uint64               `json:"decimal,omitempty"`
	Default       *string              `json:"default,omitempty"`
	Null          bool                 `json:"null,omitempty"`
	AutoIncrement bool                 `json:"autoincrement,omitempty"`
	Desc          string               `json:"desc,omitempty"`
}

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 CtxCustomMetrics added in v1.1.0

type CtxCustomMetrics struct{}

type CtxEnv added in v1.0.0

type CtxEnv struct{}

type CtxFlow added in v1.4.6

type CtxFlow 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 DBInfo added in v1.4.6

type DBInfo struct {
	Endpoint string   `json:"endpoint,omitempty"`
	DBType   string   `json:"DBType,omitempty"`
	Table    string   `json:"table,omitempty"`
	Columns  []string `json:"columns,omitempty"`
}

type Database added in v1.1.0

type Database struct {
	// Name: database name, currently this should be assigned by host; if the
	// database resource can be assigned by project, then open this field.
	Name string `json:"-"`
	// Dialect database dialect, support postgres only now
	Dialect enums.WasmDBDialect `json:"dialect,omitempty,default=''"`
	// Schemas schema list
	Schemas []*Schema `json:"schemas,omitempty"`
	// contains filtered or unexported fields
}

func MustSQLStoreFromContext added in v1.0.0

func MustSQLStoreFromContext(ctx context.Context) *Database

func NewDatabase added in v1.1.0

func NewDatabase(name string) *Database

func SQLStoreFromContext added in v1.0.0

func SQLStoreFromContext(ctx context.Context) (*Database, bool)

func (*Database) ConfigType added in v1.1.0

func (d *Database) ConfigType() enums.ConfigType

func (*Database) Init added in v1.1.0

func (d *Database) Init(parent context.Context) (err error)

func (*Database) WithContext added in v1.1.0

func (d *Database) WithContext(ctx context.Context) context.Context

func (*Database) WithDefaultSchema added in v1.1.0

func (d *Database) WithDefaultSchema() (sqlx.DBExecutor, error)

func (*Database) WithSchema added in v1.1.0

func (d *Database) WithSchema(name string) (db sqlx.DBExecutor, err error)

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(parent 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 EthClient added in v1.6.1

type EthClient interface {
	TransactionByHash(ctx context.Context, hash string) (any, error)
	TransactionState(ctx context.Context, hash string) (enums.TransactionState, error)
	SendTransaction(ctx context.Context, toStr, valueStr, dataStr string, op *optypes.SyncOperator) (*ethtypes.Transaction, error)
}

TODO: move to a more appropriate place

func NewEthClient added in v1.6.1

func NewEthClient(chain *types.Chain) EthClient

NewEthClient creates a new EthClient according to the chain type

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 Flow added in v1.4.6

type Flow struct {
	Source    Source     `json:"source"`
	Operators []Operator `json:"operators"`
	Sink      Sink       `json:"sink"`
}

func FlowFromContext added in v1.4.6

func FlowFromContext(ctx context.Context) (*Flow, bool)

func MustFlowFromContext added in v1.4.6

func MustFlowFromContext(ctx context.Context) *Flow

func (*Flow) ConfigType added in v1.4.6

func (f *Flow) ConfigType() enums.ConfigType

func (*Flow) WithContext added in v1.4.6

func (f *Flow) WithContext(ctx context.Context) context.Context

type GlobalConfiguration added in v1.4.6

type GlobalConfiguration interface {
	GlobalConfigType() ConfigType
	WithContext(context.Context) context.Context
}

func NewGlobalConfigurationByType added in v1.4.6

func NewGlobalConfigurationByType(t ConfigType) (GlobalConfiguration, error)

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 Key added in v1.1.0

type Key struct {
	Name        string   `json:"name,omitempty"`
	Method      string   `json:"method,omitempty"`
	IsUnique    bool     `json:"isUnique,omitempty"`
	ColumnNames []string `json:"columnNames"`
	Expr        string   `json:"expr,omitempty"`
}

func (*Key) Build added in v1.1.0

func (k *Key) Build(tblName string) *builder.Key

type Logger added in v1.4.6

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

func (*Logger) GlobalConfigType added in v1.4.6

func (l *Logger) GlobalConfigType() ConfigType

func (*Logger) Init added in v1.4.6

func (l *Logger) Init(parent context.Context) error

func (*Logger) WithContext added in v1.4.6

func (l *Logger) WithContext(ctx context.Context) context.Context

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 {
	// contains filtered or unexported fields
}

func (*MqttClient) GlobalConfigType added in v1.4.6

func (m *MqttClient) GlobalConfigType() ConfigType

func (*MqttClient) Init added in v1.4.6

func (m *MqttClient) Init(parent context.Context) error

func (*MqttClient) WithContext added in v1.1.0

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

type Operator added in v1.4.6

type Operator struct {
	OpType   enums.FlowOperator `json:"opType"`
	WasmFunc string             `json:"wasmFunc,omitempty"`
	Parallel int                `json:"parallel,omitempty"`
}

type PrivateKey added in v1.5.3

type PrivateKey struct {
	Type    enums.OperatorKeyType
	Ecdsa   []byte
	Ed25519 ed25519.PrivateKey
}

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
	ResultStatusCode_ParamIllegal

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

type SQLStore added in v1.0.0

type SQLStore interface {
	sqlx.SqlExecutor
}

type Schema added in v1.0.0

type Schema struct {
	// Name: schema name, use postgres driver, default schema is `public`
	Name string `json:"schema,omitempty,default='public'"`
	// Tables: tables define
	Tables []*Table `json:"tables,omitempty"`
}

type SendTxResp added in v1.5.9

type SendTxResp struct {
	ChainName enums.ChainName
	Nonce     uint64
	Hash      string
	Sender    string
	Receiver  string
	Data      string
}

type Sink added in v1.4.6

type Sink struct {
	SinkType enums.FlowSink `json:"sinkType"`
	SinkInfo SinkInfo       `json:"sinkInfo"`
}

func (*Sink) UnmarshalJSON added in v1.4.6

func (s *Sink) UnmarshalJSON(b []byte) error

type SinkInfo added in v1.4.6

type SinkInfo struct {
	DBInfo     DBInfo `json:"DBInfo,omitempty"`
	ChainBlock CBInfo `json:"chainBlock,omitempty"`
}

type Source added in v1.4.6

type Source struct {
	Strategies []string `json:"strategies"`
}

type Table added in v1.1.0

type Table struct {
	// Name table name
	Name string `json:"name"`
	// Desc table description
	Desc string `json:"desc,omitempty"`
	// Cols table column define
	Cols []*Column `json:"cols"`
	// Keys table index or primary define
	Keys []*Key `json:"keys"`
}

func (*Table) Build added in v1.1.0

func (t *Table) Build() *builder.Table

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