igo

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

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

Go to latest
Published: Sep 17, 2017 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package igo implements the machinery necessary to run a Go kernel for IPython. It should be installed with an "igo" command to launch the kernel.

Index

Constants

This section is empty.

Variables

View Source
var ExecCounter int = 0

ExecCounter is incremented each time we run user code.

View Source
var World *eval.World

World holds the user namespace for the REPL.

Functions

func HandleExecuteRequest

func HandleExecuteRequest(receipt MsgReceipt)

HandleExecuteRequest runs code from an execute_request method, and sends the various reply messages.

func HandleShellMsg

func HandleShellMsg(receipt MsgReceipt)

HandleShellMsg responds to a message on the shell ROUTER socket.

func HandleShutdownRequest

func HandleShutdownRequest(receipt MsgReceipt)

func RunCode

func RunCode(text string) (val interface{}, err error)

RunCode runs the given user code, returning the expression value and/or an error.

func RunKernel

func RunKernel(connection_file string, logwriter io.Writer)

RunKernel is the main entry point to start the kernel. This is what is called by the igo executable.

func SendKernelInfo

func SendKernelInfo(receipt MsgReceipt)

SendKernelInfo sends a kernel_info_reply message.

func SetupExecutionEnvironment

func SetupExecutionEnvironment()

Types

type ComposedMsg

type ComposedMsg struct {
	Header        MsgHeader
	Parent_header MsgHeader
	Metadata      map[string]interface{}
	Content       interface{}
}

ComposedMsg represents an entire message in a high-level structure.

func NewMsg

func NewMsg(msg_type string, parent ComposedMsg) (msg ComposedMsg)

NewMsg creates a new ComposedMsg to respond to a parent message. This includes setting up its headers.

func WireMsgToComposedMsg

func WireMsgToComposedMsg(msgparts [][]byte, signkey []byte) (msg ComposedMsg,
	identities [][]byte, err error)

WireMsgToComposedMsg translates a multipart ZMQ messages received from a socket into a ComposedMsg struct and a slice of return identities. This includes verifying the message signature.

func (ComposedMsg) ToWireMsg

func (msg ComposedMsg) ToWireMsg(signkey []byte) (msgparts [][]byte)

ToWireMsg translates a ComposedMsg into a multipart ZMQ message ready to send, and signs it. This does not add the return identities or the delimiter.

type ConnectionInfo

type ConnectionInfo struct {
	Signature_scheme string
	Transport        string
	Stdin_port       int
	Control_port     int
	IOPub_port       int
	HB_port          int
	Shell_port       int
	Key              string
	IP               string
}

ConnectionInfo stores the contents of the kernel connection file created by IPython.

type ErrMsg

type ErrMsg struct {
	EName     string   `json:"ename"`
	EValue    string   `json:"evalue"`
	Traceback []string `json:"traceback"`
}

type InvalidSignatureError

type InvalidSignatureError struct{}

InvalidSignatureError is returned when the signature on a received message does not validate.

func (*InvalidSignatureError) Error

func (e *InvalidSignatureError) Error() string

type KernelInfo

type KernelInfo struct {
	Protocol_version []int  `json:"protocol_version"`
	Language         string `json:"language"`
}

KernelInfo holds information about the igo kernel, for kernel_info_reply messages.

type KernelStatus

type KernelStatus struct {
	ExecutionState string `json:"execution_state"`
}

KernelStatus holds a kernel state, for status broadcast messages.

type MsgHeader

type MsgHeader struct {
	Msg_id   string `json:"msg_id"`
	Username string `json:"username"`
	Session  string `json:"session"`
	Msg_type string `json:"msg_type"`
}

type MsgReceipt

type MsgReceipt struct {
	Msg        ComposedMsg
	Identities [][]byte
	Sockets    SocketGroup
}

MsgReceipt represents a received message, its return identities, and the sockets for communication.

func (*MsgReceipt) SendResponse

func (receipt *MsgReceipt) SendResponse(socket *zmq.Socket, msg ComposedMsg)

SendResponse sends a message back to return identites of the received message.

type OutputMsg

type OutputMsg struct {
	Execcount int                    `json:"execution_count"`
	Data      map[string]string      `json:"data"`
	Metadata  map[string]interface{} `json:"metadata"`
}

OutputMsg holds the data for a pyout message.

type ShutdownReply

type ShutdownReply struct {
	Restart bool `json:"restart"`
}

type SocketGroup

type SocketGroup struct {
	Shell_socket   *zmq.Socket
	Control_socket *zmq.Socket
	Stdin_socket   *zmq.Socket
	IOPub_socket   *zmq.Socket
	Key            []byte
}

SocketGroup holds the sockets the kernel needs to communicate with the kernel, and the key for message signing.

func PrepareSockets

func PrepareSockets(conn_info ConnectionInfo) (sg SocketGroup)

PrepareSockets sets up the ZMQ sockets through which the kernel will communicate.

Jump to

Keyboard shortcuts

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