Version: v1.0.1-rc1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2019 License: MIT Imports: 6 Imported by: 0




This section is empty.


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{}


func InitRequestCheck

func InitRequestCheck(loginCnf *config.MethodPathConfig, whiteList []*config.MethodPathConfig)


type Dispatcher

type Dispatcher interface {
	Dispatch(sess Session, req Request)

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 {

type KV

type KV struct {
	Key []byte
	Val []byte

type LocalPeer

type LocalPeer interface {
	Name() string
	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 Request

type Request []byte

func Marshal

func Marshal(model proto.Message) (req Request, err error)

func (Request) Unmarshal

func (req Request) Unmarshal(model proto.Message) error

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)
	RouteOut(pr PeerRouter, request proto.Message) (response proto.Message, err error)
	//appName 资源服务名称
	//peer 节点名称(空字符串为本地)
	//address  资源服务连接地址(
	Register(mps []MethodPath, pr PeerRouter, address string) error
	UnRegisterApp(pr PeerRouter)
	UnRegisterPeer(peerName string)

type Session

type Session interface {
	GetID() string
	GetUserId() string
	Send(message proto.Message) error
	LoggedIn() bool
	SetUserId(userId string)

type Subscriber

type Subscriber = Session

type Subscription

type Subscription struct {
	Ssid string
	Sub  Subscriber


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL