Documentation ¶
Index ¶
- Variables
- func InitRequestCheck(loginCnf *config.MethodPathConfig, whiteList []*config.MethodPathConfig)
- type Dispatcher
- type Hub
- type HubDispatcher
- type KV
- type LocalPeer
- type MethodPath
- type PeerRouter
- type PeerRouters
- func (s *PeerRouters) Append(pr PeerRouter)
- func (s PeerRouters) FindOne(peerName string) (PeerRouter, error)
- func (s PeerRouters) Len() int
- func (s PeerRouters) Less(i, j int) bool
- func (s *PeerRouters) RemoveByPeer(peerName string)
- func (s *PeerRouters) RemoveByPeerRouter(pr PeerRouter)
- func (s *PeerRouters) Sort()
- func (s PeerRouters) Swap(i, j int)
- type Request
- type RequestCheck
- type Router
- type Session
- type Subscriber
- type Subscription
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCheckFirst = errors.New("need login/register first")
)
View Source
var (
ErrPeerNotFound = errors.New("core: peer not found")
)
View Source
var ReqCheck = &RequestCheck{}
Functions ¶
func InitRequestCheck ¶
func InitRequestCheck(loginCnf *config.MethodPathConfig, whiteList []*config.MethodPathConfig)
Types ¶
type Dispatcher ¶
type Hub ¶
type Hub interface { Start() error Stop() error Subscribe(ssid string, sub Subscriber) (*Subscription, error) UnSubscribe(subscription *Subscription) Publish(kv *KV) }
type HubDispatcher ¶
type HubDispatcher interface { Hub Dispatcher }
type LocalPeer ¶
type LocalPeer interface { Name() string SetRouter(Router) Notify(PeerRouter, ...MethodPath) Request(PeerRouter, proto.Message) (proto.Message, error) }
type MethodPath ¶
type MethodPath interface {
String() string
}
func NewMethodPath ¶
func NewMethodPath(version, resource, action string) MethodPath
type PeerRouter ¶
type PeerRouter interface { PeerName() string SetPeerName(name string) AppName() string Equals(pr PeerRouter) bool String() string }
func NewPeerRouter ¶
func NewPeerRouter(peerName, appName string) PeerRouter
type PeerRouters ¶
type PeerRouters []PeerRouter
func (*PeerRouters) Append ¶
func (s *PeerRouters) Append(pr PeerRouter)
func (PeerRouters) FindOne ¶
func (s PeerRouters) FindOne(peerName string) (PeerRouter, error)
func (PeerRouters) Len ¶
func (s PeerRouters) Len() int
func (PeerRouters) Less ¶
func (s PeerRouters) Less(i, j int) bool
func (*PeerRouters) RemoveByPeer ¶
func (s *PeerRouters) RemoveByPeer(peerName string)
func (*PeerRouters) RemoveByPeerRouter ¶
func (s *PeerRouters) RemoveByPeerRouter(pr PeerRouter)
func (*PeerRouters) Sort ¶
func (s *PeerRouters) Sort()
func (PeerRouters) Swap ¶
func (s PeerRouters) Swap(i, j int)
type RequestCheck ¶
type RequestCheck struct { LoginMP MethodPath WhiteList []MethodPath // contains filtered or unexported fields }
账户体系,不用接口,这里用接口会带来很多对象开销
func (*RequestCheck) CheckFirst ¶
func (rc *RequestCheck) CheckFirst(mp MethodPath) error
func (*RequestCheck) CheckLogin ¶
func (rc *RequestCheck) CheckLogin(mp MethodPath) bool
func (*RequestCheck) NeedCheck ¶
func (rc *RequestCheck) NeedCheck() bool
type Router ¶
type Router interface { //获取路由分流指向 RouteIn(mp MethodPath, id string, request proto.Message) (response proto.Message, err error) //根据peerRouter将request定向到指定Grpc服务并返回结果 RouteOut(pr PeerRouter, request proto.Message) (response proto.Message, err error) //注册单个 //appName 资源服务名称 //peer 节点名称(空字符串为本地) //address 资源服务连接地址(ps:www.example.com:8080) Register(mps []MethodPath, pr PeerRouter, address string) error //注销app下所有 UnRegisterApp(pr PeerRouter) //注销peer下所有 UnRegisterPeer(peerName string) }
type Subscriber ¶
type Subscriber = Session
type Subscription ¶
type Subscription struct { Ssid string Sub Subscriber }
Click to show internal directories.
Click to hide internal directories.