gateway

package
v0.0.0-...-74ad9c3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKernel

func NewKernel(ctx context.Context, k *Kernel) error

New attaches a websocket connection to a new, or existing, kernel.

Types

type Content

type Content struct {
	Message uuid.UUID `json:"-"`

	// Actual content
	Channel string `json:"channel,omitempty"`
	Code    string `json:"code,omitempty"` // stream data
	Text    string `json:"text,omitempty"` // stream data
	Data    *Data  `json:"data,omitempty"`

	// Result
	Status         string    `json:"status"`
	ExecutionCount int       `json:"execution_count"`
	Timestamp      time.Time `json:"date"`

	// Metadata
	Metadata  map[string]any `json:"metadata"`
	Transient map[string]any `json:"transient"`
	Error     *Error         `json:"-"`
}

type Data

type Data struct {
	Plaintext string `json:"text/plain"`
	Markdown  string `json:"text/markdown"`
	Latex     string `json:"text/latex"`
	JS        string `json:"application/javascript"`
	JSON      string `json:"application/json"`
	HTML      string `json:"text/html"`

	PNG String64 `json:"image/png"`
	JPG String64 `json:"image/jpeg"`
	SVG String64 `json:"image/svg+xml"`
}

func (*Data) Multipart

func (m *Data) Multipart() (b []byte, mimeType string, err error)

func (*Data) Text

func (m *Data) Text() (string, bool)

type Error

type Error struct {
	Ename     string   `json:"ename"`
	Evalue    string   `json:"evalue"`
	Traceback []string `json:"traceback"`
	// contains filtered or unexported fields
}

func (Error) Error

func (e Error) Error() string

func (Error) String

func (e Error) String() string
type Header struct {
	ID       string    `json:"msg_id,omitempty"`
	Type     string    `json:"msg_type,omitempty"`
	Username string    `json:"username,omitempty"`
	Session  string    `json:"session,omitempty"`
	Version  string    `json:"version,omitempty"`
	Date     time.Time `json:"date,omitempty"`
}

type Kernel

type Kernel struct {
	ID        uuid.UUID
	Name      string
	Session   string
	User      string
	Status    string
	KeepAlive time.Duration
	Client    *api.Client
	URL       *url.URL
	// contains filtered or unexported fields
}

func (*Kernel) Close

func (k *Kernel) Close() (err error)

func (*Kernel) Execute

func (k *Kernel) Execute(ctx context.Context, code string) (chan *Content, error)

Execute

func (*Kernel) Interrupt

func (k *Kernel) Interrupt(ctx context.Context) error

Interrupt stops the current kernel execution, & makes way for a new one.

func (*Kernel) Listen

func (k *Kernel) Listen() <-chan *Content

Listen returns a combined stdout/stderr stream.

func (*Kernel) Shutdown

func (k *Kernel) Shutdown(ctx context.Context) error

Shutdown kills the kernel, & releases the resources associated with it.

type Message

type Message struct {
	Header       *Header         `json:"header"`
	ParentHeader *Header         `json:"parent_header"`
	Channel      string          `json:"channel"`
	ID           string          `json:"msg_id"`
	Type         string          `json:"msg_type"`
	Content      json.RawMessage `json:"content"`
	Metadata     map[string]any  `json:"metadata"`
	Buffers      []any           `json:"buffers"`
}

func (Message) String

func (m Message) String() string

func (*Message) Unmarshal

func (m *Message) Unmarshal(v any) error

type String64

type String64 string

String64 is a base64 encoded string.

func (String64) Bytes

func (s String64) Bytes() ([]byte, error)

Directories

Path Synopsis
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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