ranna

package
v0.0.0-...-8d5cf93 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointSpec    = "/v1/spec"
	EndpointExecute = "/v1/exec"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a ranna client

func NewClient

func NewClient(instance string) *Client

NewClient creates a new ranna client

func (*Client) Execute

func (client *Client) Execute(executionRequest *ExecutionRequest) (*ExecutionResponse, error)

Execute executes a code snippet using ranna

func (*Client) Specs

func (client *Client) Specs() (*Specs, error)

Specs requests the specified specs from the ranna instance

type Error

type Error struct {
	Message string `json:"error"`
	Code    int    `json:"code"`
	Context string `json:"context"`
}

Error represents a ranna API error

func (Error) Error

func (err Error) Error() string

Error stringifies a ranna API error

type ExecutionRequest

type ExecutionRequest struct {
	Language    string            `json:"language"`
	Code        string            `json:"code"`
	Arguments   []string          `json:"arguments"`
	Environment map[string]string `json:"environment"`
}

ExecutionRequest is being sent to ranna to execute a code snippet

type ExecutionResponse

type ExecutionResponse struct {
	StdOut string `json:"stdout"`
	StdErr string `json:"stderr"`

	// Duration represents the duration ranna took to execute the requested snippet
	// Please note that this is not 100% accurate as this is calculated on the client side
	Duration time.Duration `json:"-"`
}

ExecutionResponse represents a response of a ranna code execution

type Spec

type Spec struct {
	Use        string `json:"use"`
	Image      string `json:"image"`
	Entrypoint string `json:"entrypoint"`
	Filename   string `json:"filename"`
}

Spec represents a language execution spec

type Specs

type Specs map[string]*Spec

Specs represents a map of specs

Jump to

Keyboard shortcuts

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