util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	DefaultDataPartitionSize = 120 * GB
	TaskWorkerInterval       = 1
)
View Source
const (
	BlockCount       = 1024
	BlockSize        = 65536 * 2
	ReadBlockSize    = BlockSize
	PerBlockCrcSize  = 4
	ExtentSize       = BlockCount * BlockSize
	PacketHeaderSize = 57
	BlockHeaderSize  = 4096
)
View Source
const (
	ConnectIdleTime = 30
)
View Source
const (
	DefaultTinySizeLimit = 1 * MB // TODO explain tiny extent?
)
View Source
const MEMINFO = "/proc/meminfo"

Variables

View Source
var (
	ErrNoValidMaster = errors.New("no valid master")
)

Functions

func GetMemInfo

func GetMemInfo() (total, used uint64, err error)

GetMemInfo returns the memory information.

func IsIPV4

func IsIPV4(val interface{}) bool

IsIPV4 returns if it is IPV4 address.

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

Types

type ConnectPool

type ConnectPool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewConnectPool

func NewConnectPool() (cp *ConnectPool)

func (*ConnectPool) GetConnect

func (cp *ConnectPool) GetConnect(targetAddr string) (c *net.TCPConn, err error)

func (*ConnectPool) PutConnect

func (cp *ConnectPool) PutConnect(c *net.TCPConn, forceClose bool)

type MasterHelper

type MasterHelper interface {
	AddNode(address string)
	Nodes() []string
	Leader() string
	Request(method, path string, param map[string]string, body []byte) (data []byte, err error)
}

MasterHelper defines the helper struct to manage the master.

func NewMasterHelper

func NewMasterHelper() MasterHelper

NewMasterHelper returns a new MasterHelper instance.

type Object

type Object struct {
	// contains filtered or unexported fields
}

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool(min, max int, timeout int64, target string) (p *Pool)

func (*Pool) GetConnectFromPool

func (p *Pool) GetConnectFromPool() (c *net.TCPConn, err error)

func (*Pool) NewConnect

func (p *Pool) NewConnect(target string) (c *net.TCPConn, err error)

func (*Pool) PutConnectObjectToPool

func (p *Pool) PutConnectObjectToPool(o *Object)

Directories

Path Synopsis
Package btree implements in-memory B-Trees of arbitrary degree.
Package btree implements in-memory B-Trees of arbitrary degree.

Jump to

Keyboard shortcuts

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