rpc

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package rpc implements the communication between the h2c command line interface and the h2c process.

The command line interface uses a simple request/response protocol to communicate with the h2c process:

The cli sends a Command struct to the h2c process, and receives a Result struct as result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name    string
	Args    []string
	Options map[string]string
}

Command struct is sent from the command line interface to the h2c process.

func NewCommand

func NewCommand(name string, args []string, options map[string]string) (*Command, error)

func UnmarshalCommand

func UnmarshalCommand(encodedCmd string) (*Command, error)

Used by the h2c process when receiving a command from the command line interface.

func (*Command) Marshal

func (cmd *Command) Marshal() (string, error)

Marshal returns the base64 encoding of a Command.

The resulting string does not contain newlines, so newlines can be used as separators between multiple commands.

type IpcManager

type IpcManager interface {
	IsListening() bool
	Listen() (net.Listener, error)
	Dial() (net.Conn, error)
	InUseErrorMessage() string
}

IpcManager maintains the socket for communication between the cli and the h2c process.

type Result

type Result struct {
	Message string
	Error   *string // Should be type error, but this doesn't seem to work well with JSON marshalling.
}

Result is sent from the h2c process to the command line interface.

func NewResult

func NewResult(msg string, err error) *Result

func UnmarshalResult

func UnmarshalResult(encodedResult string) (*Result, error)

Used by the command line interface when receiving a Result from the h2c process.

func (*Result) Marshal

func (res *Result) Marshal() (string, error)

Marshal returns the base64 encoding of Result.

type UnixSocketConnection

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

Implements rpc.IpcManager

func NewIpcManager

func NewIpcManager() *UnixSocketConnection

func (*UnixSocketConnection) Dial

func (s *UnixSocketConnection) Dial() (net.Conn, error)

func (*UnixSocketConnection) InUseErrorMessage

func (s *UnixSocketConnection) InUseErrorMessage() string

func (*UnixSocketConnection) IsListening

func (s *UnixSocketConnection) IsListening() bool

func (*UnixSocketConnection) Listen

func (s *UnixSocketConnection) Listen() (net.Listener, error)

Jump to

Keyboard shortcuts

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