kernel

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Delimiter       = "<IDS|MSG>"
	ProtocolVersion = "5.4"
)
View Source
const (
	KernelVersion = "0.1.0"
)

Variables

This section is empty.

Functions

func Sign

func Sign(key []byte, header, parentHeader, metadata, content []byte) string

Sign computes the HMAC-SHA256 signature for the message parts.

func VerifySignature

func VerifySignature(key []byte, frames [][]byte) bool

VerifySignature checks the HMAC signature of incoming message frames.

Types

type ArrowServer added in v0.1.1

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

ArrowServer serves Arrow IPC files over HTTP directly from the spool. Also serves static assets (perspective JS/WASM) for VS Code renderer. Exposes /introspect endpoint for database metadata exploration.

func NewArrowServer added in v0.1.1

func NewArrowServer(sp *spool.Spool, introspector *engine.Introspector) (*ArrowServer, error)

NewArrowServer creates and starts an HTTP server on a random port.

func (*ArrowServer) ArrowURL added in v0.1.1

func (as *ArrowServer) ArrowURL(queryID string, totalRows int64) string

ArrowURL returns the URL for fetching the given query's Arrow data. Uses streaming endpoint for large datasets, raw file for small ones.

func (*ArrowServer) BaseURL added in v0.1.1

func (as *ArrowServer) BaseURL() string

BaseURL returns the base URL of the Arrow HTTP server.

func (*ArrowServer) Close added in v0.1.1

func (as *ArrowServer) Close() error

Close shuts down the HTTP server.

func (*ArrowServer) Port added in v0.1.1

func (as *ArrowServer) Port() int

Port returns the port the server is listening on.

type ConnectionInfo

type ConnectionInfo struct {
	Transport       string `json:"transport"`
	IP              string `json:"ip"`
	ShellPort       int    `json:"shell_port"`
	ControlPort     int    `json:"control_port"`
	IOPubPort       int    `json:"iopub_port"`
	StdinPort       int    `json:"stdin_port"`
	HBPort          int    `json:"hb_port"`
	Key             string `json:"key"`
	SignatureScheme string `json:"signature_scheme"`
}

ConnectionInfo holds the parsed Jupyter connection file data.

func (*ConnectionInfo) Endpoint

func (c *ConnectionInfo) Endpoint(port int) string

Endpoint returns the ZMQ endpoint string for a given port.

type Header struct {
	MsgID    string `json:"msg_id"`
	Session  string `json:"session"`
	Username string `json:"username"`
	Date     string `json:"date"`
	MsgType  string `json:"msg_type"`
	Version  string `json:"version"`
}

Header represents a Jupyter message header.

type History added in v0.2.0

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

History stores recent executed queries and persists them to a temp file.

func NewHistory added in v0.2.0

func NewHistory(dir string, sessionID string) *History

NewHistory creates a history backed by a file in the given directory.

func (*History) Add added in v0.2.0

func (h *History) Add(execCount int, source string)

Add appends a query to the history, keeping only the last maxHistorySize entries.

func (*History) Entries added in v0.2.0

func (h *History) Entries() [][]any

Entries returns all history entries as [session, line, source] tuples compatible with the Jupyter history_reply format.

type HistoryEntry added in v0.2.0

type HistoryEntry struct {
	Session int    `json:"session"`
	Line    int    `json:"line"`
	Source  string `json:"source"`
}

HistoryEntry represents a single executed query in the history.

type Kernel

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

Kernel manages the Jupyter kernel lifecycle and ZMQ sockets.

func NewKernel

func NewKernel(connInfo *ConnectionInfo, sess *session.Session, sp *spool.Spool) *Kernel

NewKernel creates a new kernel with the given connection info, session, and spool.

func (*Kernel) SetTileSources added in v0.2.0

func (k *Kernel) SetTileSources(sources []TileSourceConfig)

SetTileSources configures basemap tile sources for the map plugin.

func (*Kernel) Shutdown

func (k *Kernel) Shutdown()

Shutdown signals the kernel to stop.

func (*Kernel) Start

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

Start initializes ZMQ sockets and begins the message loop.

type Message

type Message struct {
	Identities   [][]byte
	Header       Header
	ParentHeader Header
	Metadata     map[string]any
	Content      map[string]any
}

Message represents a complete Jupyter wire protocol message.

func Deserialize

func Deserialize(frames [][]byte) (*Message, error)

Deserialize parses wire format frames into a Message.

func NewMessage

func NewMessage(parent *Message, msgType string) *Message

NewMessage creates a new message as a reply to the given parent.

func (*Message) Serialize

func (m *Message) Serialize(key []byte) ([][]byte, error)

Serialize converts the message to wire format frames.

type TileSourceConfig added in v0.2.0

type TileSourceConfig struct {
	Name        string `json:"name"`
	URL         string `json:"url"`
	Type        string `json:"type"` // "raster", "vector", "tilejson"
	Attribution string `json:"attribution,omitempty"`
	MinZoom     int    `json:"min_zoom,omitempty"`
	MaxZoom     int    `json:"max_zoom,omitempty"`
}

TileSourceConfig holds a basemap tile source configuration.

Jump to

Keyboard shortcuts

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