En cours de développement

master
losyme 9 months ago
parent ed5211ad5a
commit c5e35a5886
  1. 64
      server/options.go

@ -0,0 +1,64 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### kong ####### Copyright (c) 2021-2022 losyme ################################################ MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package server
import "time"
type Options struct {
Addr string
IdleTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
}
type Option interface {
apply(*Options)
}
type addrOption string
func (ao addrOption) apply(opts *Options) {
opts.Addr = string(ao)
}
func WithAddr(addr string) Option {
return addrOption(addr)
}
type idleTimeoutOption time.Duration
func (ito idleTimeoutOption) apply(opts *Options) {
opts.IdleTimeout = time.Duration(ito)
}
func WithIdleTimeout(idleTimeout time.Duration) Option {
return idleTimeoutOption(idleTimeout)
}
type readTimeoutOption time.Duration
func (rto readTimeoutOption) apply(opts *Options) {
opts.ReadTimeout = time.Duration(rto)
}
func WithReadTimeout(readTimeout time.Duration) Option {
return readTimeoutOption(readTimeout)
}
type writeTimeoutOption time.Duration
func (wto writeTimeoutOption) apply(opts *Options) {
opts.WriteTimeout = time.Duration(wto)
}
func WithWriteTimeout(writeTimeout time.Duration) Option {
return writeTimeoutOption(writeTimeout)
}
/*
######################################################################################################## @(°_°)@ #######
*/
Loading…
Cancel
Save