Documentation ¶
Overview ¶
Package rpc is the hprose RPC library for Golang.
Index ¶
- Constants
- Variables
- func CheckAddresses(uriList []string, schemes []string) (scheme string)
- func CoarseTimeNow() time.Time
- func DefaultFixArguments(args []reflect.Value, context ServiceContext)
- func FireErrorEvent(event ServiceEvent, e error, context Context) (err error)
- func RegisterClientFactory(scheme string, newClient func(...string) Client)
- type BaseClient
- func (client *BaseClient) AddAfterFilterHandler(handler ...FilterHandler) Client
- func (client *BaseClient) AddBeforeFilterHandler(handler ...FilterHandler) Client
- func (client *BaseClient) AddFilter(filter ...Filter) Client
- func (client *BaseClient) AddInvokeHandler(handler ...InvokeHandler) Client
- func (client *BaseClient) AutoID() (string, error)
- func (client *BaseClient) Close()
- func (client *BaseClient) Failround() int
- func (fm *BaseClient) Filter() Filter
- func (fm *BaseClient) FilterByIndex(index int) Filter
- func (client *BaseClient) GetClientContext(settings *InvokeSettings) (context *ClientContext)
- func (client *BaseClient) Go(name string, args []reflect.Value, settings *InvokeSettings, callback Callback)
- func (client *BaseClient) ID() string
- func (client *BaseClient) InitBaseClient()
- func (client *BaseClient) Invoke(name string, args []reflect.Value, settings *InvokeSettings) (results []reflect.Value, err error)
- func (tm *BaseClient) IsSubscribed(topic string) bool
- func (fm *BaseClient) NumFilter() int
- func (client *BaseClient) RemoveFilter(filter ...Filter) Client
- func (client *BaseClient) RemoveFilterByIndex(index int) Client
- func (client *BaseClient) Retry() int
- func (client *BaseClient) SetEvent(event ClientEvent)
- func (client *BaseClient) SetFilter(filter ...Filter) Client
- func (client *BaseClient) SetRetry(value int)
- func (client *BaseClient) SetTLSClientConfig(config *tls.Config)
- func (client *BaseClient) SetTimeout(value time.Duration)
- func (client *BaseClient) SetURI(uri string)
- func (client *BaseClient) SetURIList(uriList []string)
- func (client *BaseClient) SetUserData(userdata map[string]interface{}) Client
- func (client *BaseClient) Subscribe(name string, id string, settings *InvokeSettings, callback interface{}) (err error)
- func (tm *BaseClient) SubscribedList() []string
- func (client *BaseClient) TLSClientConfig() *tls.Config
- func (client *BaseClient) Timeout() time.Duration
- func (client *BaseClient) URI() string
- func (client *BaseClient) URIList() []string
- func (client *BaseClient) URL() *url.URL
- func (client *BaseClient) Unsubscribe(name string, id ...string)
- func (hm *BaseClient) Use(handler ...InvokeHandler)
- func (client *BaseClient) UseService(remoteService interface{}, namespace ...string)
- type BaseContext
- func (context *BaseContext) Get(key string) interface{}
- func (context *BaseContext) GetBool(key string, defaultValue ...bool) bool
- func (context *BaseContext) GetFloat(key string, defaultValue ...float64) float64
- func (context *BaseContext) GetInt(key string, defaultValue ...int) int
- func (context *BaseContext) GetInt64(key string, defaultValue ...int64) int64
- func (context *BaseContext) GetInterface(key string, defaultValue ...interface{}) interface{}
- func (context *BaseContext) GetString(key string, defaultValue ...string) string
- func (context *BaseContext) GetUInt(key string, defaultValue ...uint) uint
- func (context *BaseContext) GetUInt64(key string, defaultValue ...uint64) uint64
- func (context *BaseContext) InitBaseContext()
- func (context *BaseContext) Set(key string, value interface{})
- func (context *BaseContext) SetBool(key string, value bool)
- func (context *BaseContext) SetFloat(key string, value float64)
- func (context *BaseContext) SetInt(key string, value int)
- func (context *BaseContext) SetInt64(key string, value int64)
- func (context *BaseContext) SetInterface(key string, value interface{})
- func (context *BaseContext) SetString(key string, value string)
- func (context *BaseContext) SetUInt(key string, value uint)
- func (context *BaseContext) SetUInt64(key string, value uint64)
- func (context *BaseContext) UserData() map[string]interface{}
- type BaseHTTPService
- func (service *BaseHTTPService) AddAccessControlAllowOrigin(origins ...string)
- func (service *BaseHTTPService) ClientAccessPolicyXMLContent() []byte
- func (service *BaseHTTPService) ClientAccessPolicyXMLFile() string
- func (service *BaseHTTPService) CrossDomainXMLContent() []byte
- func (service *BaseHTTPService) CrossDomainXMLFile() string
- func (fm *BaseHTTPService) Filter() Filter
- func (fm *BaseHTTPService) FilterByIndex(index int) Filter
- func (service *BaseHTTPService) InitBaseHTTPService()
- func (fm *BaseHTTPService) NumFilter() int
- func (service *BaseHTTPService) RemoveAccessControlAllowOrigin(origins ...string)
- func (service *BaseHTTPService) SetClientAccessPolicyXMLContent(content []byte)
- func (service *BaseHTTPService) SetClientAccessPolicyXMLFile(filename string)
- func (service *BaseHTTPService) SetCrossDomainXMLContent(content []byte)
- func (service *BaseHTTPService) SetCrossDomainXMLFile(filename string)
- func (hm *BaseHTTPService) Use(handler ...InvokeHandler)
- type BaseService
- func (service *BaseService) AddAfterFilterHandler(handler ...FilterHandler) Service
- func (service *BaseService) AddAllMethods(obj interface{}, option ...Options) Service
- func (service *BaseService) AddBeforeFilterHandler(handler ...FilterHandler) Service
- func (service *BaseService) AddFilter(filter ...Filter) Service
- func (service *BaseService) AddFunction(name string, function interface{}, option ...Options) Service
- func (service *BaseService) AddFunctions(names []string, functions []interface{}, option ...Options) Service
- func (service *BaseService) AddInstanceMethods(obj interface{}, option ...Options) Service
- func (service *BaseService) AddInvokeHandler(handler ...InvokeHandler) Service
- func (service *BaseService) AddMethod(name string, obj interface{}, alias string, option ...Options) Service
- func (service *BaseService) AddMethods(names []string, obj interface{}, aliases []string, option ...Options) Service
- func (service *BaseService) AddMissingMethod(method MissingMethod, option ...Options) Service
- func (service *BaseService) AddNetRPCMethods(rcvr interface{}, option ...Options) Service
- func (service *BaseService) Broadcast(topic string, result interface{}, callback func([]string))
- func (service *BaseService) DoFunctionList(context ServiceContext) []byte
- func (service *BaseService) EndError(err error, context Context) []byte
- func (service *BaseService) Exist(topic string, id string) bool
- func (fm *BaseService) Filter() Filter
- func (fm *BaseService) FilterByIndex(index int) Filter
- func (service *BaseService) Handle(request []byte, context Context) []byte
- func (service *BaseService) IDList(topic string) []string
- func (service *BaseService) InitBaseService()
- func (service *BaseService) Multicast(topic string, ids []string, result interface{}, callback func([]string))
- func (fm *BaseService) NumFilter() int
- func (service *BaseService) Publish(topic string, timeout time.Duration, heartbeat time.Duration) Service
- func (service *BaseService) Push(topic string, result interface{}, id ...string)
- func (service *BaseService) Remove(name string) Service
- func (service *BaseService) RemoveFilter(filter ...Filter) Service
- func (service *BaseService) RemoveFilterByIndex(index int) Service
- func (service *BaseService) SetFilter(filter ...Filter) Service
- func (service *BaseService) SetUserData(userdata map[string]interface{}) Service
- func (service *BaseService) Unicast(topic string, id string, result interface{}, callback func(bool))
- func (hm *BaseService) Use(handler ...InvokeHandler)
- type BaseServiceContext
- func (context *BaseServiceContext) ByRef() bool
- func (context *BaseServiceContext) Clients() Clients
- func (context *BaseServiceContext) InitServiceContext(service Service)
- func (context *BaseServiceContext) IsMissingMethod() bool
- func (context *BaseServiceContext) Method() *Method
- func (context *BaseServiceContext) Service() Service
- type Callback
- type Client
- type ClientContext
- type ClientEvent
- type Clients
- type Context
- type Filter
- type FilterHandler
- type HTTPClient
- func (client *HTTPClient) Compression() bool
- func (fm *HTTPClient) Filter() Filter
- func (fm *HTTPClient) FilterByIndex(index int) Filter
- func (tm *HTTPClient) IsSubscribed(topic string) bool
- func (client *HTTPClient) KeepAlive() bool
- func (client *HTTPClient) MaxConcurrentRequests() int
- func (fm *HTTPClient) NumFilter() int
- func (client *HTTPClient) SetCompression(enable bool)
- func (client *HTTPClient) SetKeepAlive(enable bool)
- func (client *HTTPClient) SetMaxConcurrentRequests(value int)
- func (client *HTTPClient) SetTLSClientConfig(config *tls.Config)
- func (client *HTTPClient) SetURIList(uriList []string)
- func (tm *HTTPClient) SubscribedList() []string
- func (client *HTTPClient) TLSClientConfig() *tls.Config
- func (hm *HTTPClient) Use(handler ...InvokeHandler)
- type HTTPContext
- type HTTPService
- func (fm *HTTPService) Filter() Filter
- func (fm *HTTPService) FilterByIndex(index int) Filter
- func (service *HTTPService) InitHTTPService()
- func (fm *HTTPService) NumFilter() int
- func (service *HTTPService) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (hm *HTTPService) Use(handler ...InvokeHandler)
- type InvokeHandler
- type InvokeSettings
- type Limiter
- type Method
- type MissingMethod
- type NextFilterHandler
- type NextInvokeHandler
- type Options
- type PanicError
- type ResultMode
- type Server
- type Service
- type ServiceContext
- type ServiceEvent
- type SocketClient
- func (client *SocketClient) Close()
- func (fm *SocketClient) Filter() Filter
- func (fm *SocketClient) FilterByIndex(index int) Filter
- func (tm *SocketClient) IsSubscribed(topic string) bool
- func (fm *SocketClient) NumFilter() int
- func (client *SocketClient) SetTLSClientConfig(config *tls.Config)
- func (tm *SocketClient) SubscribedList() []string
- func (client *SocketClient) TLSClientConfig() *tls.Config
- func (hm *SocketClient) Use(handler ...InvokeHandler)
- type SocketContext
- type SocketService
- type TCPClient
- func (fm *TCPClient) Filter() Filter
- func (fm *TCPClient) FilterByIndex(index int) Filter
- func (tm *TCPClient) IsSubscribed(topic string) bool
- func (fm *TCPClient) NumFilter() int
- func (client *TCPClient) SetURIList(uriList []string)
- func (tm *TCPClient) SubscribedList() []string
- func (hm *TCPClient) Use(handler ...InvokeHandler)
- type TCPServer
- func (server *TCPServer) Close()
- func (fm *TCPServer) Filter() Filter
- func (fm *TCPServer) FilterByIndex(index int) Filter
- func (server *TCPServer) Handle() (err error)
- func (fm *TCPServer) NumFilter() int
- func (starter *TCPServer) Restart()
- func (starter *TCPServer) Start() (err error)
- func (starter *TCPServer) Stop()
- func (server *TCPServer) URI() string
- func (hm *TCPServer) Use(handler ...InvokeHandler)
- type TCPService
- func (fm *TCPService) Filter() Filter
- func (fm *TCPService) FilterByIndex(index int) Filter
- func (fm *TCPService) NumFilter() int
- func (service *TCPService) Serve(listener net.Listener)
- func (service *TCPService) ServeConn(conn net.Conn)
- func (service *TCPService) ServeTCP(listener *net.TCPListener)
- func (service *TCPService) ServeTCPConn(conn *net.TCPConn)
- func (hm *TCPService) Use(handler ...InvokeHandler)
- type TransportLine
- type UnixClient
- func (fm *UnixClient) Filter() Filter
- func (fm *UnixClient) FilterByIndex(index int) Filter
- func (tm *UnixClient) IsSubscribed(topic string) bool
- func (fm *UnixClient) NumFilter() int
- func (client *UnixClient) SetURIList(uriList []string)
- func (tm *UnixClient) SubscribedList() []string
- func (hm *UnixClient) Use(handler ...InvokeHandler)
- type UnixServer
- func (server *UnixServer) Close()
- func (fm *UnixServer) Filter() Filter
- func (fm *UnixServer) FilterByIndex(index int) Filter
- func (server *UnixServer) Handle() (err error)
- func (fm *UnixServer) NumFilter() int
- func (starter *UnixServer) Restart()
- func (starter *UnixServer) Start() (err error)
- func (starter *UnixServer) Stop()
- func (server *UnixServer) URI() string
- func (hm *UnixServer) Use(handler ...InvokeHandler)
- type UnixService
- func (fm *UnixService) Filter() Filter
- func (fm *UnixService) FilterByIndex(index int) Filter
- func (fm *UnixService) NumFilter() int
- func (service *UnixService) Serve(listener net.Listener)
- func (service *UnixService) ServeConn(conn net.Conn)
- func (service *UnixService) ServeUnix(listener *net.UnixListener)
- func (service *UnixService) ServeUnixConn(conn *net.UnixConn)
- func (hm *UnixService) Use(handler ...InvokeHandler)
- type WorkerPool
Constants ¶
const ( //网络断开时,初始重连间隔 RECONN_MIN = 500 * time.Millisecond //网络断开时,最大重连间隔 RECONN_MAX = 2 * time.Second //保持的tcp连接数量 CONN_NUM = 2 //数据包过期时间 EXPIRE_TIME = 5 * time.Second //发送请求最大等待数量 SendQueueSize = 256 * 1024 )
const ( // Normal is default mode Normal = ResultMode(iota) // Serialized means the result is serialized Serialized // Raw means the result is the raw bytes data Raw // RawWithEndTag means the result is the raw bytes data with the end tag RawWithEndTag )
Variables ¶
var DisableGlobalCookie = false
DisableGlobalCookie is a flag to disable global cookie
var ErrClientIsAlreadyClosed = errors.New("The Client is already closed")
ErrClientIsAlreadyClosed represents a error
var ErrNotSupportMultpleProtocol = errors.New("Not support multiple protocol")
ErrNotSupportMultpleProtocol represents a error
var ErrServerIsAlreadyStarted = errors.New("The server is already started")
ErrServerIsAlreadyStarted represents a error
var ErrServerIsNotStarted = errors.New("The server is not started")
ErrServerIsNotStarted represents a error
var ErrTimeout = errors.New("timeout")
ErrTimeout represents a timeout error
var ErrURIListEmpty = errors.New("uriList must contain at least one uri")
ErrURIListEmpty represents a error
Functions ¶
func CheckAddresses ¶
CheckAddresses returns the uri scheme if the address is valid.
func CoarseTimeNow ¶
func DefaultFixArguments ¶
func DefaultFixArguments(args []reflect.Value, context ServiceContext)
DefaultFixArguments is the default FixArguments function
func FireErrorEvent ¶
func FireErrorEvent(event ServiceEvent, e error, context Context) (err error)
FireErrorEvent fires the OnSendError
func RegisterClientFactory ¶
RegisterClientFactory registers the default client factory
Types ¶
type BaseClient ¶
type BaseClient struct { SendAndReceive func([]byte, *ClientContext) ([]byte, error) UserData map[string]interface{} // contains filtered or unexported fields }
BaseClient is hprose base client
func (*BaseClient) AddAfterFilterHandler ¶
func (client *BaseClient) AddAfterFilterHandler(handler ...FilterHandler) Client
AddAfterFilterHandler add the filter handler after filters
func (*BaseClient) AddBeforeFilterHandler ¶
func (client *BaseClient) AddBeforeFilterHandler(handler ...FilterHandler) Client
AddBeforeFilterHandler add the filter handler before filters
func (*BaseClient) AddFilter ¶
func (client *BaseClient) AddFilter(filter ...Filter) Client
AddFilter add the filter to this Service
func (*BaseClient) AddInvokeHandler ¶
func (client *BaseClient) AddInvokeHandler(handler ...InvokeHandler) Client
AddInvokeHandler add the invoke handler to this Service
func (*BaseClient) AutoID ¶
func (client *BaseClient) AutoID() (string, error)
AutoID returns the auto id of this hprose client. If the id is not initialized, it be initialized and returned.
func (*BaseClient) Failround ¶
func (client *BaseClient) Failround() int
Failround return the fail round
func (*BaseClient) FilterByIndex ¶
FilterByIndex return the filter by index
func (*BaseClient) GetClientContext ¶
func (client *BaseClient) GetClientContext( settings *InvokeSettings) (context *ClientContext)
GetClientContext return a ClientContext
func (*BaseClient) Go ¶
func (client *BaseClient) Go( name string, args []reflect.Value, settings *InvokeSettings, callback Callback)
Go invoke the remote method asynchronous
func (*BaseClient) ID ¶
func (client *BaseClient) ID() string
ID returns the auto id of this hprose client. If the id is not initialized, return empty string.
func (*BaseClient) InitBaseClient ¶
func (client *BaseClient) InitBaseClient()
InitBaseClient initializes BaseClient
func (*BaseClient) Invoke ¶
func (client *BaseClient) Invoke( name string, args []reflect.Value, settings *InvokeSettings) (results []reflect.Value, err error)
Invoke the remote method synchronous
func (*BaseClient) IsSubscribed ¶
IsSubscribed the topic
func (*BaseClient) NumFilter ¶
func (fm *BaseClient) NumFilter() int
NumFilter return the filter count
func (*BaseClient) RemoveFilter ¶
func (client *BaseClient) RemoveFilter(filter ...Filter) Client
RemoveFilter remove the filter from this Service
func (*BaseClient) RemoveFilterByIndex ¶
func (client *BaseClient) RemoveFilterByIndex(index int) Client
RemoveFilterByIndex remove the filter by the index
func (*BaseClient) SetEvent ¶
func (client *BaseClient) SetEvent(event ClientEvent)
SetEvent set the client event
func (*BaseClient) SetFilter ¶
func (client *BaseClient) SetFilter(filter ...Filter) Client
SetFilter will replace the current filter settings
func (*BaseClient) SetRetry ¶
func (client *BaseClient) SetRetry(value int)
SetRetry set the max retry count
func (*BaseClient) SetTLSClientConfig ¶
func (client *BaseClient) SetTLSClientConfig(config *tls.Config)
SetTLSClientConfig set the tls config of hprose client
func (*BaseClient) SetTimeout ¶
func (client *BaseClient) SetTimeout(value time.Duration)
SetTimeout set the client timeout setting
func (*BaseClient) SetURI ¶
func (client *BaseClient) SetURI(uri string)
SetURI set the current hprose service address.
If you want to set more than one service address, please don't use this method, use SetURIList instead.
func (*BaseClient) SetURIList ¶
func (client *BaseClient) SetURIList(uriList []string)
SetURIList set a list of server addresses
func (*BaseClient) SetUserData ¶
func (client *BaseClient) SetUserData( userdata map[string]interface{}) Client
SetUserData for client
func (*BaseClient) Subscribe ¶
func (client *BaseClient) Subscribe( name string, id string, settings *InvokeSettings, callback interface{}) (err error)
Subscribe a push topic
func (*BaseClient) SubscribedList ¶
func (tm *BaseClient) SubscribedList() []string
SubscribedList returns the subscribed topic list
func (*BaseClient) TLSClientConfig ¶
func (client *BaseClient) TLSClientConfig() *tls.Config
TLSClientConfig returns the tls config of hprose client
func (*BaseClient) Timeout ¶
func (client *BaseClient) Timeout() time.Duration
Timeout returns the client timeout setting
func (*BaseClient) URI ¶
func (client *BaseClient) URI() string
URI returns the current hprose service address.
func (*BaseClient) URIList ¶
func (client *BaseClient) URIList() []string
URIList returns all of the hprose service addresses
func (*BaseClient) URL ¶
func (client *BaseClient) URL() *url.URL
URL returns the current hprose service address.
func (*BaseClient) Unsubscribe ¶
func (client *BaseClient) Unsubscribe(name string, id ...string)
Unsubscribe a push topic
func (*BaseClient) Use ¶
func (hm *BaseClient) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
func (*BaseClient) UseService ¶
func (client *BaseClient) UseService( remoteService interface{}, namespace ...string)
UseService build a remote service proxy object with namespace
type BaseContext ¶
type BaseContext struct {
// contains filtered or unexported fields
}
BaseContext is the base context
func (*BaseContext) Get ¶
func (context *BaseContext) Get(key string) interface{}
Get value from hprose context
func (*BaseContext) GetBool ¶
func (context *BaseContext) GetBool( key string, defaultValue ...bool) bool
GetBool from hprose context
func (*BaseContext) GetFloat ¶
func (context *BaseContext) GetFloat( key string, defaultValue ...float64) float64
GetFloat from hprose context
func (*BaseContext) GetInt ¶
func (context *BaseContext) GetInt( key string, defaultValue ...int) int
GetInt from hprose context
func (*BaseContext) GetInt64 ¶
func (context *BaseContext) GetInt64( key string, defaultValue ...int64) int64
GetInt64 from hprose context
func (*BaseContext) GetInterface ¶
func (context *BaseContext) GetInterface( key string, defaultValue ...interface{}) interface{}
GetInterface from hprose context
func (*BaseContext) GetString ¶
func (context *BaseContext) GetString( key string, defaultValue ...string) string
GetString from hprose context
func (*BaseContext) GetUInt ¶
func (context *BaseContext) GetUInt( key string, defaultValue ...uint) uint
GetUInt from hprose context
func (*BaseContext) GetUInt64 ¶
func (context *BaseContext) GetUInt64( key string, defaultValue ...uint64) uint64
GetUInt64 from hprose context
func (*BaseContext) InitBaseContext ¶
func (context *BaseContext) InitBaseContext()
InitBaseContext initializes BaseContext
func (*BaseContext) Set ¶
func (context *BaseContext) Set(key string, value interface{})
Set is an alias of SetInterface
func (*BaseContext) SetBool ¶
func (context *BaseContext) SetBool(key string, value bool)
SetBool to hprose context
func (*BaseContext) SetFloat ¶
func (context *BaseContext) SetFloat(key string, value float64)
SetFloat to hprose context
func (*BaseContext) SetInt ¶
func (context *BaseContext) SetInt(key string, value int)
SetInt to hprose context
func (*BaseContext) SetInt64 ¶
func (context *BaseContext) SetInt64(key string, value int64)
SetInt64 to hprose context
func (*BaseContext) SetInterface ¶
func (context *BaseContext) SetInterface(key string, value interface{})
SetInterface to hprose context
func (*BaseContext) SetString ¶
func (context *BaseContext) SetString(key string, value string)
SetString to hprose context
func (*BaseContext) SetUInt ¶
func (context *BaseContext) SetUInt(key string, value uint)
SetUInt to hprose context
func (*BaseContext) SetUInt64 ¶
func (context *BaseContext) SetUInt64(key string, value uint64)
SetUInt64 to hprose context
func (*BaseContext) UserData ¶
func (context *BaseContext) UserData() map[string]interface{}
UserData return the user data
type BaseHTTPService ¶
type BaseHTTPService struct { BaseService P3P bool GET bool CrossDomain bool AccessControlAllowOrigins map[string]bool LastModified string Etag string // contains filtered or unexported fields }
BaseHTTPService is the hprose base http service
func (*BaseHTTPService) AddAccessControlAllowOrigin ¶
func (service *BaseHTTPService) AddAccessControlAllowOrigin(origins ...string)
AddAccessControlAllowOrigin add access control allow origin
func (*BaseHTTPService) ClientAccessPolicyXMLContent ¶
func (service *BaseHTTPService) ClientAccessPolicyXMLContent() []byte
ClientAccessPolicyXMLContent return the client access policy xml content
func (*BaseHTTPService) ClientAccessPolicyXMLFile ¶
func (service *BaseHTTPService) ClientAccessPolicyXMLFile() string
ClientAccessPolicyXMLFile return the client access policy xml file
func (*BaseHTTPService) CrossDomainXMLContent ¶
func (service *BaseHTTPService) CrossDomainXMLContent() []byte
CrossDomainXMLContent return the cross domain xml content
func (*BaseHTTPService) CrossDomainXMLFile ¶
func (service *BaseHTTPService) CrossDomainXMLFile() string
CrossDomainXMLFile return the cross domain xml file
func (*BaseHTTPService) Filter ¶
func (fm *BaseHTTPService) Filter() Filter
Filter return the first filter
func (*BaseHTTPService) FilterByIndex ¶
FilterByIndex return the filter by index
func (*BaseHTTPService) InitBaseHTTPService ¶
func (service *BaseHTTPService) InitBaseHTTPService()
InitBaseHTTPService initializes BaseHTTPService
func (*BaseHTTPService) NumFilter ¶
func (fm *BaseHTTPService) NumFilter() int
NumFilter return the filter count
func (*BaseHTTPService) RemoveAccessControlAllowOrigin ¶
func (service *BaseHTTPService) RemoveAccessControlAllowOrigin(origins ...string)
RemoveAccessControlAllowOrigin remove access control allow origin
func (*BaseHTTPService) SetClientAccessPolicyXMLContent ¶
func (service *BaseHTTPService) SetClientAccessPolicyXMLContent(content []byte)
SetClientAccessPolicyXMLContent set the client access policy xml content
func (*BaseHTTPService) SetClientAccessPolicyXMLFile ¶
func (service *BaseHTTPService) SetClientAccessPolicyXMLFile(filename string)
SetClientAccessPolicyXMLFile set the client access policy xml file
func (*BaseHTTPService) SetCrossDomainXMLContent ¶
func (service *BaseHTTPService) SetCrossDomainXMLContent(content []byte)
SetCrossDomainXMLContent set the cross domain xml content
func (*BaseHTTPService) SetCrossDomainXMLFile ¶
func (service *BaseHTTPService) SetCrossDomainXMLFile(filename string)
SetCrossDomainXMLFile set the cross domain xml file
func (*BaseHTTPService) Use ¶
func (hm *BaseHTTPService) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type BaseService ¶
type BaseService struct { FixArguments func(args []reflect.Value, context ServiceContext) Event ServiceEvent Debug bool Timeout time.Duration Heartbeat time.Duration ErrorDelay time.Duration UserData map[string]interface{} // contains filtered or unexported fields }
BaseService is the hprose base service
func (*BaseService) AddAfterFilterHandler ¶
func (service *BaseService) AddAfterFilterHandler(handler ...FilterHandler) Service
AddAfterFilterHandler add the filter handler after filters
func (*BaseService) AddAllMethods ¶
func (service *BaseService) AddAllMethods(obj interface{}, option ...Options) Service
AddAllMethods will publish all methods and non-nil function fields on the obj self and on its anonymous or non-anonymous struct fields (or pointer to pointer ... to pointer struct fields). This is a recursive operation. So it's a pit, if you do not know what you are doing, do not step on.
func (*BaseService) AddBeforeFilterHandler ¶
func (service *BaseService) AddBeforeFilterHandler(handler ...FilterHandler) Service
AddBeforeFilterHandler add the filter handler before filters
func (*BaseService) AddFilter ¶
func (service *BaseService) AddFilter(filter ...Filter) Service
AddFilter add the filter to this Service
func (*BaseService) AddFunction ¶
func (service *BaseService) AddFunction(name string, function interface{}, option ...Options) Service
AddFunction publish a func or bound method name is the method name function is a func or bound method options includes Mode, Simple, Oneway and NameSpace
func (*BaseService) AddFunctions ¶
func (service *BaseService) AddFunctions(names []string, functions []interface{}, option ...Options) Service
AddFunctions is used for batch publishing service method
func (*BaseService) AddInstanceMethods ¶
func (service *BaseService) AddInstanceMethods(obj interface{}, option ...Options) Service
AddInstanceMethods is used for publishing all the public methods and func fields with options.
func (*BaseService) AddInvokeHandler ¶
func (service *BaseService) AddInvokeHandler(handler ...InvokeHandler) Service
AddInvokeHandler add the invoke handler to this Service
func (*BaseService) AddMethod ¶
func (service *BaseService) AddMethod(name string, obj interface{}, alias string, option ...Options) Service
AddMethod is used for publishing a method on the obj with an alias
func (*BaseService) AddMethods ¶
func (service *BaseService) AddMethods(names []string, obj interface{}, aliases []string, option ...Options) Service
AddMethods is used for batch publishing methods on the obj with aliases
func (*BaseService) AddMissingMethod ¶
func (service *BaseService) AddMissingMethod(method MissingMethod, option ...Options) Service
AddMissingMethod is used for publishing a method, all methods not explicitly published will be redirected to this method.
func (*BaseService) AddNetRPCMethods ¶
func (service *BaseService) AddNetRPCMethods(rcvr interface{}, option ...Options) Service
AddNetRPCMethods is used for publishing methods defined for net/rpc.
func (*BaseService) Broadcast ¶
func (service *BaseService) Broadcast( topic string, result interface{}, callback func([]string))
Broadcast push result to all clients
func (*BaseService) DoFunctionList ¶
func (service *BaseService) DoFunctionList(context ServiceContext) []byte
DoFunctionList returns the function list
func (*BaseService) EndError ¶
func (service *BaseService) EndError(err error, context Context) []byte
EndError return the error response with TagEnd
func (*BaseService) Exist ¶
func (service *BaseService) Exist(topic string, id string) bool
Exist returns true if the client id exist.
func (*BaseService) FilterByIndex ¶
FilterByIndex return the filter by index
func (*BaseService) Handle ¶
func (service *BaseService) Handle(request []byte, context Context) []byte
Handle the hprose request and return the hprose response
func (*BaseService) IDList ¶
func (service *BaseService) IDList(topic string) []string
IDList returns the push client id list
func (*BaseService) InitBaseService ¶
func (service *BaseService) InitBaseService()
InitBaseService initializes BaseService
func (*BaseService) Multicast ¶
func (service *BaseService) Multicast( topic string, ids []string, result interface{}, callback func([]string))
Multicast result to the specified clients
func (*BaseService) NumFilter ¶
func (fm *BaseService) NumFilter() int
NumFilter return the filter count
func (*BaseService) Publish ¶
func (service *BaseService) Publish( topic string, timeout time.Duration, heartbeat time.Duration) Service
Publish the hprose push topic
func (*BaseService) Push ¶
func (service *BaseService) Push(topic string, result interface{}, id ...string)
Push result to clients
func (*BaseService) Remove ¶
func (service *BaseService) Remove(name string) Service
Remove the published func or method by name
func (*BaseService) RemoveFilter ¶
func (service *BaseService) RemoveFilter(filter ...Filter) Service
RemoveFilter remove the filter from this Service
func (*BaseService) RemoveFilterByIndex ¶
func (service *BaseService) RemoveFilterByIndex(index int) Service
RemoveFilterByIndex remove the filter by the index
func (*BaseService) SetFilter ¶
func (service *BaseService) SetFilter(filter ...Filter) Service
SetFilter will replace the current filter settings
func (*BaseService) SetUserData ¶
func (service *BaseService) SetUserData( userdata map[string]interface{}) Service
SetUserData for service
func (*BaseService) Unicast ¶
func (service *BaseService) Unicast( topic string, id string, result interface{}, callback func(bool))
Unicast result to then specified client
func (*BaseService) Use ¶
func (hm *BaseService) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type BaseServiceContext ¶
type BaseServiceContext struct { BaseContext // contains filtered or unexported fields }
BaseServiceContext is the base service context
func (*BaseServiceContext) ByRef ¶
func (context *BaseServiceContext) ByRef() bool
ByRef returns whether the current invoking is parameter passing by reference.
func (*BaseServiceContext) Clients ¶
func (context *BaseServiceContext) Clients() Clients
Clients returns the Clients interface
func (*BaseServiceContext) InitServiceContext ¶
func (context *BaseServiceContext) InitServiceContext(service Service)
InitServiceContext initializes BaseServiceContext
func (*BaseServiceContext) IsMissingMethod ¶
func (context *BaseServiceContext) IsMissingMethod() bool
IsMissingMethod returns whether the current invoking is missing method
func (*BaseServiceContext) Method ¶
func (context *BaseServiceContext) Method() *Method
Method returns the method of current invoking
func (*BaseServiceContext) Service ¶
func (context *BaseServiceContext) Service() Service
Service returns the Service interface
type Client ¶
type Client interface { URL() *url.URL URI() string SetURI(uri string) URIList() []string SetURIList(uriList []string) TLSClientConfig() *tls.Config SetTLSClientConfig(config *tls.Config) Retry() int SetRetry(value int) Timeout() time.Duration SetTimeout(value time.Duration) Failround() int SetEvent(ClientEvent) Filter() Filter FilterByIndex(index int) Filter SetFilter(filter ...Filter) Client AddFilter(filter ...Filter) Client RemoveFilterByIndex(index int) Client RemoveFilter(filter ...Filter) Client AddInvokeHandler(handler ...InvokeHandler) Client AddBeforeFilterHandler(handler ...FilterHandler) Client AddAfterFilterHandler(handler ...FilterHandler) Client SetUserData(userdata map[string]interface{}) Client UseService(remoteService interface{}, namespace ...string) Invoke(string, []reflect.Value, *InvokeSettings) ([]reflect.Value, error) Go(string, []reflect.Value, *InvokeSettings, Callback) Close() AutoID() (string, error) ID() string Subscribe(name string, id string, settings *InvokeSettings, callback interface{}) (err error) Unsubscribe(name string, id ...string) IsSubscribed(name string) bool SubscribedList() []string }
Client is hprose client
type ClientContext ¶
type ClientContext struct { BaseContext InvokeSettings Retried int Client Client }
ClientContext is the hprose client context
type Clients ¶
type Clients interface { IDList(topic string) []string Exist(topic string, id string) bool Push(topic string, result interface{}, id ...string) Broadcast(topic string, result interface{}, callback func([]string)) Multicast(topic string, ids []string, result interface{}, callback func([]string)) Unicast(topic string, id string, result interface{}, callback func(bool)) }
Clients interface for server push
type Context ¶
type Context interface { UserData() map[string]interface{} GetInt(key string, defaultValue ...int) int GetUInt(key string, defaultValue ...uint) uint GetInt64(key string, defaultValue ...int64) int64 GetUInt64(key string, defaultValue ...uint64) uint64 GetFloat(key string, defaultValue ...float64) float64 GetBool(key string, defaultValue ...bool) bool GetString(key string, defaultValue ...string) string GetInterface(key string, defaultValue ...interface{}) interface{} Get(key string) interface{} SetInt(key string, value int) SetUInt(key string, value uint) SetInt64(key string, value int64) SetUInt64(key string, value uint64) SetFloat(key string, value float64) SetBool(key string, value bool) SetString(key string, value string) SetInterface(key string, value interface{}) Set(key string, value interface{}) }
Context is the hprose context
type Filter ¶
type Filter interface { InputFilter(data []byte, context Context) []byte OutputFilter(data []byte, context Context) []byte }
Filter is hprose filter
type FilterHandler ¶
type FilterHandler func( request []byte, context Context, next NextFilterHandler) (response []byte, err error)
FilterHandler is the filter handler function
type HTTPClient ¶
type HTTPClient struct { BaseClient http.Transport Header http.Header // contains filtered or unexported fields }
HTTPClient is hprose http client
func NewHTTPClient ¶
func NewHTTPClient(uri ...string) (client *HTTPClient)
NewHTTPClient is the constructor of HTTPClient
func (*HTTPClient) Compression ¶
func (client *HTTPClient) Compression() bool
Compression returns the compression status of hprose client
func (*HTTPClient) FilterByIndex ¶
FilterByIndex return the filter by index
func (*HTTPClient) IsSubscribed ¶
IsSubscribed the topic
func (*HTTPClient) KeepAlive ¶
func (client *HTTPClient) KeepAlive() bool
KeepAlive returns the keepalive status of hprose client
func (*HTTPClient) MaxConcurrentRequests ¶
func (client *HTTPClient) MaxConcurrentRequests() int
MaxConcurrentRequests returns max concurrent request count
func (*HTTPClient) NumFilter ¶
func (fm *HTTPClient) NumFilter() int
NumFilter return the filter count
func (*HTTPClient) SetCompression ¶
func (client *HTTPClient) SetCompression(enable bool)
SetCompression sets the compression status of hprose client
func (*HTTPClient) SetKeepAlive ¶
func (client *HTTPClient) SetKeepAlive(enable bool)
SetKeepAlive sets the keepalive status of hprose client
func (*HTTPClient) SetMaxConcurrentRequests ¶
func (client *HTTPClient) SetMaxConcurrentRequests(value int)
SetMaxConcurrentRequests sets max concurrent request count
func (*HTTPClient) SetTLSClientConfig ¶
func (client *HTTPClient) SetTLSClientConfig(config *tls.Config)
SetTLSClientConfig sets the tls.Config
func (*HTTPClient) SetURIList ¶
func (client *HTTPClient) SetURIList(uriList []string)
SetURIList sets a list of server addresses
func (*HTTPClient) SubscribedList ¶
func (tm *HTTPClient) SubscribedList() []string
SubscribedList returns the subscribed topic list
func (*HTTPClient) TLSClientConfig ¶
func (client *HTTPClient) TLSClientConfig() *tls.Config
TLSClientConfig returns the tls.Config in hprose client
func (*HTTPClient) Use ¶
func (hm *HTTPClient) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type HTTPContext ¶
type HTTPContext struct { BaseServiceContext Response http.ResponseWriter Request *http.Request }
HTTPContext is the hprose http context
func (*HTTPContext) InitHTTPContext ¶
func (context *HTTPContext) InitHTTPContext( service Service, response http.ResponseWriter, request *http.Request)
InitHTTPContext initializes HTTPContext
type HTTPService ¶
type HTTPService struct { BaseHTTPService // contains filtered or unexported fields }
HTTPService is the hprose http service
func NewHTTPService ¶
func NewHTTPService() (service *HTTPService)
NewHTTPService is the constructor of HTTPService
func (*HTTPService) FilterByIndex ¶
FilterByIndex return the filter by index
func (*HTTPService) InitHTTPService ¶
func (service *HTTPService) InitHTTPService()
InitHTTPService initializes HTTPService
func (*HTTPService) NumFilter ¶
func (fm *HTTPService) NumFilter() int
NumFilter return the filter count
func (*HTTPService) ServeHTTP ¶
func (service *HTTPService) ServeHTTP( response http.ResponseWriter, request *http.Request)
ServeHTTP is the hprose http handler method
func (*HTTPService) Use ¶
func (hm *HTTPService) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type InvokeHandler ¶
type InvokeHandler func( name string, args []reflect.Value, context Context, next NextInvokeHandler) (results []reflect.Value, err error)
InvokeHandler is the invoke handler function
type InvokeSettings ¶
type InvokeSettings struct { ByRef bool Simple bool Idempotent bool Failswitch bool Oneway bool JSONCompatible bool Retry int Mode ResultMode Timeout time.Duration ResultTypes []reflect.Type // contains filtered or unexported fields }
InvokeSettings is the invoke settings of hprose client
func (*InvokeSettings) SetUserData ¶
func (settings *InvokeSettings) SetUserData(data map[string]interface{})
SetUserData on InvokeSettings
type Limiter ¶
type Limiter struct { MaxConcurrentRequests int sync.Cond // contains filtered or unexported fields }
Limiter is a request limiter
type MissingMethod ¶
type MissingMethod func(name string, args []reflect.Value, context Context) (result []reflect.Value, err error)
MissingMethod is missing method
type NextFilterHandler ¶
NextFilterHandler is the next filter handler function
type NextInvokeHandler ¶
type NextInvokeHandler func( name string, args []reflect.Value, context Context) (results []reflect.Value, err error)
NextInvokeHandler is the next invoke handler function
type Options ¶
type Options struct { Mode ResultMode Simple bool Oneway bool NameSpace string JSONCompatible bool }
Options is the options of the published service method
type PanicError ¶
type PanicError struct { Panic interface{} Stack []byte }
PanicError represents a panic error
func NewPanicError ¶
func NewPanicError(v interface{}) *PanicError
NewPanicError return a panic error
func (*PanicError) Error ¶
func (pe *PanicError) Error() string
Error implements the PanicError Error method.
type ResultMode ¶
type ResultMode int
ResultMode is result mode
func (ResultMode) String ¶
func (mode ResultMode) String() string
type Server ¶
type Server interface { Service URI() string Handle() (err error) Close() Start() (err error) Restart() Stop() }
Server interface
type Service ¶
type Service interface { AddFunction(name string, function interface{}, option ...Options) Service AddFunctions(names []string, functions []interface{}, option ...Options) Service AddMethod(name string, obj interface{}, alias string, option ...Options) Service AddMethods(names []string, obj interface{}, aliases []string, option ...Options) Service AddInstanceMethods(obj interface{}, option ...Options) Service AddAllMethods(obj interface{}, option ...Options) Service AddMissingMethod(method MissingMethod, option ...Options) Service AddNetRPCMethods(rcvr interface{}, option ...Options) Service Remove(name string) Service Filter() Filter FilterByIndex(index int) Filter SetFilter(filter ...Filter) Service AddFilter(filter ...Filter) Service RemoveFilterByIndex(index int) Service RemoveFilter(filter ...Filter) Service AddInvokeHandler(handler ...InvokeHandler) Service AddBeforeFilterHandler(handler ...FilterHandler) Service AddAfterFilterHandler(handler ...FilterHandler) Service SetUserData(userdata map[string]interface{}) Service Publish(topic string, timeout time.Duration, heartbeat time.Duration) Service Clients }
Service interface
type ServiceContext ¶
type ServiceContext interface { Context Service() Service Clients() Clients Method() *Method IsMissingMethod() bool ByRef() bool // contains filtered or unexported methods }
ServiceContext is the hprose service context
type SocketClient ¶
type SocketClient struct { BaseClient ReadBuffer int WriteBuffer int TLSConfig *tls.Config // contains filtered or unexported fields }
SocketClient is base struct for TCPClient and UnixClient
func (*SocketClient) Filter ¶
func (fm *SocketClient) Filter() Filter
Filter return the first filter
func (*SocketClient) FilterByIndex ¶
FilterByIndex return the filter by index
func (*SocketClient) IsSubscribed ¶
IsSubscribed the topic
func (*SocketClient) NumFilter ¶
func (fm *SocketClient) NumFilter() int
NumFilter return the filter count
func (*SocketClient) SetTLSClientConfig ¶
func (client *SocketClient) SetTLSClientConfig(config *tls.Config)
SetTLSClientConfig sets the tls.Config
func (*SocketClient) SubscribedList ¶
func (tm *SocketClient) SubscribedList() []string
SubscribedList returns the subscribed topic list
func (*SocketClient) TLSClientConfig ¶
func (client *SocketClient) TLSClientConfig() *tls.Config
TLSClientConfig returns the tls.Config in hprose client
func (*SocketClient) Use ¶
func (hm *SocketClient) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type SocketContext ¶
type SocketContext struct { BaseServiceContext net.Conn }
SocketContext is the hprose socket context for service
type SocketService ¶
type SocketService struct { BaseService TLSConfig *tls.Config // contains filtered or unexported fields }
SocketService is the hprose socket service
func (*SocketService) Filter ¶
func (fm *SocketService) Filter() Filter
Filter return the first filter
func (*SocketService) FilterByIndex ¶
FilterByIndex return the filter by index
func (*SocketService) NumFilter ¶
func (fm *SocketService) NumFilter() int
NumFilter return the filter count
func (*SocketService) Use ¶
func (hm *SocketService) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type TCPClient ¶
type TCPClient struct { SocketClient Linger int NoDelay bool KeepAlive bool KeepAlivePeriod time.Duration }
TCPClient is hprose tcp client
func NewTCPClient ¶
NewTCPClient is the constructor of TCPClient
func (*TCPClient) FilterByIndex ¶
FilterByIndex return the filter by index
func (*TCPClient) IsSubscribed ¶
IsSubscribed the topic
func (*TCPClient) NumFilter ¶
func (fm *TCPClient) NumFilter() int
NumFilter return the filter count
func (*TCPClient) SetURIList ¶
SetURIList set a list of server addresses
func (*TCPClient) SubscribedList ¶
func (tm *TCPClient) SubscribedList() []string
SubscribedList returns the subscribed topic list
func (*TCPClient) Use ¶
func (hm *TCPClient) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type TCPServer ¶
type TCPServer struct { TCPService // contains filtered or unexported fields }
TCPServer is a hprose tcp server
func NewTCPServer ¶
NewTCPServer is the constructor for TCPServer
func (*TCPServer) FilterByIndex ¶
FilterByIndex return the filter by index
func (*TCPServer) NumFilter ¶
func (fm *TCPServer) NumFilter() int
NumFilter return the filter count
func (*TCPServer) Use ¶
func (hm *TCPServer) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type TCPService ¶
type TCPService struct { SocketService Linger int NoDelay bool KeepAlive bool KeepAlivePeriod time.Duration }
TCPService is the hprose tcp service
func NewTCPService ¶
func NewTCPService() (service *TCPService)
NewTCPService is the constructor of TCPService
func (*TCPService) FilterByIndex ¶
FilterByIndex return the filter by index
func (*TCPService) NumFilter ¶
func (fm *TCPService) NumFilter() int
NumFilter return the filter count
func (*TCPService) Serve ¶
func (service *TCPService) Serve(listener net.Listener)
Serve runs on the Listener. Serve blocks, serving the listener until the server is stop. The caller typically invokes Serve in a go statement.
func (*TCPService) ServeConn ¶
func (service *TCPService) ServeConn(conn net.Conn)
ServeConn runs on a single net connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement.
func (*TCPService) ServeTCP ¶
func (service *TCPService) ServeTCP(listener *net.TCPListener)
ServeTCP runs on the TCPListener. ServeTCP blocks, serving the listener until the server is stop. The caller typically invokes ServeTCP in a go statement.
func (*TCPService) ServeTCPConn ¶
func (service *TCPService) ServeTCPConn(conn *net.TCPConn)
ServeTCPConn runs on a single tcp connection. ServeTCPConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeTCPConn in a go statement.
func (*TCPService) Use ¶
func (hm *TCPService) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type UnixClient ¶
type UnixClient struct {
SocketClient
}
UnixClient is hprose unix client
func NewUnixClient ¶
func NewUnixClient(uri ...string) (client *UnixClient)
NewUnixClient is the constructor of UnixClient
func (*UnixClient) FilterByIndex ¶
FilterByIndex return the filter by index
func (*UnixClient) IsSubscribed ¶
IsSubscribed the topic
func (*UnixClient) NumFilter ¶
func (fm *UnixClient) NumFilter() int
NumFilter return the filter count
func (*UnixClient) SetURIList ¶
func (client *UnixClient) SetURIList(uriList []string)
SetURIList set a list of server addresses
func (*UnixClient) SubscribedList ¶
func (tm *UnixClient) SubscribedList() []string
SubscribedList returns the subscribed topic list
func (*UnixClient) Use ¶
func (hm *UnixClient) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type UnixServer ¶
type UnixServer struct { UnixService // contains filtered or unexported fields }
UnixServer is a hprose unix server
func NewUnixServer ¶
func NewUnixServer(uri string) (server *UnixServer)
NewUnixServer is the constructor for UnixServer
func (*UnixServer) FilterByIndex ¶
FilterByIndex return the filter by index
func (*UnixServer) Handle ¶
func (server *UnixServer) Handle() (err error)
Handle the hprose unix server
func (*UnixServer) NumFilter ¶
func (fm *UnixServer) NumFilter() int
NumFilter return the filter count
func (*UnixServer) URI ¶
func (server *UnixServer) URI() string
URI return the real address of this server
func (*UnixServer) Use ¶
func (hm *UnixServer) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type UnixService ¶
type UnixService struct {
SocketService
}
UnixService is the hprose unix service
func NewUnixService ¶
func NewUnixService() (service *UnixService)
NewUnixService is the constructor of UnixService
func (*UnixService) FilterByIndex ¶
FilterByIndex return the filter by index
func (*UnixService) NumFilter ¶
func (fm *UnixService) NumFilter() int
NumFilter return the filter count
func (*UnixService) Serve ¶
func (service *UnixService) Serve(listener net.Listener)
Serve runs on the Listener. Serve blocks, serving the listener until the server is stop. The caller typically invokes Serve in a go statement.
func (*UnixService) ServeConn ¶
func (service *UnixService) ServeConn(conn net.Conn)
ServeConn runs on a single net connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement.
func (*UnixService) ServeUnix ¶
func (service *UnixService) ServeUnix(listener *net.UnixListener)
ServeUnix runs on the UnixListener. ServeUnix blocks, serving the listener until the server is stop. The caller typically invokes ServeUnix in a go statement.
func (*UnixService) ServeUnixConn ¶
func (service *UnixService) ServeUnixConn(conn *net.UnixConn)
ServeUnixConn runs on a single tcp connection. ServeUnixConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeUnixConn in a go statement.
func (*UnixService) Use ¶
func (hm *UnixService) Use(handler ...InvokeHandler)
Use is a method alias of AddInvokeHandler
type WorkerPool ¶
type WorkerPool struct { MaxWorkersCount int MaxIdleWorkerDuration time.Duration // contains filtered or unexported fields }
WorkerPool serves outgoing connections via a pool of workers in FILO order, i.e. the most recently stopped worker will serve the next incoming connection.
Such a scheme keeps CPU caches hot (in theory).
func (*WorkerPool) Go ¶
func (wp *WorkerPool) Go(c func()) bool
func (*WorkerPool) Start ¶
func (wp *WorkerPool) Start()
func (*WorkerPool) Stop ¶
func (wp *WorkerPool) Stop()
Source Files ¶
- base_client.go
- base_service.go
- basehttp_service.go
- client.go
- client_event.go
- clients.go
- context.go
- doc.go
- error.go
- filter.go
- full_socket_trans.go
- handler.go
- hd_socket_trans.go
- http_client.go
- http_service.go
- limiter.go
- method.go
- result_mode.go
- server.go
- service.go
- service_context.go
- service_event.go
- socket_client.go
- socket_common.go
- socket_service.go
- tcp_client.go
- tcp_server.go
- tcp_service.go
- topic.go
- types.go
- unix_client.go
- unix_server.go
- unix_service.go
- workerpool.go