kernel

package
v0.0.0-...-1121b9f Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnmarshalEvent

func UnmarshalEvent(data []byte) (interface{}, error)

func WriteEvent

func WriteEvent(wr io.Writer, event interface{}) error

Types

type AbortEvent

type AbortEvent struct {
	ID     int             `json:"id"`
	Value  json.RawMessage `json:"value,omitempty"`
	Line   int             `json:"line,omitempty"`
	Column int             `json:"column,omitempty"`
	Stack  string          `json:"stack,omitempty"`
}

func Abort

func Abort(id int, value ...interface{}) AbortEvent

func (AbortEvent) MarshalJSON

func (e AbortEvent) MarshalJSON() ([]byte, error)

func (AbortEvent) WithLine

func (e AbortEvent) WithLine(line, column int) AbortEvent

func (AbortEvent) WithStack

func (e AbortEvent) WithStack(stack string) AbortEvent

type CapabilitiesEvent

type CapabilitiesEvent struct {
	CanProvideVariables bool `json:"canProvideVariables"`
}

func (CapabilitiesEvent) MarshalJSON

func (e CapabilitiesEvent) MarshalJSON() ([]byte, error)

type ErrorEvent

type ErrorEvent struct {
	ID      int    `json:"id"`
	Name    string `json:"name,omitempty"`
	Message string `json:"message,omitempty"`
	Line    int    `json:"line,omitempty"`
	Column  int    `json:"column,omitempty"`
	Stack   string `json:"stack,omitempty"`
}

func Error

func Error(id int, message string) ErrorEvent

func (ErrorEvent) MarshalJSON

func (e ErrorEvent) MarshalJSON() ([]byte, error)

func (ErrorEvent) WithLine

func (e ErrorEvent) WithLine(line, column int) ErrorEvent

func (ErrorEvent) WithName

func (e ErrorEvent) WithName(name string) ErrorEvent

func (ErrorEvent) WithStack

func (e ErrorEvent) WithStack(stack string) ErrorEvent

type EventReader

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

func NewEventReader

func NewEventReader(rd io.Reader) *EventReader

func (*EventReader) Read

func (e *EventReader) Read() (interface{}, error)

type ExecuteRequest

type ExecuteRequest struct {
	Id   int
	Code string
}

type ExecutedEvent

type ExecutedEvent struct {
	ID         int             `json:"id"`
	Success    bool            `json:"success"`
	Result     json.RawMessage `json:"result"`
	Duration   float64         `json:"duration"`
	ShowResult bool            `json:"showResult"`
}

func Executed

func Executed(id int, success bool, duration time.Duration, result json.RawMessage, showResult bool) ExecutedEvent

func (ExecutedEvent) MarshalJSON

func (e ExecutedEvent) MarshalJSON() ([]byte, error)

type InterruptRequest

type InterruptRequest struct{}

type Kernel

type Kernel struct {
	Notebook NotebookCapabilities
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, wr io.Writer, opts interp.Options) *Kernel

func (*Kernel) Abort

func (k *Kernel) Abort(v ...interface{})

func (*Kernel) Err

func (k *Kernel) Err() error

func (*Kernel) Eval

func (k *Kernel) Eval(src string) (reflect.Value, error)

func (*Kernel) Event

func (k *Kernel) Event(event interface{}) bool

func (*Kernel) Output

func (k *Kernel) Output() OutputEvent

func (*Kernel) Send

func (k *Kernel) Send(event interface{}) error

func (*Kernel) SendSafe

func (k *Kernel) SendSafe(event interface{}) bool

func (*Kernel) Stderr

func (k *Kernel) Stderr() io.Writer

func (*Kernel) Stdout

func (k *Kernel) Stdout() io.Writer

func (*Kernel) Use

func (k *Kernel) Use(values interp.Exports) error

type NotebookCapabilities

type NotebookCapabilities struct {
	CanAbort bool
}

type OutputEvent

type OutputEvent struct {
	ID    int          `json:"id"`
	Items []OutputItem `json:"items"`
}

func Output

func Output(id int) OutputEvent

func (OutputEvent) Add

func (e OutputEvent) Add(mime string, value []byte) OutputEvent

func (OutputEvent) MarshalJSON

func (e OutputEvent) MarshalJSON() ([]byte, error)

type OutputItem

type OutputItem struct {
	Mime  string `json:"mime"`
	Value []byte `json:"value"`
}

type Variable

type Variable struct {
	Reference int    `json:"reference,omitempty"`
	Name      string `json:"name"`
	Value     string `json:"value"`
}

type VariableRequest

type VariableRequest struct {
	Id        int
	Reference int
}

type VariablesResponse

type VariablesResponse struct {
	ID        int        `json:"id"`
	Error     string     `json:"error,omitempty"`
	Variables []Variable `json:"variables"`
}

func Variables

func Variables(id int, vars []Variable) VariablesResponse

func VariablesError

func VariablesError(id int, err error) VariablesResponse

func (VariablesResponse) MarshalJSON

func (e VariablesResponse) MarshalJSON() ([]byte, error)

func (VariablesResponse) Sort

func (e VariablesResponse) Sort()

Jump to

Keyboard shortcuts

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