util

package
v0.0.0-...-9789875 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package util provides basic utilities.

Index

Constants

This section is empty.

Variables

View Source
var RPCCallNs int64 = 0

debug

Functions

func Call

func Call(network, srv, name string, args interface{}, reply interface{}) bool

Call is the one-time RPC communication utility. No matter successfully or not, the channel will be closed.

func DialServer

func DialServer(network, addr string) *rpc.Client

func RPCCall

func RPCCall(c *rpc.Client, name string, args interface{}, reply interface{}) bool

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 Cfg struct {
	Protocol        string
	APPAddrs        []string
	CoordinatorAddr string
	KVStoreAddrs    []string
	ItemCSV         string
	UserCSV         string
	TimeoutMS       int64
}

func ParseCfg

func ParseCfg(f string) *Cfg

type Resource

type Resource interface {
	Close() error
}

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) Get

func (pool *ResourcePool) Get() Resource

Get a resource from the pool.

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)

Jump to

Keyboard shortcuts

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