Documentation ¶
Index ¶
- Constants
- type ClientCodec
- type Codec
- type PipeRelay
- type Prefix
- func (p Prefix) Flags() byte
- func (p Prefix) HasFlag(flag byte) bool
- func (p Prefix) HasPayload() bool
- func (p Prefix) Size() uint64
- func (p Prefix) String() string
- func (p Prefix) Valid() bool
- func (p Prefix) WithFlag(flag byte) Prefix
- func (p Prefix) WithFlags(flags byte) Prefix
- func (p Prefix) WithSize(size uint64) Prefix
- type Relay
- type SocketRelay
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 ClientCodec ¶
type ClientCodec struct {
// contains filtered or unexported fields
}
Client codec for goridge connection.
func NewClientCodec ¶
func NewClientCodec(rwc io.ReadWriteCloser) *ClientCodec
NewCodec initiates new server rpc codec over socket connection.
func (*ClientCodec) ReadResponseBody ¶
func (c *ClientCodec) ReadResponseBody(out interface{}) error
ReadResponseBody response from the connection.
func (*ClientCodec) ReadResponseHeader ¶
func (c *ClientCodec) ReadResponseHeader(r *rpc.Response) error
ReadResponseHeader reads response from the connection.
func (*ClientCodec) WriteRequest ¶
func (c *ClientCodec) WriteRequest(r *rpc.Request, body interface{}) error
WriteRequest writes request to the connection. Sequential.
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 [17]byte
Prefix is always 17 bytes long and contain meta flags and length of next data package. Receive prefix by converting it into the slice. Prefix duplicates size using reverse bytes order to detect possible transmission errors.
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.