Documentation ¶
Index ¶
Constants ¶
const ( // PayloadEmpty must be set when no data to be sent. PayloadEmpty byte = 2 // PayloadRaw must be set when data binary data. PayloadRaw byte = 4 // PayloadError must be set when data is error string or structure. PayloadError byte = 8 // PayloadControl defines that associated data must be treated as control data. PayloadControl byte = 16 )
const (
// BufferSize defines max amount of bytes to read from connection at once.
BufferSize = 655336
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec represent net/rpc bridge over Goridge socket relay.
func NewCodec ¶
func NewCodec(rwc io.ReadWriteCloser) *Codec
NewCodec initiates new server rpc codec over socket connection.
func (*Codec) ReadRequestBody ¶
ReadRequestBody fetches prefixed body data and automatically unmarshal it as json. RawBody flag will populate []byte lice argument for rpc method.
func (*Codec) ReadRequestHeader ¶
ReadRequestHeader receives
type PipeRelay ¶
type PipeRelay struct { // How many bytes to write/read at once. BufferSize uint64 // contains filtered or unexported fields }
PipeRelay communicate with underlying process using standard streams (STDIN, STDOUT). Attention, use TCP alternative for Windows as more reliable option. This relay closes automatically with the process.
func NewPipeRelay ¶
func NewPipeRelay(in io.ReadCloser, out io.WriteCloser) *PipeRelay
NewPipeRelay creates new pipe based data relay.
func (*PipeRelay) Close ¶
Close the connection. Pipes are closed automatically with the underlying process.
type Prefix ¶
type Prefix [9]byte
Prefix is always 9 bytes long and contain meta flags and length of next data package. Receive prefix by converting it into the slice.
func (Prefix) HasPayload ¶
HasPayload returns true if data is not empty.
func (Prefix) WithFlag ¶
WithFlag unites given value with flag byte and returns new instance of prefix.
type Relay ¶
type Relay interface { // Send signed (prefixed) data to PHP process. Send(data []byte, flags byte) (err error) // Receive data from the underlying process and returns associated prefix or error. Receive() (data []byte, p Prefix, err error) // Close the connection. Close() error }
Relay provide IPC over signed payloads.
type SocketRelay ¶
type SocketRelay struct { // How many bytes to write/read at once. BufferSize uint64 // contains filtered or unexported fields }
SocketRelay communicates with underlying process using sockets (TPC or Unix).
func NewSocketRelay ¶
func NewSocketRelay(rwc io.ReadWriteCloser) *SocketRelay
NewSocketRelay creates new socket based data relay.