Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶ added in v0.4.2
Context wraps a context inside and carries some attributes for using.
func (*Context) LocalAddress ¶ added in v0.5.2
LocalAddress returns the address of server.
func (*Context) RemoteAddress ¶ added in v0.5.2
RemoteAddress returns the address of client.
type DialFunc ¶ added in v0.5.2
DialFunc dials with context and returns the client. Returns an error if failed.
type Handler ¶ added in v0.5.2
Handler is for handling the data from client and returns the new data or an error if failed.
type Logger ¶ added in v0.5.2
type Logger interface {
Debug(msg string, kvs ...any)
Info(msg string, kvs ...any)
Error(msg string, kvs ...any)
}
Logger is for logging some messages in different levels. You can just use log/slog package which is one implement of it.
type Option ¶ added in v0.4.2
type Option func(c *config)
Option configures the config for client or server.
func WithDialTimeout ¶ added in v0.5.2
WithDialTimeout sets the dial timeout to config.
func WithLogger ¶ added in v0.5.2
WithLogger sets the logger to config.
type Pool ¶ added in v0.5.2
type Pool struct {
// contains filtered or unexported fields
}
Pool is a pool for reusing clients. You should always use a pool instead of using a client in production.
func NewPool ¶ added in v0.5.2
NewPool returns a pool with limit and dial function. Dial function should return a new client as your way and an error if failed.