util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 41 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MeshLogPath  = "stdout"
	MeshLogLevel = "INFO"
	StartRetry   = false
)

can set

Functions

func CreateMeshToMeshConfig

func CreateMeshToMeshConfig(clientaddr string, serveraddr string, appproto types.ProtocolName, meshproto types.ProtocolName, hosts []string, tls bool) *v2.MOSNConfig

Mesh to Mesh clientaddr and serveraddr is mesh's addr appproto is client and server (not mesh) protocol meshproto is mesh's protocol hosts is server's addresses

func CreateMeshToMeshConfigWithSub added in v0.20.0

func CreateMeshToMeshConfigWithSub(clientaddr string, serveraddr string, appproto types.ProtocolName, meshproto types.ProtocolName, subproto types.ProtocolName, hosts []string, tls bool) *v2.MOSNConfig

Mesh to Mesh clientaddr and serveraddr is mesh's addr appproto is client and server (not mesh) protocol meshproto is mesh's protocol hosts is server's addresses

func CreateProxyMesh

func CreateProxyMesh(addr string, hosts []string, proto types.ProtocolName) *v2.MOSNConfig

mesh as a proxy , client and servre have same protocol

func CreateTCPProxyConfig

func CreateTCPProxyConfig(meshaddr string, hosts []string, isRouteEntryMode bool) *v2.MOSNConfig

TCP Proxy

func CreateTLSExtensionConfig

func CreateTLSExtensionConfig(clientaddr string, serveraddr string, appproto types.ProtocolName, meshproto types.ProtocolName, hosts []string, ext *ExtendVerifyConfig) *v2.MOSNConfig

func CreateXProtocolMesh

func CreateXProtocolMesh(clientaddr string, serveraddr string, subProtocol types.ProtocolName, hosts []string, tls bool) *v2.MOSNConfig

XProtocol mesh to mesh currently, support Path/Prefix is "/" only

func CreateXProtocolProxyMesh added in v0.11.0

func CreateXProtocolProxyMesh(addr string, hosts []string, proto types.ProtocolName) *v2.MOSNConfig

XProtocol mesh as a proxy , client and servre have same protocol

func CreateXWeightProxyMesh added in v0.11.0

func CreateXWeightProxyMesh(addr string, proto types.ProtocolName, clusters []*WeightCluster) *v2.MOSNConfig

mesh as a proxy , client and servre have same protocol

func CreateXprotocolTLSExtensionConfig added in v0.11.0

func CreateXprotocolTLSExtensionConfig(clientaddr string, serveraddr string, subProtocol types.ProtocolName, hosts []string, ext *ExtendVerifyConfig) *v2.MOSNConfig

func CurrentMeshAddr

func CurrentMeshAddr() string

func IsMapEmpty

func IsMapEmpty(m *sync.Map) bool

func NewBasicCluster

func NewBasicCluster(name string, hosts []string) v2.Cluster

func NewFilterChain

func NewFilterChain(routerConfigName string, downstream, upstream types.ProtocolName, routers []v2.Router) v2.FilterChain

func NewFilterChainWithSub added in v0.20.0

func NewFilterChainWithSub(routerConfigName string, downstream, upstream types.ProtocolName, subProtocol types.ProtocolName, routers []v2.Router) v2.FilterChain

func NewHeaderRouter

func NewHeaderRouter(cluster string, value string) v2.Router

common case

func NewHeaderWeightedRouter

func NewHeaderWeightedRouter(clusters []v2.WeightedCluster, value string) v2.Router

weighted cluster case

func NewListener

func NewListener(name, addr string, chains []v2.FilterChain) v2.Listener

func NewMOSNConfig

func NewMOSNConfig(listeners []v2.Listener, clusterManager v2.ClusterManagerConfig) *v2.MOSNConfig

func NewPathRouter

func NewPathRouter(cluster string, path string) v2.Router

func NewPrefixRouter

func NewPrefixRouter(cluster string, prefix string) v2.Router

func NewProxyFilter

func NewProxyFilter(routerfgname string, downstream, upstream types.ProtocolName) *v2.Proxy

Create Mesh Config

func NewWeightedCluster

func NewWeightedCluster(name string, hosts []*WeightHost) v2.Cluster

func NewXProtocolFilterChain

