cham

package
v0.0.0-...-be98215 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PTYPE_GO        uint8 = iota //service -> service
	PTYPE_MULTICAST              //multicast -> service
	PTYPE_CLIENT                 //client -> gate
	PTYPE_RESPONSE               //gate -> client
)
View Source
const (
	TIME_NEAR_SHIFT  = 8
	TIME_NEAR        = 1 << TIME_NEAR_SHIFT
	TIME_LEVEL_SHIFT = 6
	TIME_LEVEL       = 1 << TIME_LEVEL_SHIFT
	TIME_NEAR_MASK   = TIME_NEAR - 1
	TIME_LEVEL_MASK  = TIME_LEVEL - 1
)
View Source
const (
	CHAM_STOP uint8 = iota
)
View Source
const (
	DEFAULT_QUEUE_SIZE = 64
)
View Source
const (
	DEFAULT_SERVICE_SIZE = 64
)
View Source
const (
	DEFAULT_SERVICE_WORKER int = 1
)

Variables

View Source
var (
	NULLVALUE = NULL{}
	NORET     []interface{}
)
View Source
var START_ADDR uint32 = 1

Functions

func DumpService

func DumpService() string

func Redirect

func Redirect(source Address, msg *Msg)

func Ret

func Ret(args ...interface{}) []interface{}

func Run

func Run()

Types

type Address

type Address uint32

func GenAddr

func GenAddr() Address

func (Address) GetService

func (addr Address) GetService() *Service

type Dispatch

type Dispatch func(session int32, source Address, ptype uint8, args ...interface{}) []interface{}

type Master

type Master struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMaster

func NewMaster() *Master

func (*Master) AllService

func (m *Master) AllService() map[Address]*Service

func (*Master) GetService

func (m *Master) GetService(query interface{}) *Service

func (*Master) Register

func (m *Master) Register(s *Service) bool

func (*Master) UniqueService

func (m *Master) UniqueService(name string) *Service

func (*Master) Unregister

func (m *Master) Unregister(s *Service) bool

type Msg

type Msg struct {
	// contains filtered or unexported fields
}

func NewMsg

func NewMsg(source Address, session int32, ptype uint8, args interface{}) *Msg

type NULL

type NULL struct{}

type Node

type Node struct {
	C chan time.Time
	// contains filtered or unexported fields
}

func (*Node) String

func (n *Node) String() string

type Queue

type Queue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue() *Queue

func (*Queue) Length

func (q *Queue) Length() int

func (*Queue) Pop

func (q *Queue) Pop() (msg *Msg)

func (*Queue) Push

func (q *Queue) Push(msg *Msg)

func (*Queue) String

func (q *Queue) String() string

type Service

type Service struct {
	Name string
	Addr Address
	// contains filtered or unexported fields
}
var Main *Service

func NewService

func NewService(name string, start Start, args ...interface{}) *Service

args[0] is worker number, args[1:] will pass to start

func UniqueService

func UniqueService(name string, start Start, args ...interface{}) *Service

create or return already name

func (*Service) Call

func (s *Service) Call(query interface{}, ptype uint8, args ...interface{}) []interface{}

wait response, query can service name/addr/service

func (*Service) Notify

func (s *Service) Notify(query interface{}, ptype uint8, args ...interface{})

no reply

func (*Service) NotifySelf

func (s *Service) NotifySelf(ptype uint8, args ...interface{})

func (*Service) Push

func (s *Service) Push(msg *Msg)

func (*Service) RegisterProtocol

func (s *Service) RegisterProtocol(ptype uint8, start Start, args ...interface{})

func (*Service) Send

func (s *Service) Send(query interface{}, ptype uint8, args ...interface{}) chan *Msg

no wait response

func (*Service) Start

func (s *Service) Start(i int)

func (*Service) Status

func (s *Service) Status() int

func (*Service) Stop

func (s *Service) Stop() bool

func (*Service) String

func (s *Service) String() string

type Start

type Start func(service *Service, args ...interface{}) Dispatch

type Timer

type Timer struct {
	sync.Mutex
	// contains filtered or unexported fields
}
var DTimer *Timer

func NewWheelTimer

func NewWheelTimer(d time.Duration) *Timer

func (*Timer) NewTicker

func (t *Timer) NewTicker(d time.Duration) *Node

func (*Timer) NewTimer

func (t *Timer) NewTimer(d time.Duration) *Node

func (*Timer) Start

func (t *Timer) Start()

func (*Timer) Stop

func (t *Timer) Stop()

func (*Timer) String

func (t *Timer) String() string

Jump to

Keyboard shortcuts

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