2018-04-05 15:15:29 +00:00
|
|
|
package socket
|
|
|
|
|
|
|
|
import (
|
2018-04-13 07:11:43 +00:00
|
|
|
"sync/atomic"
|
|
|
|
|
2018-04-05 15:15:29 +00:00
|
|
|
"git.loafle.net/commons/server-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ServerHandler interface {
|
|
|
|
server.ServerHandler
|
|
|
|
ReadWriteHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
type ServerHandlers struct {
|
|
|
|
server.ServerHandlers
|
|
|
|
ReadWriteHandlers
|
2018-04-13 07:11:43 +00:00
|
|
|
|
|
|
|
validated atomic.Value
|
2018-04-05 15:15:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *ServerHandlers) Validate() error {
|
2018-04-13 07:11:43 +00:00
|
|
|
if nil != sh.validated.Load() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
sh.validated.Store(true)
|
|
|
|
|
2018-04-05 15:15:29 +00:00
|
|
|
if err := sh.ServerHandlers.Validate(); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := sh.ReadWriteHandlers.Validate(); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|