Documentation ¶
Index ¶
- Constants
- Variables
- type Arg
- type Kind
- func (knd Kind) Has(v Kind) bool
- func (knd Kind) IsEmpty() bool
- func (knd Kind) IsSingle() bool
- func (knd Kind) MarshalJSON() ([]byte, error)
- func (knd Kind) MarshalYAML() (interface{}, error)
- func (knd Kind) NewServer() Server
- func (knd *Kind) Set(v Kind)
- func (knd Kind) String() string
- func (knd Kind) StringTrySingle() string
- func (knd Kind) ToStringSlice() (vv []string)
- func (knd *Kind) UnSet(v Kind)
- func (knd *Kind) UnmarshalJSON(data []byte) error
- func (knd *Kind) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Server
- type ServerBase
- type ServerINET
- type ServerListener
- type ServerUNIX
- type ServerWrapped
- type Servers
- func (ss *Servers) Close() []error
- func (ss Servers) Defaultize(inetHost string, inetPort int, unixAddr string) (err error)
- func (ss Servers) Dump(ctx *dumpctx.Ctx, w io.Writer)
- func (ss Servers) ForEach(cb iterCb) bool
- func (ss Servers) IntoIter() iterator
- func (ss *Servers) Listen(fnArgs ...Arg) (Servers, []error)
- func (ss *Servers) PushINETIfNotExists(host string, port int, kind Kind)
- func (ss *Servers) PushUnixIfNotExists(addr string, kind Kind)
- func (ss *Servers) ServeGRPC(fnNewServer func(opts ...grpc.ServerOption) *grpc.Server, fnArgs ...Arg) error
- func (ss *Servers) ServeHTTP(fnNewServer func(Server) http.Handler, fnArgs ...Arg) error
- func (ss *Servers) SetPortToFirstINET(port int)
- func (ss Servers) Validate() error
- type WithKind
- type WithNetwork
Constants ¶
View Source
const ( KindEmpty Kind = 0 KindINET = 1 << (iota - 1) KindUNIX KindHTTP KindGRPC )
Variables ¶
View Source
var ( ErrUnmarshalUnknownKind = errors.New("unknown server-kind, no server associated with kind") ErrTLSCertFileNotExists = errors.New("tls cert-file doesn't exists") ErrTLSCertFilePathNotProvided = errors.New("tls cert-file path is not provided") ErrTLSKeyFileNotExists = errors.New("tls key-file doesn't exists") ErrTLSKeyFilePathNotProvided = errors.New("tls key-file path is not provided") ErrUnixSocketParentDirNotExists = errors.New("unix socket parent dir doesn't exists") ErrUnixSocketPathNotProvided = errors.New("tls key-file path is not provided") ErrGotBothInetAndUnix = errors.New("provided server is both unix and inet") )
View Source
var ErrKindINETAndUNIX = errors.New("got both INET and UNIX kind")
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind uint8
func NewKindFromString ¶
func NewKindFromStringSlice ¶ added in v0.1.0
func (Kind) MarshalJSON ¶
func (Kind) MarshalYAML ¶
func (Kind) StringTrySingle ¶ added in v0.1.0
func (Kind) ToStringSlice ¶ added in v0.1.0
func (*Kind) UnmarshalJSON ¶
func (*Kind) UnmarshalYAML ¶
type ServerBase ¶ added in v0.1.0
type ServerBase struct { WithKind `json:",inline" yaml:",inline" bson:",inline"` WithNetwork `json:",inline" yaml:",inline" bson:",inline"` GRPC struct { Reflection bool `yaml:"reflection"` } `yaml:"grpc"` HTTP struct { ReadHeaderTimeout time.Duration `yaml:"readHeaderTimeout"` } `yaml:"http"` Pprof struct { Enable bool `yaml:"enable"` Prefix string `yaml:"prefix"` } `yaml:"pprof"` }
func (*ServerBase) Network ¶ added in v0.2.0
func (s *ServerBase) Network() string
type ServerINET ¶ added in v0.1.0
type ServerINET struct { ServerBase `json:",inline" yaml:",inline" bson:",inline"` Host string `yaml:"host"` Port int `yaml:"port"` TLS struct { Enable bool `yaml:"enable"` CertFile string `yaml:"certFile"` KeyFile string `yaml:"keyFile"` } `yaml:"tls"` }
func (*ServerINET) Addr ¶ added in v0.1.0
func (s *ServerINET) Addr() string
func (*ServerINET) Base ¶ added in v0.4.0
func (s *ServerINET) Base() *ServerBase
type ServerListener ¶ added in v0.1.0
func (*ServerListener) Addr ¶ added in v0.1.0
func (sl *ServerListener) Addr() string
type ServerUNIX ¶ added in v0.1.0
type ServerUNIX struct { ServerBase `json:",inline" yaml:",inline" bson:",inline"` Address string `yaml:"addr"` SocketFileMode os.FileMode `yaml:"socketFileMode"` }
func (*ServerUNIX) Addr ¶ added in v0.1.0
func (s *ServerUNIX) Addr() string
func (*ServerUNIX) Base ¶ added in v0.4.0
func (s *ServerUNIX) Base() *ServerBase
type ServerWrapped ¶ added in v0.1.0
type ServerWrapped struct {
Server `json:",inline" yaml:",inline" bson:",inline"`
}
ServerWrapped is struct wrapped typed server. Server + kind to unmarshal and build typed json/yaml/bson. see https://stackoverflow.com/a/35584188/723095.
func (*ServerWrapped) MarshalJSON ¶ added in v0.1.0
func (sw *ServerWrapped) MarshalJSON() ([]byte, error)
func (*ServerWrapped) MarshalYAML ¶ added in v0.1.0
func (sw *ServerWrapped) MarshalYAML() (interface{}, error)
func (*ServerWrapped) UnmarshalJSON ¶ added in v0.1.0
func (sw *ServerWrapped) UnmarshalJSON(data []byte) error
func (*ServerWrapped) UnmarshalYAML ¶ added in v0.1.0
func (sw *ServerWrapped) UnmarshalYAML(unmarshal func(interface{}) error) error
type Servers ¶ added in v0.1.0
type Servers []*ServerWrapped
func (Servers) Defaultize ¶ added in v0.1.0
func (*Servers) PushINETIfNotExists ¶ added in v0.1.0
func (*Servers) PushUnixIfNotExists ¶ added in v0.1.0
func (*Servers) SetPortToFirstINET ¶ added in v0.1.0
type WithKind ¶ added in v0.1.0
type WithKind struct {
Knd Kind `json:"kind" yaml:"kind" bson:"kind"`
}
type WithNetwork ¶ added in v0.2.0
type WithNetwork struct {
Net string `json:"network" yaml:"network" bson:"network"`
}
Click to show internal directories.
Click to hide internal directories.