Documentation ¶
Overview ¶
Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Constants
- Variables
- func AppDaemon()
- func AppRestart(name, addr string, port int)
- func AppStop(name, addr string, port int)
- func ConvertAssign(dest, src interface{}) error
- func CurrentTimeNum() int
- func Exit(errorMsg ...interface{})
- func ExpandValueEnv(value string) (realValue string)
- func FieldEmpty(v reflect.Value) error
- func FileExists(path string) bool
- func GetSysClock() int64
- func LoadConfig(project string) (e error)
- func Log() *log
- func ParseBool(val interface{}) (value bool, err error)
- func ParseStruct(t reflect.Type, v reflect.Value, def string, sn string) (sInds []reflect.Value, eTyps []reflect.Type, defs []string, ...)
- func Register(rcvr interface{}) error
- func RegisterBreaker(cmd breakerCmd, rangeSec int, timeoutRatio float32, resumeSec int)
- func RegisterConf(name string, adapter Config)
- func RegisterName(name string, rcvr interface{}) error
- func RunDay(hour, minute int, child func(), name string)
- func RunDefaultTimer(tick int64, child func())
- func RunTickStopTimer(tick int64, child TickStopRun)
- func ServeCodec(codec ServerCodec)
- func ServeRequest(codec ServerCodec) error
- func Testing() bool
- func UnRegister(name string)
- type CallBreak
- type CallClient
- type CallCmd
- func (this *CallCmd) Gotree(child interface{}) *CallCmd
- func (this *CallCmd) Header(k string) string
- func (this *CallCmd) RemoteAddr(naddr interface{}) (string, error)
- func (this *CallCmd) ServiceMethod() string
- func (this *CallCmd) SetHeader(k string, v string)
- func (this *CallCmd) SetHttpHeader(head http.Header)
- type CallController
- func (this *CallController) CallInvoke_(conn net.Conn, gs *GotreeService)
- func (this *CallController) CallName_() string
- func (this *CallController) FUCK_YOU_(cmd int, result *int) error
- func (this *CallController) Gotree(child interface{}) *CallController
- func (this *CallController) OnCreate(method string, argv interface{})
- func (this *CallController) OnDestory(method string, reply interface{}, e error)
- func (this *CallController) RemoteAddr() string
- type CallQps
- type CallRoute
- type CmdHeader
- type ComEntity
- type ComLocator
- func (this *ComLocator) Add(obj interface{})
- func (this *ComLocator) Broadcast(fun string, arg interface{}) error
- func (this *ComLocator) Exist(com interface{}) bool
- func (this *ComLocator) Fetch(obj interface{}) error
- func (this *ComLocator) Get(name string) interface{}
- func (this *ComLocator) Gotree() *ComLocator
- func (this *ComLocator) Remove(obj interface{})
- type ComNode
- type ComObject
- type ComPanel
- type ConHash
- type Config
- type Configer
- type Func
- type GotreeBase
- func (this *GotreeBase) AddChild(parnet interface{}, child ...interface{})
- func (this *GotreeBase) AddEvent(event string, handle handlerFunc)
- func (this *GotreeBase) Event(event string, args ...interface{})
- func (this *GotreeBase) GetChild(parnet interface{}) (child interface{}, err error)
- func (this *GotreeBase) Gotree(child interface{}) *GotreeBase
- func (this *GotreeBase) RemoveEvent(event string)
- func (this *GotreeBase) TopChild() (result interface{})
- type GotreeMap
- func (this *GotreeMap) AllKey() []interface{}
- func (this *GotreeMap) DelAll()
- func (this *GotreeMap) Exist(key interface{}) bool
- func (this *GotreeMap) Get(key interface{}, value interface{}) error
- func (this *GotreeMap) Gotree(openLock ...bool) *GotreeMap
- func (this *GotreeMap) Interface(key interface{}) interface{}
- func (this *GotreeMap) Remove(key interface{})
- func (this *GotreeMap) Set(key interface{}, value interface{})
- func (this *GotreeMap) SetOrStore(key interface{}, value interface{}) (v interface{}, set bool)
- type GotreeService
- func (this *GotreeService) Actions() []string
- func (this *GotreeService) Calls() int
- func (this *GotreeService) CancelController(name string)
- func (this *GotreeService) Close()
- func (this *GotreeService) Gotree() *GotreeService
- func (this *GotreeService) Hook(key string, value interface{})
- func (this *GotreeService) RegController(controller interface{})
- func (this *GotreeService) Run(addr string)
- func (this *GotreeService) Runtime() RuntimeStack
- type Hash
- type HealthClient
- func (this *HealthClient) AddAppRemote(ip string, port int)
- func (this *HealthClient) AddDaoByNode(name string, id int, args ...interface{})
- func (this *HealthClient) AddRemoteAddr(RemoteAddr string)
- func (this *HealthClient) Close()
- func (this *HealthClient) Gotree() *HealthClient
- func (this *HealthClient) Start()
- type HealthController
- func (this *HealthController) AppInfo(arg interface{}, ret *string) error
- func (this *HealthController) ComQps(arg interface{}, ret *string) error
- func (this *HealthController) ComQpsBeginTime(arg interface{}, ret *string) error
- func (this *HealthController) ComStatus(arg interface{}, ret *string) error
- func (this *HealthController) DaoInfo(arg interface{}, ret *string) error
- func (this *HealthController) DaoServerStatus(arg interface{}, ret *string) error
- func (this *HealthController) Gotree() *HealthController
- func (this *HealthController) HandShake(coms struct{ ... }, ret *int) error
- func (this *HealthController) Ping(arg interface{}, ret *int) error
- func (this *HealthController) ProcessId(arg interface{}, ret *int) error
- type IniConfig
- type IniConfigContainer
- func (c *IniConfigContainer) Bool(key string) (bool, error)
- func (c *IniConfigContainer) DefaultBool(key string, defaultval bool) bool
- func (c *IniConfigContainer) DefaultFloat(key string, defaultval float64) float64
- func (c *IniConfigContainer) DefaultInt(key string, defaultval int) int
- func (c *IniConfigContainer) DefaultInt64(key string, defaultval int64) int64
- func (c *IniConfigContainer) DefaultString(key string, defaultval string) string
- func (c *IniConfigContainer) Float(key string) (float64, error)
- func (c *IniConfigContainer) GetSection(section string) (map[string]string, error)
- func (c *IniConfigContainer) Int(key string) (int, error)
- func (c *IniConfigContainer) Int64(key string) (int64, error)
- func (c *IniConfigContainer) String(key string) string
- type KeyValue
- type Limiting
- type NetConn
- func (this *NetConn) Close(pool string) (string, bool)
- func (this *NetConn) Do(req *http.Request, v interface{}) (r *http.Response, err error)
- func (this *NetConn) Gotree(host ...string) *NetConn
- func (this *NetConn) Host() string
- func (this *NetConn) NewRequest(method, path string, body interface{}) (*http.Request, error)
- type ObServer
- type PB
- type Panel
- type Request
- type Response
- type RunStack
- func (this *RunStack) Calls() (result int)
- func (this *RunStack) Del(key string)
- func (this *RunStack) Eval(key string, value interface{}) error
- func (this *RunStack) Get(key string) interface{}
- func (this *RunStack) Gotree() *RunStack
- func (this *RunStack) Remove()
- func (this *RunStack) Set(key string, value interface{})
- type RuntimeStack
- type Scanner
- type Server
- func (server *Server) Close()
- func (server *Server) Register(rcvr interface{}) error
- func (server *Server) RegisterGotreeService(gs *GotreeService)
- func (server *Server) RegisterName(name string, rcvr interface{}) error
- func (server *Server) ServeCodec(codec ServerCodec)
- func (server *Server) ServeRequest(codec ServerCodec) error
- func (server *Server) ServiceNameList() []string
- func (server *Server) UnRegister(name string)
- type ServerCodec
- type SleepObject
- type StopTick
- type TickStopRun
- type Trace
- func (this *Trace) BoolValue() (bool, error)
- func (this *Trace) Caller(depth int) string
- func (this *Trace) CharIn(b byte, s string) int
- func (this *Trace) Gotree() *Trace
- func (this *Trace) HasKey() bool
- func (this *Trace) HasValue() bool
- func (this *Trace) IntValue() (int, error)
- func (this *Trace) NewRetryListener(l net.Listener, minSleepMs, maxSleepMs int) net.Listener
- func (this *Trace) NoKey() bool
- func (this *Trace) NoValue() bool
- func (this *Trace) Parse(str, sep string) *Trace
- func (this *Trace) ParseTraceWith(str, sep string, sepIndexFn func(string, string) int) *Trace
- func (this *Trace) ReadInput(prompt, def string) string
- func (this *Trace) RetryListen(netname, addr string, minSleepMs, maxSleepMs int) (net.Listener, error)
- func (this *Trace) Rparse(str, sep string) *Trace
- func (this *Trace) SortedNumberIn(n int, nums ...int)
- func (this *Trace) String() string
- func (this *Trace) Trim() *Trace
- func (this *Trace) ValueOrKey() string
Constants ¶
const ( // Defaults used by HandleHTTP DefaultRPCPath = "/_goRPC_" DefaultDebugPath = "/debug/rpc" )
const (
DefaultHostURL = "gotree:3000"
)
const (
StatusUnprocessableEntity = 422
)
Variables ¶
var App appInter
var DefaultServer = NewServer()
DefaultServer is the default instance of *Server.
var ErrConnect = errors.New("dial is fail")
var ErrNetwork = errors.New("connection is shut down")
var ErrShutdown = errors.New("connection is shut down")
var Unexpected = errors.New("unexpected EOF")
Functions ¶
func AppRestart ¶
func ConvertAssign ¶
func ConvertAssign(dest, src interface{}) error
func CurrentTimeNum ¶
func CurrentTimeNum() int
func ExpandValueEnv ¶
func FieldEmpty ¶
func LoadConfig ¶
func ParseStruct ¶
func Register ¶
func Register(rcvr interface{}) error
Register publishes the receiver's methods in the DefaultServer.
func RegisterBreaker ¶
RegisterBreaker 注册熔断
func RegisterConf ¶
func RegisterName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
func RunDefaultTimer ¶
func RunDefaultTimer(tick int64, child func())
func RunTickStopTimer ¶
func RunTickStopTimer(tick int64, child TickStopRun)
func ServeCodec ¶
func ServeCodec(codec ServerCodec)
ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses.
func ServeRequest ¶
func ServeRequest(codec ServerCodec) error
ServeRequest is like ServeCodec but synchronously serves a single request. It does not close the codec upon completion.
func UnRegister ¶
func UnRegister(name string)
Types ¶
type CallClient ¶
type CallClient struct { ComEntity // contains filtered or unexported fields }
func (*CallClient) Close ¶
func (this *CallClient) Close()
func (*CallClient) Do ¶
func (this *CallClient) Do(inArg interface{}, reply interface{}) (err error)
func (*CallClient) Gotree ¶
func (this *CallClient) Gotree(concurrency int, timeout int) *CallClient
并发数量 和rpc失败重试次数
func (*CallClient) Start ¶
func (this *CallClient) Start()
type CallCmd ¶
type CallCmd struct { GotreeBase Gseq string `opt:"null"` Head string `opt:"null"` }
func (*CallCmd) RemoteAddr ¶
client调用RemoteAddr 传入NodeMaster, 获取远程地址
func (*CallCmd) ServiceMethod ¶
func (*CallCmd) SetHttpHeader ¶
type CallController ¶
type CallController struct { GotreeBase // contains filtered or unexported fields }
func (*CallController) CallInvoke_ ¶
func (this *CallController) CallInvoke_(conn net.Conn, gs *GotreeService)
func (*CallController) CallName_ ¶
func (this *CallController) CallName_() string
用于rpcserver 注册,不可重写
func (*CallController) FUCK_YOU_ ¶
func (this *CallController) FUCK_YOU_(cmd int, result *int) error
func (*CallController) Gotree ¶
func (this *CallController) Gotree(child interface{}) *CallController
Gotree 构造
func (*CallController) OnCreate ¶
func (this *CallController) OnCreate(method string, argv interface{})
func (*CallController) OnDestory ¶
func (this *CallController) OnDestory(method string, reply interface{}, e error)
func (*CallController) RemoteAddr ¶
func (this *CallController) RemoteAddr() string
type CallQps ¶
type CallQps struct { ComEntity // contains filtered or unexported fields }
func (*CallQps) ComQpsBeginTime ¶
func (this *CallQps) ComQpsBeginTime(args ...interface{})
type CallRoute ¶
type CallRoute struct { ComEntity // contains filtered or unexported fields }
func (*CallRoute) GetAddrList ¶
func (*CallRoute) LocalAddCom ¶
type ComEntity ¶
type ComEntity struct { GotreeBase // contains filtered or unexported fields }
func (*ComEntity) GetComObject ¶
GetComObject
func (*ComEntity) UpdateComObject ¶
UpdateComObject
type ComLocator ¶
type ComLocator struct { ComEntity // contains filtered or unexported fields }
func (*ComLocator) Add ¶
func (this *ComLocator) Add(obj interface{})
func (*ComLocator) Broadcast ¶
func (this *ComLocator) Broadcast(fun string, arg interface{}) error
func (*ComLocator) Exist ¶
func (this *ComLocator) Exist(com interface{}) bool
func (*ComLocator) Fetch ¶
func (this *ComLocator) Fetch(obj interface{}) error
func (*ComLocator) Get ¶
func (this *ComLocator) Get(name string) interface{}
func (*ComLocator) Gotree ¶
func (this *ComLocator) Gotree() *ComLocator
func (*ComLocator) Remove ¶
func (this *ComLocator) Remove(obj interface{})
type ComNode ¶
type ComNode interface { RandomAddr() string //随机地址 BalanceAddr() string //负载均衡地址 HostHashRpcAddr(value interface{}) string //热一致性哈希地址 HashRpcAddr(value interface{}) string //一致性哈希地址 SlaveAddr() string //返回随机从节点 主节点:节点id=1,当只有主节点返回主节点 MasterAddr() string //返回主节点 AllCom() (list []*Panel) //获取全部节点,自定义分发 }
type Configer ¶
type Configer interface { DefaultString(key string, defaultVal string) string DefaultInt(key string, defaultVal int) int DefaultInt64(key string, defaultVal int64) int64 DefaultBool(key string, defaultVal bool) bool DefaultFloat(key string, defaultVal float64) float64 GetSection(section string) (map[string]string, error) String(key string) string }
type GotreeBase ¶
type GotreeBase struct {
// contains filtered or unexported fields
}
func (*GotreeBase) AddChild ¶
func (this *GotreeBase) AddChild(parnet interface{}, child ...interface{})
func (*GotreeBase) AddEvent ¶
func (this *GotreeBase) AddEvent(event string, handle handlerFunc)
func (*GotreeBase) Event ¶
func (this *GotreeBase) Event(event string, args ...interface{})
func (*GotreeBase) GetChild ¶
func (this *GotreeBase) GetChild(parnet interface{}) (child interface{}, err error)
func (*GotreeBase) Gotree ¶
func (this *GotreeBase) Gotree(child interface{}) *GotreeBase
func (*GotreeBase) RemoveEvent ¶
func (this *GotreeBase) RemoveEvent(event string)
func (*GotreeBase) TopChild ¶
func (this *GotreeBase) TopChild() (result interface{})
type GotreeMap ¶
type GotreeMap struct {
// contains filtered or unexported fields
}
func (*GotreeMap) SetOrStore ¶
type GotreeService ¶
type GotreeService struct { GotreeBase // contains filtered or unexported fields }
func (*GotreeService) Calls ¶
func (this *GotreeService) Calls() int
func (*GotreeService) CancelController ¶
func (this *GotreeService) CancelController(name string)
CancelController
func (*GotreeService) Close ¶
func (this *GotreeService) Close()
func (*GotreeService) Gotree ¶
func (this *GotreeService) Gotree() *GotreeService
func (*GotreeService) Hook ¶
func (this *GotreeService) Hook(key string, value interface{})
func (*GotreeService) RegController ¶
func (this *GotreeService) RegController(controller interface{})
RegController
func (*GotreeService) Run ¶
func (this *GotreeService) Run(addr string)
func (*GotreeService) Runtime ¶
func (this *GotreeService) Runtime() RuntimeStack
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
func (*Hash) HashNodeSum ¶
type HealthClient ¶
type HealthClient struct { ComEntity AppRemote []*struct { Addr string Port int StartPort int } StartTime string LastInfoTime int64 // contains filtered or unexported fields }
func (*HealthClient) AddAppRemote ¶
func (this *HealthClient) AddAppRemote(ip string, port int)
func (*HealthClient) AddDaoByNode ¶
func (this *HealthClient) AddDaoByNode(name string, id int, args ...interface{})
func (*HealthClient) AddRemoteAddr ¶
func (this *HealthClient) AddRemoteAddr(RemoteAddr string)
AddRemoteSerAddr 加入远程地址
func (*HealthClient) Close ¶
func (this *HealthClient) Close()
func (*HealthClient) Gotree ¶
func (this *HealthClient) Gotree() *HealthClient
func (*HealthClient) Start ¶
func (this *HealthClient) Start()
type HealthController ¶
type HealthController struct {
CallController
}
func (*HealthController) AppInfo ¶
func (this *HealthController) AppInfo(arg interface{}, ret *string) error
func (*HealthController) ComQps ¶
func (this *HealthController) ComQps(arg interface{}, ret *string) error
ComQps
func (*HealthController) ComQpsBeginTime ¶
func (this *HealthController) ComQpsBeginTime(arg interface{}, ret *string) error
ComQpsBeginTime
func (*HealthController) ComStatus ¶
func (this *HealthController) ComStatus(arg interface{}, ret *string) error
func (*HealthController) DaoInfo ¶
func (this *HealthController) DaoInfo(arg interface{}, ret *string) error
func (*HealthController) DaoServerStatus ¶
func (this *HealthController) DaoServerStatus(arg interface{}, ret *string) error
func (*HealthController) Gotree ¶
func (this *HealthController) Gotree() *HealthController
func (*HealthController) HandShake ¶
func (this *HealthController) HandShake(coms struct { ComList []ComPanel }, ret *int) error
func (*HealthController) Ping ¶
func (this *HealthController) Ping(arg interface{}, ret *int) error
api 服务器发来的握手
func (*HealthController) ProcessId ¶
func (this *HealthController) ProcessId(arg interface{}, ret *int) error
ProcessId 获取进程id
type IniConfigContainer ¶
func (*IniConfigContainer) DefaultBool ¶
func (c *IniConfigContainer) DefaultBool(key string, defaultval bool) bool
func (*IniConfigContainer) DefaultFloat ¶
func (c *IniConfigContainer) DefaultFloat(key string, defaultval float64) float64
func (*IniConfigContainer) DefaultInt ¶
func (c *IniConfigContainer) DefaultInt(key string, defaultval int) int
func (*IniConfigContainer) DefaultInt64 ¶
func (c *IniConfigContainer) DefaultInt64(key string, defaultval int64) int64
func (*IniConfigContainer) DefaultString ¶
func (c *IniConfigContainer) DefaultString(key string, defaultval string) string
func (*IniConfigContainer) GetSection ¶
func (c *IniConfigContainer) GetSection(section string) (map[string]string, error)
func (*IniConfigContainer) String ¶
func (c *IniConfigContainer) String(key string) string
type NetConn ¶
type NetConn struct { GotreeBase UserAgent string // contains filtered or unexported fields }
type ObServer ¶
type ObServer struct {
// contains filtered or unexported fields
}
func (*ObServer) RemoveEvent ¶
func (this *ObServer) RemoveEvent(o interface{})
func (*ObServer) SubscribeLen ¶
type Request ¶
type Request struct { ServiceMethod string // format: "Service.Method" Seq uint64 // sequence number chosen by client // contains filtered or unexported fields }
Request is a header written before every RPC call. It is used internally but documented here as an aid to debugging, such as when analyzing network traffic.
type Response ¶
type Response struct { ServiceMethod string // echoes that of the Request Seq uint64 // echoes that of the request Error string // error, if any. // contains filtered or unexported fields }
Response is a header written before every RPC return. It is used internally but documented here as an aid to debugging, such as when analyzing network traffic.
type RuntimeStack ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an RPC Server.
func (*Server) Register ¶
Register publishes in the server the set of methods of the receiver value that satisfy the following conditions:
- exported method of exported type
- two arguments, both of exported type
- the second argument is a pointer
- one return value, of type error
It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.
func (*Server) RegisterGotreeService ¶
func (server *Server) RegisterGotreeService(gs *GotreeService)
func (*Server) RegisterName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
func (*Server) ServeCodec ¶
func (server *Server) ServeCodec(codec ServerCodec)
ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses.
func (*Server) ServeRequest ¶
func (server *Server) ServeRequest(codec ServerCodec) error
ServeRequest is like ServeCodec but synchronously serves a single request. It does not close the codec upon completion.
func (*Server) ServiceNameList ¶
func (*Server) UnRegister ¶
type ServerCodec ¶
type ServerCodec interface { ReadRequestHeader(*Request) error ReadRequestBody(interface{}) error // WriteResponse must be safe for concurrent use by multiple goroutines. WriteResponse(*Response, interface{}) error ConnInterface() net.Conn Close() error }
A ServerCodec implements reading of RPC requests and writing of RPC responses for the server side of an RPC session. The server calls ReadRequestHeader and ReadRequestBody in pairs to read requests from the connection, and it calls WriteResponse to write a response back. The server calls Close when finished with the connection. ReadRequestBody may be called with a nil argument to force the body of the request to be read and discarded.
func NewServerCodec ¶
func NewServerCodec(conn net.Conn) ServerCodec
type SleepObject ¶
type SleepObject struct {
// contains filtered or unexported fields
}
func (*SleepObject) Gotree ¶
func (this *SleepObject) Gotree() *SleepObject
func (*SleepObject) Reset ¶
func (this *SleepObject) Reset()
func (*SleepObject) Sleep ¶
func (this *SleepObject) Sleep() int64
type TickStopRun ¶
type TickStopRun func(stop *bool)
type Trace ¶
type Trace struct { ComEntity Key string Value string Error error Buf []byte // contains filtered or unexported fields }
func (*Trace) NewRetryListener ¶
func (*Trace) ParseTraceWith ¶
ParseTraceWith
func (*Trace) RetryListen ¶
func (*Trace) SortedNumberIn ¶
Source Files ¶
- base.go
- call_break.go
- call_client.go
- call_cmd.go
- call_conn.go
- call_controller.go
- call_health.go
- call_qps.go
- call_route.go
- call_server.go
- com_entity.go
- com_locator.go
- com_object.go
- command.go
- config.go
- framework.go
- hash.go
- limiting.go
- log.go
- map.go
- net.go
- observer.go
- panel.go
- run_stack.go
- sleep.go
- timer.go