Documentation ¶
Index ¶
- Constants
- Variables
- func DailTimeOut(target string, timeout time.Duration) (c *net.TCPConn, err error)
- func DefaultSmuxConfig() *smux.Config
- func FilterSmuxAcceptError(err error) error
- func GetMemInfo() (total, used uint64, err error)
- func GetProcessMemory(pid int) (used uint64, err error)
- func IsIPV4(val interface{}) bool
- func Max(a, b int) int
- func Min(a, b int) int
- func RandomString(length int, seed RandomSeed) string
- func RecvFd(socket *os.File) (*os.File, error)
- func SendFd(socket *os.File, name string, fd uintptr) error
- func SendFds(socket *os.File, msg []byte, fds ...int) error
- func ShiftAddrPort(addr string, shift int) (afterShift string)
- func SubString(sourceString string, begin, end int) string
- func VerifySmuxPoolConfig(cfg *SmuxConnPoolConfig) error
- type ConnectPool
- type MasterHelper
- type MultipartID
- type Object
- type Pool
- type RandomSeed
- type SmuxConnPoolConfig
- type SmuxConnPoolStat
- type SmuxConnectPool
- type SmuxPool
- type SmuxPoolStat
Constants ¶
const ( MEMINFO = "/proc/meminfo" PRO_MEM = "/proc/%d/status" )
const ( KB = 1 << (10 * iota) MB GB TB PB DefaultDataPartitionSize = 120 * GB TaskWorkerInterval = 1 )
const ( BlockCount = 1024 BlockSize = 65536 * 2 ReadBlockSize = BlockSize PerBlockCrcSize = 4 ExtentSize = BlockCount * BlockSize PacketHeaderSize = 57 BlockHeaderSize = 4096 RepairReadBlockSize = 4 * MB )
const (
ConnectIdleTime = 30
)
const (
DefaultSmuxPortShift = 500
)
const (
DefaultTinySizeLimit = 1 * MB // TODO explain tiny extent?
)
const MaxNameLen = 4096
MaxSendfdLen is the maximum length of the name of a file descriptor being sent using SendFd. The name of the file handle returned by RecvFd will never be larger than this value.
Variables ¶
var (
ErrNoValidMaster = errors.New("no valid master")
)
var (
ErrTooMuchSmuxStreams = errors.New("too much smux streams")
)
Functions ¶
func DailTimeOut ¶ added in v1.4.0
func DefaultSmuxConfig ¶
func GetMemInfo ¶
GetMemInfo returns the memory information.
func GetProcessMemory ¶ added in v1.1.0
func RandomString ¶ added in v1.5.0
func RandomString(length int, seed RandomSeed) string
func RecvFd ¶
RecvFd waits for a file descriptor to be sent over the given AF_UNIX socket. The file name of the remote file descriptor will be recreated locally (it is sent as non-auxiliary data in the same payload).
func SendFd ¶
SendFd sends a file descriptor over the given AF_UNIX socket. In addition, the file.Name() of the given file will also be sent as non-auxiliary data in the same payload (allowing to send contextual information for a file descriptor).
func ShiftAddrPort ¶
addr = ip:port afterShift = ip:(port+shift)
func VerifySmuxPoolConfig ¶
func VerifySmuxPoolConfig(cfg *SmuxConnPoolConfig) error
Types ¶
type ConnectPool ¶
func NewConnectPool ¶
func NewConnectPool() (cp *ConnectPool)
func NewConnectPoolWithTimeout ¶
func NewConnectPoolWithTimeout(idleConnTimeout time.Duration, connectTimeout int64) (cp *ConnectPool)
func (*ConnectPool) Close ¶
func (cp *ConnectPool) Close()
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, header 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 MultipartID ¶
type MultipartID string
func CreateMultipartID ¶
func CreateMultipartID(mpId uint64) MultipartID
func MultipartIDFromString ¶
func MultipartIDFromString(src string) MultipartID
func (MultipartID) PartitionID ¶
func (id MultipartID) PartitionID() (pID uint64, found bool)
func (MultipartID) String ¶
func (id MultipartID) String() string
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) PutConnectObjectToPool ¶
func (*Pool) ReleaseAll ¶
func (p *Pool) ReleaseAll()
type RandomSeed ¶ added in v1.5.0
type RandomSeed byte
const ( Numeric RandomSeed = 1 << iota LowerLetter UpperLetter )
func (RandomSeed) Runes ¶ added in v1.5.0
func (s RandomSeed) Runes() []rune
type SmuxConnPoolConfig ¶
type SmuxConnPoolConfig struct { *smux.Config TotalStreams int StreamsPerConn int ConnsPerAddr int PoolCapacity int DialTimeout time.Duration StreamIdleTimeout int64 }
func DefaultSmuxConnPoolConfig ¶
func DefaultSmuxConnPoolConfig() *SmuxConnPoolConfig
type SmuxConnPoolStat ¶
type SmuxConnPoolStat struct { TotalStreams int `json:"totalStreams"` TotalStreamsReported int `json:"totalStreamsInflight"` Pools map[string]*SmuxPoolStat `json:"pools"` TotalSessions int `json:"totalSessions"` }
type SmuxConnectPool ¶
func NewSmuxConnectPool ¶
func NewSmuxConnectPool(cfg *SmuxConnPoolConfig) (cp *SmuxConnectPool)
func (*SmuxConnectPool) Close ¶
func (cp *SmuxConnectPool) Close()
func (*SmuxConnectPool) GetConnect ¶
func (cp *SmuxConnectPool) GetConnect(targetAddr string) (c *smux.Stream, err error)
func (*SmuxConnectPool) GetStat ¶
func (cp *SmuxConnectPool) GetStat() *SmuxConnPoolStat
func (*SmuxConnectPool) PutConnect ¶
func (cp *SmuxConnectPool) PutConnect(stream *smux.Stream, forceClose bool)
type SmuxPool ¶
type SmuxPool struct {
// contains filtered or unexported fields
}
func NewSmuxPool ¶
func NewSmuxPool(cfg *SmuxConnPoolConfig, target string, streamBucket *simpleTokenBucket) (p *SmuxPool)
func (*SmuxPool) GetStat ¶
func (p *SmuxPool) GetStat() *SmuxPoolStat
func (*SmuxPool) MarkClosed ¶
func (*SmuxPool) PutStreamObjectToPool ¶
func (p *SmuxPool) PutStreamObjectToPool(obj *streamObject)
func (*SmuxPool) ReleaseAll ¶
func (p *SmuxPool) ReleaseAll()