grpcutil

package
v2.111.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package grpcutil contains gRPC lazy codecs, messages and a pipe-based listener.

Index

Constants

View Source
const (
	P_GRPC           = BertyCustomPrefix + 0x0002 //nolint:golint
	P_GRPC_WEB       = BertyCustomPrefix + 0x0004 //nolint:golint
	P_GRPC_WEBSOCKET = BertyCustomPrefix + 0x0008 //nolint:golint
	P_GRPC_GATEWAY   = BertyCustomPrefix + 0x0016 //nolint:golint
)
View Source
const BertyCustomPrefix = 0xbe00

BertyCustomPrefix is a multiformat custom prefix

Variables

This section is empty.

Functions

This section is empty.

Types

type LazyCodec

type LazyCodec struct{}

LazyCodec is basically a no-op grpc.Codec use to pass LazyMessage through grpc

func NewLazyCodec

func NewLazyCodec() *LazyCodec

func (*LazyCodec) Marshal

func (lc *LazyCodec) Marshal(value interface{}) ([]byte, error)

func (*LazyCodec) Name

func (lc *LazyCodec) Name() string

func (*LazyCodec) String

func (lc *LazyCodec) String() string

func (*LazyCodec) Unmarshal

func (*LazyCodec) Unmarshal(buf []byte, value interface{}) error

type LazyMessage

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

LazyMessage is basically a no-op `proto.Message` used to pass serialized message through grpc

func NewLazyMessage

func NewLazyMessage() *LazyMessage

func (*LazyMessage) Base64

func (m *LazyMessage) Base64() string

func (*LazyMessage) Bytes

func (m *LazyMessage) Bytes() []byte

func (*LazyMessage) FromBase64

func (m *LazyMessage) FromBase64(b64 string) (lm *LazyMessage, err error)

func (*LazyMessage) FromBytes

func (m *LazyMessage) FromBytes(buf []byte) *LazyMessage

func (*LazyMessage) ProtoMessage

func (m *LazyMessage) ProtoMessage()

func (*LazyMessage) Reset

func (m *LazyMessage) Reset()

func (*LazyMessage) String

func (m *LazyMessage) String() string

type Listener

type Listener interface {
	manet.Listener

	GRPCMultiaddr() ma.Multiaddr
}

func Listen

func Listen(maddr ma.Multiaddr) (Listener, error)

type PipeListener

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

func NewPipeListener

func NewPipeListener() *PipeListener

func NewPipeListenerWithContext added in v2.92.0

func NewPipeListenerWithContext(ctx context.Context) *PipeListener

func (*PipeListener) Accept

func (pl *PipeListener) Accept() (net.Conn, error)

func (*PipeListener) AddConn

func (pl *PipeListener) AddConn(c net.Conn)

Add conn forward the given conn to the listener

func (*PipeListener) Addr

func (pl *PipeListener) Addr() net.Addr

func (*PipeListener) Close

func (pl *PipeListener) Close() error

func (*PipeListener) Network

func (pl *PipeListener) Network() string

func (*PipeListener) NewClientConn

func (pl *PipeListener) NewClientConn(opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)

NewClientConn return a grpc conn connected with the listener

func (*PipeListener) String

func (pl *PipeListener) String() string

type Server

type Server struct {
	*grpc.Server
	*grpcgw.ServeMux
}

func (*Server) Serve

func (s *Server) Serve(l Listener) error

Jump to

Keyboard shortcuts

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