protobuf

package
v0.0.0-...-4e2cb2d Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package protobuf implements a ClientCodec and ServerCodec for the network package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(network, address string) (*network.Client, error)

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

func NewClient

func NewClient(conn io.ReadWriteCloser) *network.Client

NewClient returns a new network.Client to handle requests to the set of services at the other end of the connection.

func NewClientCodec

func NewClientCodec(conn io.ReadWriteCloser) network.ClientCodec

NewClientCodec returns a new network.ClientCodec using ProtoBuf on conn.

func NewServerCodec

func NewServerCodec(conn io.ReadWriteCloser) network.ServerCodec

NewServerCodec returns a new network.ServerCodec using Protobuf on conn.

func ServeConn

func ServeConn(server *network.Server, conn io.ReadWriteCloser)

ServeConn runs the Protobuf server on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement.

Types

type Decoder

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

A Decoder reads and decodes Proto Buffer values from an input stream.

func NewDecoder

func NewDecoder(r *network.ConnReader) *Decoder

NewDecoder returns a new decoder that reads from r.

The decoder introduces its own buffering and may read data from r beyond the Proto Buffer values requested.

func (*Decoder) Decode

func (dec *Decoder) Decode(m proto.Message) (err error)

type Encoder

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

An Encoder writes Proto Buffer values to an output stream.

func NewEncoder

func NewEncoder(w *network.ConnWriter) *Encoder

NewEncoder returns a new encoder that writes to w.

func (*Encoder) Encode

func (enc *Encoder) Encode(m proto.Message) error

Encode writes the Proto Buffer encoding of v to the stream. preceded by big-endian uint16 len.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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