Documentation ¶
Overview ¶
Motan-go is the golang implementation of Motan. Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.
Motan-go includes server, client and agent. agent is designed for interpreted languages such as PHP to support service governance.
Index ¶
- Constants
- Variables
- func AddDefaultExt(d motan.ExtensionFactory)
- func Cmdline(w http.ResponseWriter, r *http.Request)
- func GetDefaultExtFactory() motan.ExtensionFactory
- func GetDefaultManageHandlers() map[string]http.Handler
- func Handler(name string) http.Handler
- func Index(w http.ResponseWriter, r *http.Request)
- func MeshTrace(w http.ResponseWriter, r *http.Request)
- func NoPermissionCheck(r *http.Request) bool
- func Profile(w http.ResponseWriter, r *http.Request)
- func StatConnections(w http.ResponseWriter)
- func StatOpenFiles(w http.ResponseWriter)
- func StatProcess(w http.ResponseWriter)
- func StatSystem(w http.ResponseWriter)
- func Symbol(w http.ResponseWriter, r *http.Request)
- func Trace(w http.ResponseWriter, r *http.Request)
- type Agent
- func (a *Agent) ExportService(url *motan.URL) error
- func (a *Agent) GetAgentServer() motan.Server
- func (a *Agent) OnAfterStart(f func(a *Agent))
- func (a *Agent) RegisterManageHandler(path string, handler http.Handler)
- func (a *Agent) RuntimeDir() string
- func (a *Agent) SetAllServicesAvailable()
- func (a *Agent) SetAllServicesUnavailable()
- func (a *Agent) SetSanpshotConf()
- func (a *Agent) StartMotanAgent()
- func (a *Agent) StartMotanAgentFromConfig(config *cfg.Config)
- func (a *Agent) SubscribeService(url *motan.URL) error
- func (a *Agent) UnexportService(url *motan.URL) error
- type AgentListener
- type Client
- func (c *Client) BaseCall(req motan.Request, reply interface{}) error
- func (c *Client) BaseGo(req motan.Request, reply interface{}, done chan *motan.AsyncResult) *motan.AsyncResult
- func (c *Client) BuildRequest(method string, args []interface{}) motan.Request
- func (c *Client) Call(method string, args []interface{}, reply interface{}) error
- func (c *Client) Go(method string, args []interface{}, reply interface{}, ...) *motan.AsyncResult
- type CustomTrace
- type DebugHandler
- type DynamicConfigurer
- type DynamicConfigurerHandler
- type HotReload
- type InfoHandler
- type LogHandler
- type MCContext
- type MSContext
- type MeshClient
- func (c *MeshClient) BaseCall(request core.Request, reply interface{}) core.Response
- func (c *MeshClient) BuildRequest(service string, method string, args []interface{}) core.Request
- func (c *MeshClient) BuildRequestWithGroup(service string, method string, args []interface{}, group string) core.Request
- func (c *MeshClient) Call(service string, method string, args []interface{}, reply interface{}) error
- func (c *MeshClient) Destroy()
- func (c *MeshClient) Initialize()
- func (c *MeshClient) SetAddress(address string)
- func (c *MeshClient) SetApplication(application string)
- func (c *MeshClient) SetRequestTimeout(requestTimeout time.Duration)
- func (c *MeshClient) SetSerialization(serialization string)
- type PermissionCheckFunc
- type SetAgent
- type StatConn
- type StatConnInfo
- type StatIOInfo
- type StatMemInfo
- type StatNetInfo
- type StatProcessEntity
- type StatSystemEntity
- type StatusHandler
- type SwitcherHandler
Constants ¶
const ( DefaultMeshRequestTimeout = 5 * time.Second DefaultMeshAddress = "127.0.0.1:9981" DefaultMeshSerialization = "simple" )
const (
Version = "1.0.0"
)
Variables ¶
var ( // PermissionCheck is default permission check for manage request PermissionCheck = NoPermissionCheck )
Functions ¶
func AddDefaultExt ¶
func AddDefaultExt(d motan.ExtensionFactory)
func Cmdline ¶
func Cmdline(w http.ResponseWriter, r *http.Request)
Cmdline responds with the running program's command line, with arguments separated by NUL bytes. The package initialization registers it as /debug/pprof/cmdline.
func GetDefaultExtFactory ¶
func GetDefaultExtFactory() motan.ExtensionFactory
func Index ¶
func Index(w http.ResponseWriter, r *http.Request)
Index responds with the pprof-formatted profile named by the request. For example, "/debug/pprof/heap" serves the "heap" profile. Index responds to a request for "/debug/pprof/" with an HTML page listing the available profiles.
func NoPermissionCheck ¶
func Profile ¶
func Profile(w http.ResponseWriter, r *http.Request)
Profile responds with the pprof-formatted cpu profile. The package initialization registers it as /debug/pprof/profile.
func StatConnections ¶
func StatConnections(w http.ResponseWriter)
func StatOpenFiles ¶
func StatOpenFiles(w http.ResponseWriter)
func StatProcess ¶
func StatProcess(w http.ResponseWriter)
func StatSystem ¶
func StatSystem(w http.ResponseWriter)
Types ¶
type Agent ¶
type Agent struct { ConfigFile string Context *motan.Context // contains filtered or unexported fields }
func NewAgent ¶
func NewAgent(extfactory motan.ExtensionFactory) *Agent
func (*Agent) OnAfterStart ¶
func (*Agent) RegisterManageHandler ¶
func (*Agent) RuntimeDir ¶
RuntimeDir acquires the agent runtime working directory
func (*Agent) SetAllServicesAvailable ¶
func (a *Agent) SetAllServicesAvailable()
func (*Agent) SetAllServicesUnavailable ¶
func (a *Agent) SetAllServicesUnavailable()
func (*Agent) SetSanpshotConf ¶
func (a *Agent) SetSanpshotConf()
func (*Agent) StartMotanAgent ¶
func (a *Agent) StartMotanAgent()
func (*Agent) StartMotanAgentFromConfig ¶
type AgentListener ¶
type AgentListener struct { CurrentCommandInfo string // contains filtered or unexported fields }
func (*AgentListener) GetIdentity ¶
func (a *AgentListener) GetIdentity() string
func (*AgentListener) NotifyCommand ¶
func (a *AgentListener) NotifyCommand(registryURL *motan.URL, commandType int, commandInfo string)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(url *motan.URL, cluster *cluster.MotanCluster, extFactory motan.ExtensionFactory) *Client
func (*Client) BaseGo ¶
func (c *Client) BaseGo(req motan.Request, reply interface{}, done chan *motan.AsyncResult) *motan.AsyncResult
func (*Client) BuildRequest ¶
func (*Client) Go ¶
func (c *Client) Go(method string, args []interface{}, reply interface{}, done chan *motan.AsyncResult) *motan.AsyncResult
type CustomTrace ¶
type CustomTrace struct {
// contains filtered or unexported fields
}
func (*CustomTrace) Trace ¶
func (c *CustomTrace) Trace(rid uint64, ext *motan.StringMap) *motan.TraceContext
type DebugHandler ¶
type DebugHandler struct {
// contains filtered or unexported fields
}
DebugHandler control pprof dynamically ***the func of pprof is copied from net/http/pprof ***
func (*DebugHandler) ServeHTTP ¶
func (d *DebugHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP implement handler interface
type DynamicConfigurer ¶
type DynamicConfigurer struct {
// contains filtered or unexported fields
}
func NewDynamicConfigurer ¶
func NewDynamicConfigurer(agent *Agent) *DynamicConfigurer
func (*DynamicConfigurer) Unregister ¶
func (c *DynamicConfigurer) Unregister(url *core.URL) error
type DynamicConfigurerHandler ¶
type DynamicConfigurerHandler struct {
// contains filtered or unexported fields
}
func (*DynamicConfigurerHandler) ServeHTTP ¶
func (h *DynamicConfigurerHandler) ServeHTTP(res http.ResponseWriter, req *http.Request)
func (*DynamicConfigurerHandler) SetAgent ¶
func (h *DynamicConfigurerHandler) SetAgent(agent *Agent)
type InfoHandler ¶
type InfoHandler struct {
// contains filtered or unexported fields
}
func (*InfoHandler) ServeHTTP ¶
func (i *InfoHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*InfoHandler) SetAgent ¶
func (i *InfoHandler) SetAgent(agent *Agent)
type LogHandler ¶
type LogHandler struct{}
func (*LogHandler) ServeHTTP ¶
func (l *LogHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MCContext ¶
type MCContext struct {
// contains filtered or unexported fields
}
func GetClientContext ¶
func (*MCContext) Initialize ¶
func (m *MCContext) Initialize()
func (*MCContext) Start ¶
func (m *MCContext) Start(extfactory motan.ExtensionFactory)
type MSContext ¶
type MSContext struct {
// contains filtered or unexported fields
}
MSContext is Motan Server Context
func GetMotanServerContext ¶
GetMotanServerContext start a motan server context by config a motan server context can listen multi ports and provide many services. so a single motan server context is suggested default context will be used if confFile is empty
func (*MSContext) Initialize ¶
func (m *MSContext) Initialize()
func (*MSContext) RegisterService ¶
RegisterService register service with serviceId for config ref. the type.string will used as serviceId if sid is not set. e.g. 'packageName.structName'
func (*MSContext) ServicesAvailable ¶
func (m *MSContext) ServicesAvailable()
ServicesAvailable will enable all service registed in registries
func (*MSContext) ServicesUnavailable ¶
func (m *MSContext) ServicesUnavailable()
ServicesUnavailable will enable all service registed in registries
func (*MSContext) Start ¶
func (m *MSContext) Start(extfactory motan.ExtensionFactory)
type MeshClient ¶
type MeshClient struct {
// contains filtered or unexported fields
}
func NewMeshClient ¶
func NewMeshClient() *MeshClient
func (*MeshClient) BaseCall ¶
func (c *MeshClient) BaseCall(request core.Request, reply interface{}) core.Response
func (*MeshClient) BuildRequest ¶
func (c *MeshClient) BuildRequest(service string, method string, args []interface{}) core.Request
func (*MeshClient) BuildRequestWithGroup ¶
func (*MeshClient) Call ¶
func (c *MeshClient) Call(service string, method string, args []interface{}, reply interface{}) error
func (*MeshClient) Destroy ¶
func (c *MeshClient) Destroy()
func (*MeshClient) Initialize ¶
func (c *MeshClient) Initialize()
func (*MeshClient) SetAddress ¶
func (c *MeshClient) SetAddress(address string)
func (*MeshClient) SetApplication ¶
func (c *MeshClient) SetApplication(application string)
func (*MeshClient) SetRequestTimeout ¶
func (c *MeshClient) SetRequestTimeout(requestTimeout time.Duration)
func (*MeshClient) SetSerialization ¶
func (c *MeshClient) SetSerialization(serialization string)
type PermissionCheckFunc ¶
type SetAgent ¶
type SetAgent interface {
SetAgent(agent *Agent)
}
SetAgent : if need agent to do sth, the handler can implement this interface, the func SetAgent will called when agent init the handler
type StatConnInfo ¶
type StatIOInfo ¶
type StatMemInfo ¶
type StatNetInfo ¶
type StatProcessEntity ¶
type StatProcessEntity struct { NumThreads int32 `json:"numThreads"` NumFDs int32 `json:"numFds"` CpuPercent float64 `json:"cpuPercent"` MemoryPercent float32 `json:"memoryPercent"` UsedMemory float64 `json:"usedMemory(MB)"` OpenFilesCount int32 `json:"openFilesCount"` CreateTime string `json:"createTime"` IO *StatIOInfo `json:"io"` Connections *StatConn `json:"connections"` }
type StatSystemEntity ¶
type StatSystemEntity struct { CpuCores int32 `json:"cpuCores"` Load1 float64 `json:"load1"` Load5 float64 `json:"load5"` Load15 float64 `json:"load15"` CpuPercent float64 `json:"cpuPercent"` HostName string `json:"hostName"` Platform string `json:"platform"` PlatformVersion string `json:"platformVersion"` KernelVersion string `json:"kernelVersion"` GoVersion string `json:"goVersion"` BootTime string `json:"bootTime"` MemInfo *StatMemInfo `json:"memInfo"` NetInfo []StatNetInfo `json:"netInfo"` }
type StatusHandler ¶
type StatusHandler struct {
// contains filtered or unexported fields
}
StatusHandler can change http status, such as 200, 503 the registed services will not available when status is 503, and will available when status change to 200
func (*StatusHandler) ServeHTTP ¶
func (s *StatusHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*StatusHandler) SetAgent ¶
func (s *StatusHandler) SetAgent(agent *Agent)
type SwitcherHandler ¶
type SwitcherHandler struct{}
func (*SwitcherHandler) ServeHTTP ¶
func (s *SwitcherHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package cluster contains Cluster implement and command process.
|
Package cluster contains Cluster implement and command process. |
Package core is motan-go base package.
|
Package core is motan-go base package. |
Package endpoint is transport implement of different protocol.
|
Package endpoint is transport implement of different protocol. |
Package filter is some default filter implements.
|
Package filter is some default filter implements. |
Package ha is default HaStrategy implements.
|
Package ha is default HaStrategy implements. |
Package lb is default LoadBalance implements.
|
Package lb is default LoadBalance implements. |
********** this file is modified based on "gopkg.in/natefinch/lumberjack.v2" ********** Package lumberjack provides a rolling logger.
|
********** this file is modified based on "gopkg.in/natefinch/lumberjack.v2" ********** Package lumberjack provides a rolling logger. |
Package protocol is motan2 protocol codec implements.
|
Package protocol is motan2 protocol codec implements. |
Package provider is default Provider implements.
|
Package provider is default Provider implements. |
Package registry is default registry implements.
|
Package registry is default registry implements. |
Package serialize is default serialization implements.
|
Package serialize is default serialization implements. |
Package server is default Server implements for different protocol.
|
Package server is default Server implements for different protocol. |
tools
|
|