server-go/socket/server-handler.go
crusader e34e7030c2 ing
2018-06-29 17:53:39 +09:00

36 lines
532 B
Go

package socket
import (
"sync/atomic"
"git.loafle.net/commons/server-go"
)
type ServerHandler interface {
server.ServerHandler
ReadWriteHandler
}
type ServerHandlers struct {
server.ServerHandlers
ReadWriteHandlers
validated atomic.Value
}
func (sh *ServerHandlers) Validate() error {
if nil != sh.validated.Load() {
return nil
}
sh.validated.Store(true)
if err := sh.ServerHandlers.Validate(); nil != err {
return err
}
if err := sh.ReadWriteHandlers.Validate(); nil != err {
return err
}
return nil
}