message

package
v0.2.14 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2018 License: NCSA Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidSignatureError = errors.New("A message had an invalid signature")

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

Functions

This section is empty.

Types

type Header struct {
	ID       string      `json:"msg_id"`
	Username string      `json:"username"`
	Session  string      `json:"session"`
	Type     MessageType `json:"msg_type"`
	Date     time.Time   `json:"date"`
	Version  string      `json:"version"`
}

The message header contains a pair of unique identifiers for the originating session and the actual message id, in addition to the username for the process that generated the message. This is useful in collaborative settings where multiple users may be interacting with the same kernel simultaneously, so that frontends can label the various messages in a meaningful way.

type Message

type Message struct {
	Header Header `json:"header"`
	// In a chain of messages, the header from the parent is copied so that
	// clients can track where messages come from.
	ParentHeader Header `json:"parent_header"`
	// Any metadata associated with the message.
	Metadata map[string]interface{} `json:"metadata"`
	// The actual content of the message must be a dict, whose structure
	// depends on the message type.
	Content interface{} `json:"content"`
	// optional: buffers is a list of binary data buffers for implementations
	// that support binary extensions to the protocol.
	Buffer []string `json:"buffer"`
}

func FromWire

func FromWire(msgparts [][]byte, signkey []byte) (*Message, [][]byte, error)

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

func New

func New(msgType MessageType, parent Message) (*Message, error)

New creates a new Message to respond to a parent message. This includes setting up its headers.

func (Message) ToWire

func (msg Message) ToWire(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 MessageType

type MessageType string
const (
	ErrorReplyType        MessageType = "error"
	CommCloseType         MessageType = "comm_close"
	CommInfoRequestType   MessageType = "comm_info_request"
	CommMessageType       MessageType = "comm_msg"
	CommOpenType          MessageType = "comm_open"
	CompleteRequestType   MessageType = "complete_request"
	ConnectReplyType      MessageType = "connect_reply"
	ConnectRequestType    MessageType = "connect_request"
	ExecuteReplyType      MessageType = "execute_reply"
	ExecuteRequestType    MessageType = "execute_request"
	ExecuteResultType     MessageType = "execute_result"
	HistoryRequestType    MessageType = "history_request"
	InspectRequestType    MessageType = "inspect_request"
	IsCompleteRequestType MessageType = "is_complete_request"
	KernelInfoReplyType   MessageType = "kernel_info_reply"
	KernelInfoRequestType MessageType = "kernel_info_request"
	ShutdownReplyType     MessageType = "shutdown_reply"
	ShutdownRequestType   MessageType = "shutdown_request"
	StatusType            MessageType = "status"
)

type Receipt

type Receipt struct {
	Message    Message
	Identities [][]byte
	Connection *connection.Connection
}

func (Receipt) SendResponse

func (receipt Receipt) SendResponse(socket *zmq.Socket, msg *Message) error

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

Jump to

Keyboard shortcuts

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