api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Log  zerolog.Logger
	Node Node
}

API provides REST API functionality for the Blockless head node.

func New

func New(log zerolog.Logger, node Node) *API

New creates a new instance of a Blockless head node REST API. Access to node data is provided by the provided `node`.

func (*API) Execute

func (a *API) Execute(ctx echo.Context) error

Execute implements the REST API endpoint for function execution.

func (*API) ExecutionResult

func (a *API) ExecutionResult(ctx echo.Context) error

ExecutionResult implements the REST API endpoint for retrieving the result of a function execution.

func (*API) Health

func (a *API) Health(ctx echo.Context) error

Execute implements the REST API endpoint for function execution.

func (*API) Install

func (a *API) Install(ctx echo.Context) error

type ExecuteRequest

type ExecuteRequest struct {
	execute.Request
	Topic string `json:"topic,omitempty"`
}

ExecuteRequest describes the payload for the REST API request for function execution.

type ExecuteResponse

type ExecuteResponse struct {
	Code      codes.Code        `json:"code,omitempty"`
	RequestID string            `json:"request_id,omitempty"`
	Message   string            `json:"message,omitempty"`
	Results   aggregate.Results `json:"results,omitempty"`
	Cluster   execute.Cluster   `json:"cluster,omitempty"`
}

ExecuteResponse describes the REST API response for function execution.

type ExecuteResult

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

ExecuteResult represents the API representation of a single execution response. It is similar to the model in `execute.Result`, except it omits the usage information for now.

type ExecutionResultRequest

type ExecutionResultRequest struct {
	ID string `json:"id"`
}

ExecutionResultRequest describes the payload for the REST API request for execution result.

type InstallFunctionRequest

type InstallFunctionRequest struct {
	CID      string `json:"cid"`
	URI      string `json:"uri"`
	Subgroup string `json:"subgroup"`
}

InstallFunctionRequest describes the payload for the REST API request for function install.

type InstallFunctionResponse

type InstallFunctionResponse struct {
	Code string `json:"code"`
}

InstallFunctionResponse describes the REST API response for the function install.

type Node

type Node interface {
	ExecuteFunction(ctx context.Context, req execute.Request, subgroup string) (code codes.Code, requestID string, results execute.ResultMap, peers execute.Cluster, err error)
	ExecutionResult(id string) (execute.Result, bool)
	PublishFunctionInstall(ctx context.Context, uri string, cid string, subgroup string) error
	CommunicatorAppLayer() chan []byte
}

Jump to

Keyboard shortcuts

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