Documentation
¶
Index ¶
- Constants
- Variables
- func Address(s Socket, url string) (string, error)
- func DefaultTLSConfig() *tls.Config
- func LoadTLSConfig(certFile, keyFile string) (*tls.Config, error)
- func SkipVerifyTLSConfig() *tls.Config
- func TLSConfig(certPEM []byte, keyPEM []byte) *tls.Config
- func URL(s Socket, addr string) string
- type Batch
- type Conn
- type Context
- type Dialer
- type HTTP
- type HTTPConn
- type HTTPListener
- func (l *HTTPListener) Accept() (Conn, error)
- func (l *HTTPListener) Addr() net.Addr
- func (l *HTTPListener) Close() error
- func (l *HTTPListener) Serve(handler netpoll.Handler) error
- func (l *HTTPListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
- func (l *HTTPListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
- func (l *HTTPListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
- type INPROC
- type INPROCListener
- func (l *INPROCListener) Accept() (Conn, error)
- func (l *INPROCListener) Addr() net.Addr
- func (l *INPROCListener) Close() error
- func (l *INPROCListener) Serve(handler netpoll.Handler) error
- func (l *INPROCListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
- func (l *INPROCListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
- func (l *INPROCListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
- type INPROConn
- type Listener
- type Messages
- type Socket
- type TCP
- type TCPConn
- type TCPListener
- func (l *TCPListener) Accept() (Conn, error)
- func (l *TCPListener) Addr() net.Addr
- func (l *TCPListener) Close() error
- func (l *TCPListener) Serve(handler netpoll.Handler) error
- func (l *TCPListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
- func (l *TCPListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
- func (l *TCPListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
- type UNIX
- type UNIXConn
- type UNIXListener
- func (l *UNIXListener) Accept() (Conn, error)
- func (l *UNIXListener) Addr() net.Addr
- func (l *UNIXListener) Close() error
- func (l *UNIXListener) Serve(handler netpoll.Handler) error
- func (l *UNIXListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
- func (l *UNIXListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
- func (l *UNIXListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
- type WS
- type WSConn
- type WSListener
- func (l *WSListener) Accept() (Conn, error)
- func (l *WSListener) Addr() net.Addr
- func (l *WSListener) Close() error
- func (l *WSListener) Serve(handler netpoll.Handler) error
- func (l *WSListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
- func (l *WSListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
- func (l *WSListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
Constants ¶
const ( // HTTPConnected defines the http connected. HTTPConnected = "200 Connected to Server" // HTTPPath defines the http path. HTTPPath = "/" )
const (
//WSPath defines the ws path.
WSPath = "/"
)
Variables ¶
var DefaultCertPEM = []byte(`-----BEGIN CERTIFICATE-----
MIIDfDCCAmQCCQCAHkBfX03BnTANBgkqhkiG9w0BAQsFADB/MQswCQYDVQQGEwJD
TjELMAkGA1UECAwCQkoxEDAOBgNVBAcMB0JlaWppbmcxDjAMBgNVBAoMBUhTTEFN
MQwwCgYDVQQLDANSJkQxEjAQBgNVBAMMCWhzbGFtLmNvbTEfMB0GCSqGSIb3DQEJ
ARYQNzkxODc0MTU4QHFxLmNvbTAgFw0yMDA5MjMwMzE3NTdaGA8yMTIwMDgzMDAz
MTc1N1owfzELMAkGA1UEBhMCQ04xCzAJBgNVBAgMAkJKMRAwDgYDVQQHDAdCZWlq
aW5nMQ4wDAYDVQQKDAVIU0xBTTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAloc2xh
bS5jb20xHzAdBgkqhkiG9w0BCQEWEDc5MTg3NDE1OEBxcS5jb20wggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa3lfVcQZg3Ra2DCeTPM9I8cv35Y+R4niX
J7c2U9TvGE3l8zfsLBXtdN4bSlmaimOnOmfx0aVJ8XwLqcIMspJmzG9UlGdlOfir
MTYCybvwhEf9bZc9lmLv27C4++4IljNF9sSv/Lnbdl5VNr+lY1xKRR3HPpwwuJj3
jh3TznzAnb0QnIRTyGGVThyE6uUQAgx8/taGenJDkzb7pry4kRvz+GgjAvhi/KOg
xho7G6PLfzXeS+iPyaMg5npd3B90XIzaaXr4/yffC5BUbynHhZLmWKJXSp7brjiZ
zpFV8np7wKYrtqXW4My2MtMASnvfXrCfTwQ3FU0biBsk7dQHCcuzAgMBAAEwDQYJ
KoZIhvcNAQELBQADggEBAA4rrtWczvjVpttxJ7pbXQlmvVrakPwqqKEQ09hxcoqY
EKkCucjJwFFQi1fNQBKpb+3BwlHIcfqdwpURiTwQjPmRgVhqdFqHE5pNF9EXdNm7
zaylUiu+ySKKHHnCVagM7UszovCoRYY3hq75UsGwR+9WWxOoWRz43NdOTBBDE9y7
JkRowySk9JE5isec+G0tDf6Fyj/3zWshWQalEH/Aq1Af0BMtWQL4VYXbealqK6rq
MOwPd7m67gCJlNREX2JnMDBM2A9QcAIzhYrHBx5w6UhUwSL6IFhJzdFXl4klsKUQ
cmw7rbPxsuPIyPlCobdtFoVpFN5vnOnF42nCb8tr0Xs=
-----END CERTIFICATE-----
`)
DefaultCertPEM represents the default certificate data.
var DefaultKeyPEM = []byte(`-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDa3lfVcQZg3Ra2
DCeTPM9I8cv35Y+R4niXJ7c2U9TvGE3l8zfsLBXtdN4bSlmaimOnOmfx0aVJ8XwL
qcIMspJmzG9UlGdlOfirMTYCybvwhEf9bZc9lmLv27C4++4IljNF9sSv/Lnbdl5V
Nr+lY1xKRR3HPpwwuJj3jh3TznzAnb0QnIRTyGGVThyE6uUQAgx8/taGenJDkzb7
pry4kRvz+Gg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oOykdcqke
dKkVs4j/uzdFg49Ftmb4OfvRH73oMSsh3EyYResBvJG09qnoWhpNFpo7atLwlcWm
g6H5Eov0H6SDBaFzLFT5gty8sOSd6I3wbU0p5zkCgYAwQe8+M7Su2v3mA0vbxbGb
W96El5n15YRa6JHOigC+5mBhXilnDE8qomFkfELDOnQ+hdkgqbFd7P1/+K5raV+I
aGh+dZd2MKnLevVoMexu40NQLVyJTOqumG05NNgmfg7VE8QUbXKfz+9pmfYFSZGS
Wx4EqMDhdG9wlTsHGb1I/Q==
-----END PRIVATE KEY-----
`)
DefaultKeyPEM represents the default private key data.
var ErrConn = errors.New("conn is nil")
ErrConn is the error when the conn is nil
var ErrHandler = errors.New("handler is nil")
ErrHandler is the error when the handler is nil
var ErrNetwork = errors.New("network is not supported")
ErrNetwork is the error when the network is not supported
var ErrOpened = errors.New("opened is nil")
ErrOpened is the error when the opened is nil
var ErrServe = errors.New("serve is nil")
ErrServe is the error when the serve is nil
Functions ¶
func DefaultTLSConfig ¶ added in v0.0.2
DefaultTLSConfig returns a default TLS config.
func LoadTLSConfig ¶
LoadTLSConfig returns a TLS config by loading the certificate file and the key file.
func SkipVerifyTLSConfig ¶
SkipVerifyTLSConfig returns a insecure skip verify TLS config.
Types ¶
type Batch ¶
type Batch interface { // SetConcurrency sets a callback function concurrency to enable auto batch writer for improving throughput. SetConcurrency(concurrency func() int) }
Batch interface is used to write batch messages.
type Conn ¶
type Conn interface { net.Conn // Messages returns a new Messages. Messages() Messages // Connection returns the net.Conn. Connection() net.Conn }
Conn is a generic stream-oriented network connection.
type HTTP ¶
HTTP implements the Socket interface.
type HTTPConn ¶
HTTPConn implements the Conn interface.
func (*HTTPConn) Connection ¶
Connection returns the net.Conn.
type HTTPListener ¶
type HTTPListener struct {
// contains filtered or unexported fields
}
HTTPListener implements the Listener interface.
func (*HTTPListener) Accept ¶
func (l *HTTPListener) Accept() (Conn, error)
Accept waits for and returns the next connection to the listener.
func (*HTTPListener) Addr ¶
func (l *HTTPListener) Addr() net.Addr
Addr returns the listener's network address.
func (*HTTPListener) Serve ¶
func (l *HTTPListener) Serve(handler netpoll.Handler) error
Serve serves the netpoll.Handler by the netpoll.
func (*HTTPListener) ServeConn ¶
func (l *HTTPListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
ServeConn serves the opened func and the serve func by the netpoll.
func (*HTTPListener) ServeData ¶
func (l *HTTPListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
ServeData serves the opened func and the serve func by the netpoll.
func (*HTTPListener) ServeMessages ¶
func (l *HTTPListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
ServeMessages serves the opened func and the serve func by the netpoll.
type INPROC ¶
INPROC implements the Socket interface.
type INPROCListener ¶
type INPROCListener struct {
// contains filtered or unexported fields
}
INPROCListener implements the Listener interface.
func (*INPROCListener) Accept ¶
func (l *INPROCListener) Accept() (Conn, error)
Accept waits for and returns the next connection to the listener.
func (*INPROCListener) Addr ¶
func (l *INPROCListener) Addr() net.Addr
Addr returns the listener's network address.
func (*INPROCListener) Serve ¶
func (l *INPROCListener) Serve(handler netpoll.Handler) error
Serve serves the netpoll.Handler by the netpoll.
func (*INPROCListener) ServeConn ¶
func (l *INPROCListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
ServeConn serves the opened func and the serve func by the netpoll.
func (*INPROCListener) ServeData ¶
func (l *INPROCListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
ServeData serves the opened func and the serve func by the netpoll.
func (*INPROCListener) ServeMessages ¶
func (l *INPROCListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
ServeMessages serves the opened func and the serve func by the netpoll.
type INPROConn ¶
INPROConn implements the Conn interface.
func (*INPROConn) Connection ¶
Connection returns the net.Conn.
type Listener ¶
type Listener interface { // Accept waits for and returns the next connection to the listener. Accept() (Conn, error) // Close closes the listener. // Any blocked Accept operations will be unblocked and return errors. Close() error // Addr returns the listener's network address. Addr() net.Addr // Serve serves the netpoll.Handler by the netpoll. Serve(handler netpoll.Handler) error // ServeData serves the opened func and the serve func by the netpoll. ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error // ServeConn serves the opened func and the serve func by the netpoll. ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error // ServeMessages serves the opened func and the serve func by the netpoll. ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error }
Listener is a generic network listener for stream-oriented protocols.
type Messages ¶
type Messages interface { // ReadMessage reads single message frame from the Messages. ReadMessage(buf []byte) ([]byte, error) // WriteMessage writes data as a message frame to the Messages. WriteMessage([]byte) error // Close closes the Messages. Close() error }
Messages interface is used to read and write message.
func NewMessages ¶
func NewMessages(rwc io.ReadWriteCloser, shared bool, writeBufferSize int, readBufferSize int) Messages
NewMessages returns a new messages.
type Socket ¶
type Socket interface { // Scheme returns the socket's scheme. Scheme() string Dialer // Listen announces on the local address. Listen(address string) (Listener, error) }
Socket contains the Dialer and the Listener.
func NewHTTPSocket ¶
NewHTTPSocket returns a new HTTP socket.
func NewINPROCSocket ¶
NewINPROCSocket returns a new TCP socket.
func NewTCPSocket ¶
NewTCPSocket returns a new TCP socket.
func NewUNIXSocket ¶
NewUNIXSocket returns a new UNIX socket.
type TCP ¶
TCP implements the Socket interface.
type TCPConn ¶
TCPConn implements the Conn interface.
func (*TCPConn) Connection ¶
Connection returns the net.Conn.
type TCPListener ¶
type TCPListener struct {
// contains filtered or unexported fields
}
TCPListener implements the Listener interface.
func (*TCPListener) Accept ¶
func (l *TCPListener) Accept() (Conn, error)
Accept waits for and returns the next connection to the listener.
func (*TCPListener) Addr ¶
func (l *TCPListener) Addr() net.Addr
Addr returns the listener's network address.
func (*TCPListener) Serve ¶
func (l *TCPListener) Serve(handler netpoll.Handler) error
Serve serves the netpoll.Handler by the netpoll.
func (*TCPListener) ServeConn ¶
func (l *TCPListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
ServeConn serves the opened func and the serve func by the netpoll.
func (*TCPListener) ServeData ¶
func (l *TCPListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
ServeData serves the opened func and the serve func by the netpoll.
func (*TCPListener) ServeMessages ¶
func (l *TCPListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
ServeMessages serves the opened func and the serve func by the netpoll.
type UNIX ¶
UNIX implements the Socket interface.
type UNIXConn ¶
UNIXConn implements the Conn interface.
func (*UNIXConn) Connection ¶
Connection returns the net.Conn.
type UNIXListener ¶
type UNIXListener struct {
// contains filtered or unexported fields
}
UNIXListener implements the Listener interface.
func (*UNIXListener) Accept ¶
func (l *UNIXListener) Accept() (Conn, error)
Accept waits for and returns the next connection to the listener.
func (*UNIXListener) Addr ¶
func (l *UNIXListener) Addr() net.Addr
Addr returns the listener's network address.
func (*UNIXListener) Serve ¶
func (l *UNIXListener) Serve(handler netpoll.Handler) error
Serve serves the netpoll.Handler by the netpoll.
func (*UNIXListener) ServeConn ¶
func (l *UNIXListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
ServeConn serves the opened func and the serve func by the netpoll.
func (*UNIXListener) ServeData ¶
func (l *UNIXListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
ServeData serves the opened func and the serve func by the netpoll.
func (*UNIXListener) ServeMessages ¶
func (l *UNIXListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
ServeMessages serves the opened func and the serve func by the netpoll.
type WS ¶
WS implements the Socket interface.
type WSListener ¶
type WSListener struct {
// contains filtered or unexported fields
}
WSListener implements the Listener interface.
func (*WSListener) Accept ¶
func (l *WSListener) Accept() (Conn, error)
Accept waits for and returns the next connection to the listener.
func (*WSListener) Addr ¶
func (l *WSListener) Addr() net.Addr
Addr returns the listener's network address.
func (*WSListener) Serve ¶
func (l *WSListener) Serve(handler netpoll.Handler) error
Serve serves the netpoll.Handler by the netpoll.
func (*WSListener) ServeConn ¶
func (l *WSListener) ServeConn(opened func(net.Conn) (Context, error), serve func(Context) error) error
ServeConn serves the opened func and the serve func by the netpoll.
func (*WSListener) ServeData ¶
func (l *WSListener) ServeData(opened func(net.Conn) error, serve func(req []byte) (res []byte)) error
ServeData serves the opened func and the serve func by the netpoll.
func (*WSListener) ServeMessages ¶
func (l *WSListener) ServeMessages(opened func(Messages) (Context, error), serve func(Context) error) error
ServeMessages serves the opened func and the serve func by the netpoll.\