rpc

package
v0.0.0-...-ff27e19 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2014 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint interface {
	broker.Endpoint

	DispatchRequest(receiver []byte, msg Request) error
	DispatchInterrupt(receiver []byte, msg Interrupt) error
	DispatchProgress(msg Progress) error
	DispatchStreamFrame(msg StreamFrame) error
	DispatchReply(msg Reply) error
}

Endpoint represents an RPC endpoint for particular transport and it works like a bridge between the remote application and the central RPC handler.

type Exchange

type Exchange interface {
	// RegisterMethod tells the handler that the app can start processing
	// requests to the method specified.
	RegisterMethod(app string, endpoint Endpoint, method string) error

	// UnregisterMethod is the opposite of RegisterMethod.
	UnregisterMethod(app string, method string)

	// UnregisterApp unregisters the app. This should be called by the endpoint
	// one the application has disconnected.
	UnregisterApp(app string)

	// UnregisterEndpoint is invoked when the relevant endpoint is closed so
	// that the handler can perform some cleanup if necessary.
	UnregisterEndpoint(endpoint Endpoint)

	HandleRequest(msg Request, srcEndpoint Endpoint)
	HandleInterrupt(msg Interrupt)
	HandleProgress(msg Progress)
	HandleStreamFrame(msg StreamFrame)
	HandleReply(msg Reply)
}

Exchange takes care of RPC requests routing and dispatching. Its sole purpose is to receive requests, decide what application should be in change and forward it to the given applicaton.

type Interrupt

type Interrupt interface {

	// Sender is the application that sent the interrupt.
	Sender() []byte

	// TargetRequestId returns ID of the request that is supposed to be
	// interrupted. It always contains uint16 (BE).
	TargetRequestId() []byte
}

Interrupt is a message for signalling that a RPC request should stop executing. It works much like SIGINT for OS processes.

type Progress

type Progress interface {
	Sender() []byte
	Receiver() []byte
	TargetRequestId() []byte
}

Progress is a message that can be sent from the app executing a method to the original requester to signal that something important has happened.

The semantics must be defined by the method itself.

type Reply

type Reply interface {
	Sender() []byte
	Receiver() []byte
	TargetRequestId() []byte
	ReturnCode() []byte
	ReturnValue() []byte
}

Reply message notifies the RPC requester about the result of the call.

The semantics of the return code and value must be defined by the method.

type Request

type Request interface {

	// Sender is the application that sent the request.
	Sender() []byte

	// Id must be unique for the given sender. It always contains a uint16 (BE).
	Id() []byte

	// Method returns the remote method requested.
	Method() []byte

	// Args returns the arguments for the method call, marshalled.
	Args() []byte

	// StdoutTag returns the stream tag identifying this request's stdout stream.
	// If no stream is requested, this method returns an empty slice.
	StdoutTag() []byte

	// StderrTag is the same as StdoutTag, just for stderr instead of stdout.
	StderrTag() []byte

	// A utility function for the RPC handler to be able to reject requests
	// for methods that nobody really exported more easily.
	Reject(code byte, reason string) error
}

Request represents an RPC call from one application to another. It contains the method to be called and the arguments to be passed to that method when invoked.

type StreamFrame

type StreamFrame interface {
	Sender() []byte
	Receiver() []byte
	TargetStreamTag() []byte
	Body() []byte
}

StreamFrame is a message type that represents a fraction of an output stream, in our case it is either stderr or stdout.

It contains the stream tag and the sequence number so that the receiver can assemble incoming stream frames into the original stream again.

Jump to

Keyboard shortcuts

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