Documentation ¶
Index ¶
- Constants
- func RegisterModuleFactory(name string, factory ModuleFactory)
- func WithContext(ctx context.Context, call *Call) context.Context
- type Argument
- type BaseArgument
- type BaseValueArgument
- type Call
- func (c *Call) AppendLog(message string)
- func (c *Call) DoAddBigDecimal(ord uint64, key string, value string)
- func (c *Call) DoAddBigInt(ord uint64, key string, value string)
- func (c *Call) DoAddFloat64(ord uint64, key string, value float64)
- func (c *Call) DoAddInt64(ord uint64, key string, value int64)
- func (c *Call) DoAppend(ord uint64, key string, value []byte)
- func (c *Call) DoDeletePrefix(ord uint64, prefix string)
- func (c *Call) DoGetAt(storeIndex int, ord uint64, key string) (value []byte, found bool)
- func (c *Call) DoGetFirst(storeIndex int, key string) (value []byte, found bool)
- func (c *Call) DoGetLast(storeIndex int, key string) (value []byte, found bool)
- func (c *Call) DoHasAt(storeIndex int, ord uint64, key string) (found bool)
- func (c *Call) DoHasFirst(storeIndex int, key string) (found bool)
- func (c *Call) DoHasLast(storeIndex int, key string) (found bool)
- func (c *Call) DoSet(ord uint64, key string, value []byte)
- func (c *Call) DoSetIfNotExists(ord uint64, key string, value []byte)
- func (c *Call) DoSetMaxBigDecimal(ord uint64, key string, value string)
- func (c *Call) DoSetMaxBigInt(ord uint64, key string, value string)
- func (c *Call) DoSetMaxFloat64(ord uint64, key string, value float64)
- func (c *Call) DoSetMaxInt64(ord uint64, key string, value int64)
- func (c *Call) DoSetMinBigDecimal(ord uint64, key string, value string)
- func (c *Call) DoSetMinBigInt(ord uint64, key string, value string)
- func (c *Call) DoSetMinFloat64(ord uint64, key string, value float64)
- func (c *Call) DoSetMinInt64(ord uint64, key string, value int64)
- func (c *Call) Err() error
- func (c *Call) Output() []byte
- func (c *Call) ReachedLogsMaxByteCount() bool
- func (c *Call) ReturnError(err error)
- func (c *Call) SetOutputStore(store store.Store)
- func (c *Call) SetPanicError(message string, filename string, lineNo int, colNo int)
- func (c *Call) SetReturnValue(msg []byte)
- type InputType
- type Instance
- type MapInput
- type Module
- type ModuleFactory
- type ModuleFactoryFunc
- type PanicError
- type ParamsInput
- type Registry
- type SourceInput
- type StoreDeltaInput
- type StoreReaderInput
- type StoreWriterOutput
- type ValueArgument
- type WASMExtension
- type WASMExtensioner
Constants ¶
const ClockType = "sf.substreams.v1.Clock"
const MaxLogByteCount = 128 * 1024 // 128 KiB
Variables ¶
This section is empty.
Functions ¶
func RegisterModuleFactory ¶ added in v1.1.5
func RegisterModuleFactory(name string, factory ModuleFactory)
Types ¶
type BaseArgument ¶ added in v0.0.21
type BaseArgument struct {
// contains filtered or unexported fields
}
func (*BaseArgument) Name ¶ added in v0.0.21
func (b *BaseArgument) Name() string
type BaseValueArgument ¶ added in v0.0.21
type BaseValueArgument struct {
// contains filtered or unexported fields
}
func (*BaseValueArgument) SetValue ¶ added in v0.0.21
func (b *BaseValueArgument) SetValue(data []byte)
func (*BaseValueArgument) Value ¶ added in v0.0.21
func (b *BaseValueArgument) Value() []byte
type Call ¶ added in v1.1.1
type Call struct { Clock *pbsubstreams.Clock // Used by WASM extensions ModuleName string Entrypoint string Logs []string LogsByteCount uint64 ExecutionStack []string // contains filtered or unexported fields }
func FromContext ¶ added in v1.1.5
func (*Call) DoAddBigDecimal ¶ added in v1.1.5
func (*Call) DoAddBigInt ¶ added in v1.1.5
func (*Call) DoAddFloat64 ¶ added in v1.1.5
func (*Call) DoAddInt64 ¶ added in v1.1.5
func (*Call) DoDeletePrefix ¶ added in v1.1.5
func (*Call) DoGetFirst ¶ added in v1.1.5
func (*Call) DoHasFirst ¶ added in v1.1.5
func (*Call) DoSetIfNotExists ¶ added in v1.1.5
func (*Call) DoSetMaxBigDecimal ¶ added in v1.1.5
func (*Call) DoSetMaxBigInt ¶ added in v1.1.5
func (*Call) DoSetMaxFloat64 ¶ added in v1.1.5
func (*Call) DoSetMaxInt64 ¶ added in v1.1.5
func (*Call) DoSetMinBigDecimal ¶ added in v1.1.5
func (*Call) DoSetMinBigInt ¶ added in v1.1.5
func (*Call) DoSetMinFloat64 ¶ added in v1.1.5
func (*Call) DoSetMinInt64 ¶ added in v1.1.5
func (*Call) ReachedLogsMaxByteCount ¶ added in v1.1.1
func (*Call) ReturnError ¶ added in v1.1.5
func (*Call) SetOutputStore ¶ added in v1.1.1
func (*Call) SetPanicError ¶ added in v1.1.5
func (*Call) SetReturnValue ¶ added in v1.1.5
type Instance ¶
type Instance interface { // Cleanup is called between each calls, for lightweight clean-up (remove allocation) // in case we're not using a fully deterministic execution strategy. Cleanup(ctx context.Context) error // Close is called once we know we won't be reusing this instance, and it can be // freed from memory. When using cached instances, this won't be called between // each execution, but only at the end of a user's request. Close(ctx context.Context) error }
An Instance lives for the duration of an execution (with instance caching disabled) // or a series of execution (when instance caching is enabled).
type MapInput ¶ added in v0.0.21
type MapInput struct { BaseArgument BaseValueArgument }
func NewMapInput ¶ added in v0.0.21
type Module ¶
type Module interface { // NewInstance can be used to create up-front a new instance, which will be // cached and reused for the duration execution of ExecuteNewCall. NewInstance(ctx context.Context) (instance Instance, err error) // ExecuteNewCall is called once per module execution for each block. // If caching is enabled, the returned Instance will be saved and passed in // as the `cachedInstance` argument upon the next call. In which case, the runtime // would benefit from using it back. It is the runtime's responsibility to determine // whether this caching entails risks to determinism (leaking of global state for instance). ExecuteNewCall(ctx context.Context, call *Call, cachedInstance Instance, arguments []Argument) (instance Instance, err error) // Close gets called when the module can be unloaded at the end of a user's request. Close(ctx context.Context) error }
A Module is a cached or pre-compiled version able to generate new isolated instances, and execute calls on them. It lives for the duration of a stream.
type ModuleFactory ¶ added in v1.1.5
type ModuleFactory interface {
NewModule(ctx context.Context, code []byte, registry *Registry) (module Module, err error)
}
WASM VM specific implementation to create a new Module, which is an abstraction around a runtime and pre-compiled WASM modules.
type ModuleFactoryFunc ¶ added in v1.1.5
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
func NewPanicError ¶ added in v1.1.5
func NewPanicError(message, filename string, lineNumber, columnNumber int) *PanicError
func (*PanicError) Error ¶
func (e *PanicError) Error() string
type ParamsInput ¶ added in v1.0.0
type ParamsInput struct { BaseArgument BaseValueArgument }
func NewParamsInput ¶ added in v1.0.0
func NewParamsInput(value string) *ParamsInput
type Registry ¶ added in v1.1.5
type Registry struct { Extensions map[string]map[string]WASMExtension // contains filtered or unexported fields }
Registry from Substreams's perspective is a singleton that is reused across requests, from which we instantiate Modules (wasm code provided by the users) and from which we instantiate Instances (one for each executions within each blocks).
func NewRegistry ¶ added in v1.1.5
func NewRegistry(extensions []WASMExtensioner, maxFuel uint64) *Registry
func NewRegistryWithRuntime ¶ added in v1.1.9
func NewRegistryWithRuntime(runtimeName string, extensions []WASMExtensioner, maxFuel uint64) *Registry
func (*Registry) InstanceCacheEnabled ¶ added in v1.1.5
type SourceInput ¶ added in v0.0.21
type SourceInput struct { BaseArgument BaseValueArgument }
func NewSourceInput ¶ added in v0.0.21
func NewSourceInput(name string) *SourceInput
type StoreDeltaInput ¶ added in v0.0.21
type StoreDeltaInput struct { BaseArgument BaseValueArgument }
func NewStoreDeltaInput ¶ added in v0.0.21
func NewStoreDeltaInput(name string) *StoreDeltaInput
type StoreReaderInput ¶ added in v0.0.21
type StoreReaderInput struct { BaseArgument Store store.Store }
func NewStoreReaderInput ¶ added in v0.0.21
func NewStoreReaderInput(name string, store store.Store) *StoreReaderInput
type StoreWriterOutput ¶ added in v0.0.21
type StoreWriterOutput struct { BaseArgument Store store.Store UpdatePolicy pbsubstreams.Module_KindStore_UpdatePolicy ValueType string }
func NewStoreWriterOutput ¶ added in v0.0.21
func NewStoreWriterOutput(name string, store store.Store, updatePolicy pbsubstreams.Module_KindStore_UpdatePolicy, valueType string) *StoreWriterOutput
type ValueArgument ¶ added in v0.0.21
type WASMExtension ¶
type WASMExtension func(ctx context.Context, requestID string, clock *pbsubstreams.Clock, in []byte) (out []byte, err error)
WASMExtension defines the implementation of a function that will be exposed as wasm imports; therefore, exposed to the host language like Rust.
For example, this can be an RPC call, taking a structured request in `in` and outputting a structured response in `out`, both serialized as protobuf messages.
Such a function needs to be registered through RegisterRuntime.
type WASMExtensioner ¶
type WASMExtensioner interface {
WASMExtensions() map[string]map[string]WASMExtension
}