Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAbsPathLimit(f string) error
- func DecodeBKCheckCache(data []byte, head *protocol.PBHead, _ string, _ PathMapping, _ chan<- string) (*protocol.PBBodyCheckCacheReq, error)
- func DecodeBKCommonDispatchReq(data []byte, head *protocol.PBHead, basedir string, callback PathMapping, ...) (*protocol.PBBodyDispatchTaskReq, error)
- func DecodeBKCommonDispatchReqBuf(data []byte, body *protocol.PBBodyDispatchTaskReq, buflen int64, ...) error
- func DecodeBKCommonHead(data []byte) (*protocol.PBHead, int, error)
- func DecodeBKSendFile(data []byte, head *protocol.PBHead, basedir string, callback PathMapping, ...) (*protocol.PBBodySendFileReq, error)
- func DecodeBKSendFileBuf(data []byte, body *protocol.PBBodySendFileReq, buflen int64, basedir string, ...) error
- func DecodeUnknown(data []byte, head *protocol.PBHead, _ string, _ PathMapping) error
- func EncodeBKCheckCacheRsp(result []*protocol.PBCacheResult) ([]protocol.Message, error)
- func EncodeBKCommonDispatchRsp(results []*protocol.PBResult) ([]protocol.Message, error)
- func EncodeBKQuerySlotRsp(availableslotnum int32, refused int32, message string) ([]protocol.Message, error)
- func EncodeBKSendFileRsp(req *protocol.PBBodySendFileReq) ([]protocol.Message, error)
- func EncodeBKSyncTimeRsp(receivedtime time.Time) ([]protocol.Message, error)
- func EncodeBKUnknownRsp(_ time.Time) ([]protocol.Message, error)
- func ReceiveBKCheckCache(client *TCPClient, head *protocol.PBHead, _ string, _ PathMapping, ...) (*protocol.PBBodyCheckCacheReq, error)
- func ReceiveBKCommonDispatchReq(client *TCPClient, head *protocol.PBHead, basedir string, callback PathMapping, ...) (*protocol.PBBodyDispatchTaskReq, error)
- func ReceiveBKCommonHead(client *TCPClient) (*protocol.PBHead, error)
- func ReceiveBKQuerySlot(client *TCPClient, head *protocol.PBHead) (*protocol.PBBodyQuerySlotReq, error)
- func ReceiveBKSendFile(client *TCPClient, head *protocol.PBHead, basedir string, callback PathMapping, ...) (*protocol.PBBodySendFileReq, error)
- func ReceiveBKSlotRspAck(client *TCPClient, head *protocol.PBHead) (*protocol.PBBodySlotRspAck, error)
- func ReceiveUnknown(client *TCPClient, head *protocol.PBHead, _ string, _ PathMapping) error
- func SendMessages(client *TCPClient, messages *[]protocol.Message) error
- type PathMapping
- type TCPClient
- func (c *TCPClient) Close() error
- func (c *TCPClient) Closed() bool
- func (c *TCPClient) Connect(server string) error
- func (c *TCPClient) ReadData(expectlen int) ([]byte, int, error)
- func (c *TCPClient) ReadUntilEOF() ([]byte, int, error)
- func (c *TCPClient) RemoteAddr() string
- func (c *TCPClient) RemoteIP() string
- func (c *TCPClient) SendFile(infile string, compress protocol.CompressType) error
- func (c *TCPClient) TryReadData(expectlen int) ([]byte, int, error)
- func (c *TCPClient) WriteData(data []byte) error
Constants ¶
const ( DEFAULTTIMEOUTSECS = 300 DEFAULTREADALLTIMEOUTSECS = 600 )
define const vars for http client
Variables ¶
var ( SupportAbsPath = true DefaultWorkDir = "" )
var (
ErrorNotEnoughtBufData = fmt.Errorf("buf data of file is not enought")
)
Functions ¶
func CheckAbsPathLimit ¶
func DecodeBKCheckCache ¶
func DecodeBKCheckCache( data []byte, head *protocol.PBHead, _ string, _ PathMapping, _ chan<- string) (*protocol.PBBodyCheckCacheReq, error)
ReceiveBKCheckCache receive check cache request and generate the body
func DecodeBKCommonDispatchReq ¶
func DecodeBKCommonDispatchReq( data []byte, head *protocol.PBHead, basedir string, callback PathMapping, c chan<- string) (*protocol.PBBodyDispatchTaskReq, error)
func DecodeBKCommonDispatchReqBuf ¶
func DecodeBKCommonDispatchReqBuf( data []byte, body *protocol.PBBodyDispatchTaskReq, buflen int64, basedir string, callback PathMapping, c chan<- string) error
func DecodeBKSendFile ¶
func DecodeBKSendFileBuf ¶
func DecodeBKSendFileBuf( data []byte, body *protocol.PBBodySendFileReq, buflen int64, basedir string, callback PathMapping, c chan<- string, cm cache.Manager) error
func DecodeUnknown ¶
ReceiveUnknown to receive pb command body for unknown cmd
func EncodeBKCheckCacheRsp ¶
func EncodeBKCheckCacheRsp(result []*protocol.PBCacheResult) ([]protocol.Message, error)
EncodeBKCheckCacheRsp encode result to Messages
func EncodeBKCommonDispatchRsp ¶
EncodeBKCommonDispatchRsp encode results to Messages
func EncodeBKQuerySlotRsp ¶
func EncodeBKQuerySlotRsp(availableslotnum int32, refused int32, message string) ([]protocol.Message, error)
EncodeBKQuerySlotRsp encode time to Messages
func EncodeBKSendFileRsp ¶
func EncodeBKSendFileRsp(req *protocol.PBBodySendFileReq) ([]protocol.Message, error)
EncodeBKSendFileRsp encode results to Messages
func EncodeBKSyncTimeRsp ¶
EncodeBKSyncTimeRsp encode time to Messages
func EncodeBKUnknownRsp ¶
EncodeBKUnknownRsp encode time to Messages
func ReceiveBKCheckCache ¶
func ReceiveBKCheckCache(client *TCPClient, head *protocol.PBHead, _ string, _ PathMapping, _ chan<- string) (*protocol.PBBodyCheckCacheReq, error)
ReceiveBKCheckCache receive check cache request and generate the body
func ReceiveBKCommonDispatchReq ¶
func ReceiveBKCommonDispatchReq(client *TCPClient, head *protocol.PBHead, basedir string, callback PathMapping, c chan<- string) (*protocol.PBBodyDispatchTaskReq, error)
ReceiveBKCommonDispatchReq to receive pb command body for protocol.PBCmdType_DISPATCHTASKREQ
func ReceiveBKCommonHead ¶
ReceiveBKCommonHead to receive pb command head
func ReceiveBKQuerySlot ¶
func ReceiveBKQuerySlot(client *TCPClient, head *protocol.PBHead) (*protocol.PBBodyQuerySlotReq, error)
ReceiveBKQuerySlot to receive pb command body for query slot
func ReceiveBKSendFile ¶
func ReceiveBKSendFile(client *TCPClient, head *protocol.PBHead, basedir string, callback PathMapping, c chan<- string, cm cache.Manager) (*protocol.PBBodySendFileReq, error)
ReceiveBKSendFile to receive pb command body for send file
func ReceiveBKSlotRspAck ¶
func ReceiveBKSlotRspAck(client *TCPClient, head *protocol.PBHead) (*protocol.PBBodySlotRspAck, error)
ReceiveBKSlotRspAck to receive pb command body for slot offer ack
func ReceiveUnknown ¶
ReceiveUnknown to receive pb command body for unknown cmd
Types ¶
type PathMapping ¶
return relativepath, abspath, error
type TCPClient ¶
type TCPClient struct {
// contains filtered or unexported fields
}
TCPClient wrapper net.TCPConn
func NewTCPClientWithConn ¶
NewTCPClientWithConn return new TCPClient with specified conn
func (*TCPClient) ReadUntilEOF ¶
ReadUntilEOF read data until EOF
func (*TCPClient) SendFile ¶
func (c *TCPClient) SendFile(infile string, compress protocol.CompressType) error
SendFile send file
func (*TCPClient) TryReadData ¶
TryReadData try read data, return immediately after received any data