Documentation ¶
Index ¶
- Constants
- Variables
- func New(config *Config, informer logger.Informer) (net.Conn, error)
- func NewTCP(config *Config, informer logger.Informer) (*net.TCPConn, error)
- func NewUDP(config *Config, informer logger.Informer) (*net.UDPConn, error)
- func NewWithConfigurator(config *Config, configurator configurator.Configurator, ...) (net.Conn, error)
- type Config
Constants ¶
View Source
const ( ProtocolFieldName = "client.socket.protocol" HostFieldName = "client.socket.host" PortFieldName = "client.socket.port" KeepAlivePeriodFiledName = "client.socket.keep_alive_period" DSNFieldName = "client.socket.dsn" ProtocolTCP = "tcp" ProtocolUDP = "udp" ProtocolDefault = ProtocolTCP HostDefault = "127.0.0.1" PortDefault = uint16(8081) )
Variables ¶
View Source
var Component = &app.Component{ Constructor: func(container container.Container) error { return container.Provides( NewConfig, NewWithConfigurator, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.Protocol, ProtocolFieldName, ProtocolDefault, fmt.Sprintf( "socket protocol. Available protocols [%s]", strings.Join([]string{ProtocolTCP, ProtocolUDP}, ","), )) flagSet.StringVar(&config.DSN, DSNFieldName, DSNDefault, "connection string if set to \"dsn\", fields \"host\" and \"port\" are ignored") flagSet.StringVar(&config.Host, HostFieldName, HostDefault, "connection address") flagSet.Uint16Var(&config.Port, PortFieldName, PortDefault, "connection port") flagSet.DurationVar( &config.KeepAlivePeriod, KeepAlivePeriodFiledName, 0, "period between keepalive messages for protocol type tcp", ) }) }, }
View Source
var (
DSNDefault = fmt.Sprintf("%s:%d", HostDefault, PortDefault)
)
Functions ¶
func NewWithConfigurator ¶
func NewWithConfigurator( config *Config, configurator configurator.Configurator, informer logger.Informer, ) (net.Conn, error)
Types ¶
Click to show internal directories.
Click to hide internal directories.