Documentation ¶
Overview ¶
Package util provides basic utilities.
Index ¶
- Variables
- func Call(network, srv, name string, args interface{}, reply interface{}) bool
- func DialServer(network, addr string) *rpc.Client
- func RPCCall(c *rpc.Client, name string, args interface{}, reply interface{}) bool
- func RPCPoolArrayCall(pa *ResourcePoolsArray, i int, name string, args interface{}, ...) bool
- func RPCPoolCall(pool *ResourcePool, name string, args interface{}, reply interface{}) bool
- type Cfg
- type Resource
- type ResourcePool
- type ResourcePoolsArray
- type ResourcePoolsMap
Constants ¶
This section is empty.
Variables ¶
View Source
var RPCCallNs int64 = 0
debug
Functions ¶
func Call ¶
Call is the one-time RPC communication utility. No matter successfully or not, the channel will be closed.
func DialServer ¶
func RPCCall ¶
RPCCall is the RPC utility for reusing. Note that if successfully, the channel won't be closed.
func RPCPoolArrayCall ¶
func RPCPoolArrayCall(pa *ResourcePoolsArray, i int, name string, args interface{}, reply interface{}) bool
func RPCPoolCall ¶
func RPCPoolCall(pool *ResourcePool, name string, args interface{}, reply interface{}) bool
Types ¶
type Cfg ¶
type ResourcePool ¶
type ResourcePool struct { New func() Resource // contains filtered or unexported fields }
func NewResourcePool ¶
func NewResourcePool(new func() Resource, maxSize int) *ResourcePool
func (*ResourcePool) Clean ¶
func (pool *ResourcePool) Clean(r Resource)
Close one resource in the pool and the active resource size decreases.
func (*ResourcePool) Put ¶
func (pool *ResourcePool) Put(r Resource)
Put back the available resource into the pool for the future use.
type ResourcePoolsArray ¶
type ResourcePoolsArray struct {
// contains filtered or unexported fields
}
func NewResourcePoolsArray ¶
func NewResourcePoolsArray(news []func() Resource, maxSizeForOne, poolNum int) *ResourcePoolsArray
func (ResourcePoolsArray) Clean ¶
func (array ResourcePoolsArray) Clean(i int, r Resource)
func (ResourcePoolsArray) Get ¶
func (array ResourcePoolsArray) Get(i int) Resource
func (ResourcePoolsArray) Put ¶
func (array ResourcePoolsArray) Put(i int, r Resource)
type ResourcePoolsMap ¶
type ResourcePoolsMap struct {
// contains filtered or unexported fields
}
func NewResourcePoolsMap ¶
func NewResourcePoolsMap(new func(id string) func() Resource, maxSizeForOne int) *ResourcePoolsMap
func (ResourcePoolsMap) Clean ¶
func (pm ResourcePoolsMap) Clean(id string, r Resource)
func (ResourcePoolsMap) Get ¶
func (pm ResourcePoolsMap) Get(id string) Resource
func (ResourcePoolsMap) Put ¶
func (pm ResourcePoolsMap) Put(id string, r Resource)
Click to show internal directories.
Click to hide internal directories.