func NewXProtocolFilterChain(name string, subProtocol types.ProtocolName, routers []v2.Router) v2.FilterChain

func RandomDuration

func RandomDuration(min, max time.Duration) time.Duration

func ServeRPC added in v0.11.0

func ServeRPC(t *testing.T, conn net.Conn, responseHandler func(iobuf types.IoBuffer) ([]byte, bool))

func WaitMapEmpty

func WaitMapEmpty(m *sync.Map, timeout time.Duration) bool

Types

type ExtendVerifyConfig

type ExtendVerifyConfig struct {
	ExtendType   string
	VerifyConfig map[string]interface{}
}

TLS Extension

type HTTP2Server

type HTTP2Server struct {
	Server  *http2.Server
	Handler http.Handler
	// contains filtered or unexported fields
}

func (*HTTP2Server) ServeConn

func (s *HTTP2Server) ServeConn(t *testing.T, conn net.Conn)

type HTTPHandler

type HTTPHandler struct{}

Server Implement

func (*HTTPHandler) ServeHTTP

func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HTTPServer

type HTTPServer struct {
	Handler http.Handler
	// contains filtered or unexported fields
}

Http Server

func (*HTTPServer) Addr

func (s *HTTPServer) Addr() string

func (*HTTPServer) Close

func (s *HTTPServer) Close()

func (*HTTPServer) GoServe

func (s *HTTPServer) GoServe()

type RPCClient

type RPCClient struct {
	ClientID string
	Protocol types.ProtocolName //bolt1, bolt2
	Codec    stream.Client
	Waits    sync.Map

	ExpectedStatus int16
	// contains filtered or unexported fields
}

func NewRPCClient

func NewRPCClient(t *testing.T, id string, proto types.ProtocolName) *RPCClient

func (*RPCClient) Close

func (c *RPCClient) Close()

func (*RPCClient) Connect

func (c *RPCClient) Connect(addr string) error

func (*RPCClient) ConnectTLS

func (c *RPCClient) ConnectTLS(addr string, cfg *v2.TLSConfig) error

func (*RPCClient) OnDecodeError

func (c *RPCClient) OnDecodeError(context context.Context, err error, headers types.HeaderMap)

func (*RPCClient) OnReceive

func (c *RPCClient) OnReceive(ctx context.Context, headers types.HeaderMap, data types.IoBuffer, trailers types.HeaderMap)

func (*RPCClient) SendRequest

func (c *RPCClient) SendRequest()

func (*RPCClient) SendRequestWithData

func (c *RPCClient) SendRequestWithData(in string)

func (*RPCClient) Stats

func (c *RPCClient) Stats() bool

type RPCServer

type RPCServer struct {
	UpstreamServer
	Client *RPCClient
	// Statistic
	Name  string
	Count uint32
}

func (*RPCServer) ServeBoltV1

func (s *RPCServer) ServeBoltV1(t *testing.T, conn net.Conn)

func (*RPCServer) ServeDubbo added in v0.11.0

func (s *RPCServer) ServeDubbo(t *testing.T, conn net.Conn)

func (*RPCServer) ServeDubboThrift added in v0.21.0

func (s *RPCServer) ServeDubboThrift(t *testing.T, conn net.Conn)

func (*RPCServer) ServeTars added in v0.11.0

func (s *RPCServer) ServeTars(t *testing.T, conn net.Conn)

type ServeConn

type ServeConn func(t *testing.T, conn net.Conn)

type UpstreamServer

type UpstreamServer interface {
	GoServe()
	Close()
	Addr() string
}

func NewHTTPServer

func NewHTTPServer(t *testing.T, h http.Handler) UpstreamServer

func NewRPCServer

func NewRPCServer(t *testing.T, addr string, proto types.ProtocolName) UpstreamServer

func NewUpstreamHTTP2

func NewUpstreamHTTP2(t *testing.T, addr string, h http.Handler) UpstreamServer

func NewUpstreamServer

func NewUpstreamServer(t *testing.T, addr string, serve ServeConn) UpstreamServer

type WeightCluster

type WeightCluster struct {
	Name   string
	Hosts  []*WeightHost
	Weight uint32
}

type WeightHost

type WeightHost struct {
	Addr   string
	Weight uint32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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