kernel

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Delimiter       = "<IDS|MSG>"
	ProtocolVersion = "5.0"
)
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 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 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) 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.

Jump to

Keyboard shortcuts

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