mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-28 18:22:18 +08:00
40 lines
775 B
Go
40 lines
775 B
Go
package server
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"time"
|
|
)
|
|
|
|
// OptionFn configures options of server.
|
|
type OptionFn func(*Server)
|
|
|
|
// // WithOptions sets multiple options.
|
|
// func WithOptions(ops map[string]interface{}) OptionFn {
|
|
// return func(s *Server) {
|
|
// for k, v := range ops {
|
|
// s.options[k] = v
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// WithTLSConfig sets tls.Config.
|
|
func WithTLSConfig(cfg *tls.Config) OptionFn {
|
|
return func(s *Server) {
|
|
s.tlsConfig = cfg
|
|
}
|
|
}
|
|
|
|
// WithReadTimeout sets readTimeout.
|
|
func WithReadTimeout(readTimeout time.Duration) OptionFn {
|
|
return func(s *Server) {
|
|
s.readTimeout = readTimeout
|
|
}
|
|
}
|
|
|
|
// WithWriteTimeout sets writeTimeout.
|
|
func WithWriteTimeout(writeTimeout time.Duration) OptionFn {
|
|
return func(s *Server) {
|
|
s.writeTimeout = writeTimeout
|
|
}
|
|
}
|