43 lines
811 B
Go
43 lines
811 B
Go
package corrpc
|
|
|
|
import (
|
|
"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
|
|
)
|
|
|
|
type CoordinatorAPI interface {
|
|
HubService
|
|
StorageService
|
|
UserService
|
|
PubShardsService
|
|
}
|
|
|
|
type Server struct {
|
|
UnimplementedCoordinatorServer
|
|
*rpc.ServerBase
|
|
svrImpl CoordinatorAPI
|
|
}
|
|
|
|
func NewServer(cfg rpc.Config, impl CoordinatorAPI, tokenVerifier rpc.AccessTokenVerifier) *Server {
|
|
svr := &Server{
|
|
svrImpl: impl,
|
|
}
|
|
svr.ServerBase = rpc.NewServerBase(cfg, svr, &Coordinator_ServiceDesc, tokenAuthAPIs, tokenVerifier, noAuthAPIs)
|
|
return svr
|
|
}
|
|
|
|
var _ CoordinatorServer = (*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
|
|
}
|