execute

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// Blockless Runtime flag names.
	RuntimeFlagEntry         = "entry"
	RuntimeFlagExecutionTime = "run-time"
	RuntimeFlagDebug         = "debug-info"
	RuntimeFlagFuel          = "limited-fuel"
	RuntimeFlagMemory        = "limited-memory"
	RuntimeFlagFSRoot        = "fs-root-path"
	RuntimeFlagLogger        = "runtime-logger"
	RuntimeFlagPermission    = "permission"
	RuntimeFlagEnv           = "env"
)
View Source
const (
	DefaultRuntimeEntryPoint = "_start"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Main  peer.ID   `json:"main,omitempty"`
	Peers []peer.ID `json:"peers,omitempty"`
}

Cluster represents the set of peers that executed the request.

type Config

type Config struct {
	Runtime           RuntimeConfig     `json:"runtime,omitempty"`
	Environment       []EnvVar          `json:"env_vars,omitempty"`
	Stdin             *string           `json:"stdin,omitempty"`
	Permissions       []string          `json:"permissions,omitempty"`
	ResultAggregation ResultAggregation `json:"result_aggregation,omitempty"`

	// NodeCount specifies how many nodes should execute this request.
	NodeCount int `json:"number_of_nodes,omitempty"`
	// Consensus algorithm to use. Raft and PBFT are supported at this moment.
	ConsensusAlgorithm string `json:"consensus_algorithm,omitempty"`

	// Threshold (percentage) defines how many nodes should respond with a result to consider this execution successful.
	Threshold float64 `json:"threshold,omitempty"`
}

Config represents the configurable options for an execution request.

type EnvVar

type EnvVar struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

EnvVar represents the name and value of the environment variables set for the execution.

type Parameter

type Parameter struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

Parameter represents an execution parameter, modeled as a key-value pair.

type ProcessID

type ProcessID struct {
	PID    int     // PID can used to identify a process on all platforms.
	Handle uintptr // windows.Handle value that can be used for Windows-specific operations.
}

ProcessID is used to identify an OS process.

type Request

type Request struct {
	FunctionID string      `json:"function_id"`
	Method     string      `json:"method"`
	Parameters []Parameter `json:"parameters,omitempty"`
	Config     Config      `json:"config"`

	// Optional signature of the request.
	Signature string `json:"signature,omitempty"`
}

Request describes an execution request.

func (*Request) Sign added in v0.3.0

func (e *Request) Sign(key crypto.PrivKey) error

func (Request) VerifySignature added in v0.3.0

func (e Request) VerifySignature(key crypto.PubKey) error

type Result

type Result struct {
	Code      codes.Code    `json:"code"`
	Result    RuntimeOutput `json:"result"`
	RequestID string        `json:"request_id"`
	Usage     Usage         `json:"usage,omitempty"`
}

Result describes an execution result.

type ResultAggregation

type ResultAggregation struct {
	Enable     bool        `json:"enable,omitempty"`
	Type       string      `json:"type,omitempty"`
	Parameters []Parameter `json:"parameters,omitempty"`
}

type ResultMap

type ResultMap map[peer.ID]Result

ResultMap contains execution results from multiple peers.

func (ResultMap) MarshalJSON

func (m ResultMap) MarshalJSON() ([]byte, error)

MarshalJSON provides means to correctly handle JSON serialization/deserialization. See:

https://github.com/libp2p/go-libp2p/pull/2156
https://github.com/libp2p/go-libp2p-resource-manager/pull/67#issuecomment-1176820561

type RuntimeConfig

type RuntimeConfig struct {
	Entry         string `json:"entry,omitempty"`
	ExecutionTime uint64 `json:"run_time,omitempty"`
	DebugInfo     bool   `json:"debug_info,omitempty"`
	Fuel          uint64 `json:"limited_fuel,omitempty"`
	Memory        uint64 `json:"limited_memory,omitempty"`
	Logger        string `json:"runtime_logger,omitempty"`
	// Fields not allowed to be set in the request.
	Input  string `json:"-"`
	FSRoot string `json:"-"`
}

RuntimeConfig represents the CLI flags supported by the runtime

type RuntimeOutput

type RuntimeOutput struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
	Log      string `json:"-"`
}

RuntimeOutput describes the output produced by the Blockless Runtime during exection.

type Usage

type Usage struct {
	WallClockTime time.Duration `json:"wall_clock_time,omitempty"`
	CPUUserTime   time.Duration `json:"cpu_user_time,omitempty"`
	CPUSysTime    time.Duration `json:"cpu_sys_time,omitempty"`
	MemoryMaxKB   int64         `json:"memory_max_kb,omitempty"`
}

Usage represents the resource usage information for a particular execution.

Jump to

Keyboard shortcuts

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