grpc

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 22 Imported by: 6

Documentation

Index

Constants

View Source
const (
	VarGrpcRequestResult = "requestResult"
	VarGrpcServiceName   = grpcName + "_" + grpcServiceName
)

Variables

View Source
var (
	ErrUnknownServer = errors.New("cannot found the grpc server")
	ErrInvalidConfig = errors.New("invalid config for grpc listener")
)

Functions

func CreateGRPCServerFilterFactory

func CreateGRPCServerFilterFactory(conf map[string]interface{}) (api.NetworkFilterChainFactory, error)

CreateGRPCServerFilterFactory returns a grpc network filter factory. The conf contains more than v2.GRPC becasue some config is not ready yet. @nejisama

func NewGrpcFilter

func NewGrpcFilter(_ context.Context, ln *Listener) *grpcFilter

TODO: maybe we needs the context in the future

func ParseGRPC

func ParseGRPC(conf map[string]interface{}) (*v2.GRPC, error)

func RegisterServerHandler

func RegisterServerHandler(name string, f NewRegisteredServer) bool

Types

type Connection

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

func NewConn

func NewConn(c api.Connection) *Connection

func (*Connection) Close

func (c *Connection) Close() error

Close maybe called two ways: 1. mosn connection closed, the grpc connections should be closed too. 2. grpc connection closed, the mosn connections should be close too. The closed flag is used to avoid calling the Close cyclically.

func (*Connection) LocalAddr

func (c *Connection) LocalAddr() net.Addr

func (*Connection) OnEvent

func (c *Connection) OnEvent(event api.ConnectionEvent)

func (*Connection) Read

func (c *Connection) Read(b []byte) (n int, err error)

func (*Connection) RemoteAddr

func (c *Connection) RemoteAddr() net.Addr

func (*Connection) Send

func (c *Connection) Send(buf buffer.IoBuffer)

Send awakes connection Read, and will wait Read finished.

func (*Connection) SetDeadline

func (c *Connection) SetDeadline(t time.Time) error

The real connection timeout is managed by MOSN. This connection's timeout takes no effect on real connection. If the real connection reads timeout, no data send to this connection

func (*Connection) SetReadDeadline

func (c *Connection) SetReadDeadline(t time.Time) error

func (*Connection) SetWriteDeadline

func (c *Connection) SetWriteDeadline(t time.Time) error

func (*Connection) Write

func (c *Connection) Write(b []byte) (n int, err error)

type Handler

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

Handler is a wrapper to call NewRegisteredServer

func (*Handler) New added in v0.25.0

func (s *Handler) New(addr string, conf json.RawMessage, options ...grpc.ServerOption) (*registerServerWrapper, error)

New a grpc server with address. Same address returns same server, which can be start only once.

type Listener

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

Listener is an implementation of net.Listener

func NewListener

func NewListener(address string) (*Listener, error)

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) NewConnection

func (l *Listener) NewConnection(conn net.Conn) (err error)

type NewRegisteredServer

type NewRegisteredServer func(config json.RawMessage, options ...grpc.ServerOption) (RegisteredServer, error)

NewRegisteredServer returns a grpc server that has completed protobuf registration. The grpc server Serve function should be called in MOSN. NOTICE: some grpc options is not supported, for example, secure options, which are managed by MOSN too.

type RegisteredServer

type RegisteredServer interface {
	Serve(net.Listener) error
	// GracefulStop graceful stop grpc server
	GracefulStop()
	// Stop ungraceful stop grpc server
	Stop()
}

RegisteredServer is a wrapper of *(google.golang.org/grpc).Server

Jump to

Keyboard shortcuts

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