bfe_stream

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)

WantData makes client read and check message

func (*ServerTester) WantError

func (st *ServerTester) WantError(e string)

WantError makes 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