drpcwire

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2019 License: Apache-2.0 Imports: 9 Imported by: 1

README

package drpcwire

import "storj.io/drpc/drpcwire"

package drpcwire provides low level helpers for the drpc wire protocol.

Usage

func AppendFrame
func AppendFrame(buf []byte, fr Frame) []byte
func AppendVarint
func AppendVarint(buf []byte, x uint64) []byte

AppendVarint appends the varint encoding of x to the buffer and returns it.

func MarshalError
func MarshalError(err error) []byte

MarshalError returns a byte form of the error with any error code incorporated.

func ReadVarint
func ReadVarint(buf []byte) (rem []byte, out uint64, ok bool, err error)

ReadVarint reads a varint encoded integer from the front of buf, returning the remaining bytes, the value, and if there was a success. if ok is false, the returned buffer is the same as the passed in buffer.

func SplitFrame
func SplitFrame(data []byte, atEOF bool) (int, []byte, error)
func SplitN
func SplitN(pkt Packet, n int, cb func(fr Frame) error) error
func UnmarshalError
func UnmarshalError(data []byte) error

UnmarshalError unmarshals the marshaled error to one with a code.

type Frame
type Frame struct {
	Data []byte
	ID   ID
	Kind Kind
	Done bool
}
func ParseFrame
func ParseFrame(buf []byte) (rem []byte, fr Frame, ok bool, err error)
type ID
type ID struct {
	Stream  uint64
	Message uint64
}
func (ID) Less
func (i ID) Less(j ID) bool
func (ID) String
func (i ID) String() string
type Kind
type Kind uint8
const (
	Kind_Reserved Kind = iota

	Kind_Invoke    // body is rpc name
	Kind_Message   // body is message data
	Kind_Error     // body is error data
	Kind_Cancel    // body must be empty
	Kind_Close     // body must be empty
	Kind_CloseSend // body must be empty

	Kind_Largest
)
func (Kind) String
func (i Kind) String() string
type Packet
type Packet struct {
	Data []byte
	ID   ID
	Kind Kind
}
func (Packet) String
func (p Packet) String() string
type Reader
type Reader struct {
}
func NewReader
func NewReader(r io.Reader) *Reader
func (*Reader) ReadPacket
func (s *Reader) ReadPacket() (pkt Packet, err error)
type Writer
type Writer struct {
}
func NewWriter
func NewWriter(w io.Writer, size int) *Writer
func (*Writer) Flush
func (b *Writer) Flush() (err error)
func (*Writer) WriteFrame
func (b *Writer) WriteFrame(fr Frame) (err error)
func (*Writer) WritePacket
func (b *Writer) WritePacket(pkt Packet) (err error)

Documentation

Overview

package drpcwire provides low level helpers for the drpc wire protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFrame

func AppendFrame(buf []byte, fr Frame) []byte

func AppendVarint

func AppendVarint(buf []byte, x uint64) []byte

AppendVarint appends the varint encoding of x to the buffer and returns it.

func MarshalError

func MarshalError(err error) []byte

MarshalError returns a byte form of the error with any error code incorporated.

func ReadVarint

func ReadVarint(buf []byte) (rem []byte, out uint64, ok bool, err error)

ReadVarint reads a varint encoded integer from the front of buf, returning the remaining bytes, the value, and if there was a success. if ok is false, the returned buffer is the same as the passed in buffer.

func SplitFrame

func SplitFrame(data []byte, atEOF bool) (int, []byte, error)

func SplitN

func SplitN(pkt Packet, n int, cb func(fr Frame) error) error

func UnmarshalError

func UnmarshalError(data []byte) error

UnmarshalError unmarshals the marshaled error to one with a code.

Types

type Frame

type Frame struct {
	Data []byte
	ID   ID
	Kind Kind
	Done bool
}

func ParseFrame

func ParseFrame(buf []byte) (rem []byte, fr Frame, ok bool, err error)

type ID

type ID struct {
	Stream  uint64
	Message uint64
}

func (ID) Less

func (i ID) Less(j ID) bool

func (ID) String added in v0.0.5

func (i ID) String() string

type Kind

type Kind uint8
const (
	Kind_Reserved Kind = iota

	Kind_Invoke    // body is rpc name
	Kind_Message   // body is message data
	Kind_Error     // body is error data
	Kind_Cancel    // body must be empty
	Kind_Close     // body must be empty
	Kind_CloseSend // body must be empty

	Kind_Largest
)

func (Kind) String

func (i Kind) String() string

type Packet

type Packet struct {
	Data []byte
	ID   ID
	Kind Kind
}

func (Packet) String

func (p Packet) String() string

type Reader

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

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) ReadPacket

func (s *Reader) ReadPacket() (pkt Packet, err error)

type Writer

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

func NewWriter

func NewWriter(w io.Writer, size int) *Writer

func (*Writer) Flush

func (b *Writer) Flush() (err error)

func (*Writer) WriteFrame

func (b *Writer) WriteFrame(fr Frame) (err error)

func (*Writer) WritePacket

func (b *Writer) WritePacket(pkt Packet) (err error)

Jump to

Keyboard shortcuts

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