JCS-pub/common/pkgs/rpc/hub/server.go

44 lines
766 B
Go

package hubrpc
import (
"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
)
type HubAPI interface {
// CacheSvc
IOSwitchSvc
MicsSvc
UserSvc
PubShardsService
}
type Server struct {
UnimplementedHubServer
*rpc.ServerBase
svrImpl HubAPI
}
func NewServer(cfg rpc.Config, impl HubAPI, tokenVerifier rpc.AccessTokenVerifier) *Server {
svr := &Server{
svrImpl: impl,
}
svr.ServerBase = rpc.NewServerBase(cfg, svr, &Hub_ServiceDesc, tokenAuthAPIs, tokenVerifier, noAuthAPIs)
return svr
}
var _ HubServer = (*Server)(nil)
var tokenAuthAPIs []string
func TokenAuth(api string) bool {
tokenAuthAPIs = append(tokenAuthAPIs, api)
return true
}
var noAuthAPIs []string
func NoAuth(api string) bool {
noAuthAPIs = append(noAuthAPIs, api)
return true
}