rexpro0

package
v0.0.0-...-f53217d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2013 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package rexpro0 implements the RexPro version 0 protocol.

See: https://github.com/tinkerpop/rexster/wiki/RexPro-Messages/46f76da31149b2a3a68fb470d28157e23739a66d

This package is heavily inspired by the package net/rpc.

Index

Constants

View Source
const (
	ChannelConsole
	ChannelMsgPack
	ChannelGraphSON
)
View Source
const (
	ErrFlagMalformedMessage = iota
	ErrFlagSessionNotFound
	ErrFlagScriptExecFailed
	ErrFlagInvalidCredentials
	ErrFlagGraphNotFound
	ErrFlagChannelNotFound
	ErrFlagSerializationFailed
	ErrFlagUnknown = -1
)

Variables

View Source
var EmptySession [16]byte = [16]byte{}
View Source
var ErrShutdown = errors.New("connection is shut down")
View Source
var ErrUnknownVersion = errors.New("unknown protocol version")

Functions

This section is empty.

Types

type Call

type Call struct {
	Session      [16]byte
	RequestType  MsgType
	RequestMeta  MetaMap
	RequestArgs  []interface{}
	ResponseType MsgType
	ResponseMeta MetaMap
	ResponseArgs []interface{}
	Error        error
	Done         chan *Call
}

Call represents an active request.

type Client

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

Client represents a RexPro Client. There may be multiple outstanding Calls associated with a single Client, and a Client may be used by multiple goroutines simultaneously.

func Dial

func Dial(addr string) (*Client, error)

Dial connects to a RexPro server at the specified network address.

func NewClient

func NewClient(conn io.ReadWriteCloser) *Client

NewClient returns a new Client to handle requests to the set of services at the other end of the connection. It adds a buffer to both the write and read side of the connection so the header and body are sent and received as a unit.

func (*Client) Call

func (client *Client) Call(session [16]byte, typ MsgType, meta MetaMap, args []interface{}) ([16]byte, MsgType, MetaMap, []interface{}, error)

Call sends the request to the server, waits for it to complete, and returns its results.

func (*Client) Close

func (client *Client) Close() error

func (*Client) Go

func (client *Client) Go(session [16]byte, typ MsgType, meta MetaMap, args []interface{}, done chan *Call) *Call

Go invokes the function asynchronously. It returns the Call structure representing the invocation. The done channel will signal when the call is complete by returning the same Call object. If done is nil, Go will allocate a new channel. If non-nil, done must be buffered or Go will deliberately crash.

type MetaMap

type MetaMap map[string]interface{}

type MsgHeader

type MsgHeader struct {
	Version  Version
	Type     MsgType
	BodySize uint32
}

type MsgType

type MsgType byte
const (
	MsgError MsgType = iota
	MsgSessionRequest
	MsgSessionResponse
	MsgScriptRequest
	MsgScriptResponse
)

type RexsterError

type RexsterError struct {
	Flag    int
	Message string
}

RexsterError represents an Error Response returned by the RexPro server.

func (RexsterError) Error

func (e RexsterError) Error() string

type Version

type Version byte // must be 0

Jump to

Keyboard shortcuts

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