bfe_stream

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProtoHandler

func NewProtoHandler(conf *Server) func(*http.Server, *tls.Conn, http.Handler)

NewProtoHandler creates a protocol handler for stream.

func SetServerRule

func SetServerRule(r ServerRule)

func TLSProxyHandler

func TLSProxyHandler(s *Server, c net.Conn, b net.Conn, errCh chan error)

TLSProxyHandler copy data between client conn and backend conn.

Types

type BalanceHandler

type BalanceHandler func(c interface{}) (*backend.BfeBackend, error)

BalanceHandler selects backend for current conn.

type FindProductHandler

type FindProductHandler func(c net.Conn) string

FindProductHandler gets product by conn vip.

type ProxyHandler

type ProxyHandler func(s *Server, c net.Conn, b net.Conn, errCh chan error)

ProxyHandler forwards data between client and backend.

type Rule

type Rule struct {
	ProxyProtocol int
}

Rule is the customized config for specific conn in server side.

type Server

type Server struct {
	// ConnectTimeout optionally specifies the timeout value (ms) to
	// connect backend. If zero, a default value is used.
	ConnectTimeout int

	// ConnectRetryMax optionally specifies the upper limit of connect
	// retris. If zero, a default value is used
	ConnectRetryMax int

	// BalanceHandler optionally specifies the handler for backends balance
	// BalanceHandler should not be nil.
	BalanceHandler BalanceHandler

	// FindProductHandler finds product name for stream proxy
	FindProductHandler FindProductHandler

	// ProxyHandler optionally specifies the handler for process client conn
	// and backend conn. If nil, a default value is used.
	ProxyHandler ProxyHandler

	// ProxyConfig optionally specifies the config for ProxyHandler
	ProxyConfig interface{}
}

func (*Server) FindProduct

func (s *Server) FindProduct(c net.Conn) string

FindProduct finds product by conn vip.

type ServerRule

type ServerRule interface {
	GetStreamRule(conn *tls.Conn) *Rule
}

type ServerTester

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

func NewServerTester

func NewServerTester(t testing.TB, h util.MockHandler, c *Server) *ServerTester

func (*ServerTester) Close

func (st *ServerTester) Close()

func (*ServerTester) Read

func (st *ServerTester) Read(buf []byte) error

client read message until timeout

func (*ServerTester) WantData

func (st *ServerTester) WantData(data []byte)

client read and check message

func (*ServerTester) WantError

func (st *ServerTester) WantError(e string)

client read and check error

func (*ServerTester) Write

func (st *ServerTester) Write(data []byte) error

client write message

type StreamState

type StreamState struct {
	StreamErrBalance  *metrics.Counter
	StreamErrConnect  *metrics.Counter
	StreamErrProxy    *metrics.Counter
	StreamErrTransfer *metrics.Counter
	StreamPanicConn   *metrics.Counter
	StreamBytesRecv   *metrics.Counter
	StreamBytesSent   *metrics.Counter
}

StreamState is internal state for stream.

func GetStreamState

func GetStreamState() *StreamState

GetStreamState returns internal state for stream.

Jump to

Keyboard shortcuts

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