client

package
v0.0.0-...-6ac6f58 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULTTIMEOUTSECS        = 300
	DEFAULTREADALLTIMEOUTSECS = 600
)

define const vars for http client

Variables

This section is empty.

Functions

func EncodeCommonDistTask

func EncodeCommonDistTask(req *dcSDK.BKDistCommand) ([]protocol.Message, error)

EncodeCommonDistTask encode request command info into protocol.Message

func EncodeSendFileReq

func EncodeSendFileReq(req *dcSDK.BKDistFileSender, sandbox *syscall.Sandbox) ([]protocol.Message, error)

EncodeSendFileReq encode request files into protocol.Message

func EncodeSlotRspAck

func EncodeSlotRspAck(consumeslotnum int32) ([]protocol.Message, error)

func NewCommonRemoteWorker

func NewCommonRemoteWorker() dcSDK.RemoteWorker

NewCommonRemoteWorker get a new remote worker SDK

func NewCommonRemoteWorkerWithSlot

func NewCommonRemoteWorkerWithSlot(
	ctx context.Context,
	size int64,
	sendwithcache bool) dcSDK.RemoteWorker

NewCommonRemoteWorkerWithSlot get a new remote worker SDK with specifiled size of slot

func SendMessages

func SendMessages(client *TCPClient, messages []protocol.Message) error

Types

type CommonRemoteHandler

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

CommonRemoteHandler remote executor for bk-common

func (*CommonRemoteHandler) ExecuteCheckCache

func (r *CommonRemoteHandler) ExecuteCheckCache(
	server *dcProtocol.Host,
	req *dcSDK.BKDistFileSender,
	sandbox *syscall.Sandbox) ([]bool, error)

ExecuteCheckCache check file cache in remote worker

func (*CommonRemoteHandler) ExecuteCheckCacheLongTCP

func (r *CommonRemoteHandler) ExecuteCheckCacheLongTCP(
	server *dcProtocol.Host,
	req *dcSDK.BKDistFileSender,
	sandbox *syscall.Sandbox) ([]bool, error)

func (*CommonRemoteHandler) ExecuteQuerySlot

func (r *CommonRemoteHandler) ExecuteQuerySlot(
	server *dcProtocol.Host,
	req *dcSDK.BKQuerySlot,
	c chan *dcSDK.BKQuerySlotResult,
	timeout int) (*net.TCPConn, error)

ExecuteQuerySlot obtain available slot from remote worker timeout参数单独设置,这个地方比较特殊 TODO : 返回 tcp connection,方便业务在需要时关闭该连接

func (*CommonRemoteHandler) ExecuteSendFile

func (r *CommonRemoteHandler) ExecuteSendFile(
	server *dcProtocol.Host,
	req *dcSDK.BKDistFileSender,
	sandbox *syscall.Sandbox,
	mgr dcSDK.LockMgr) (*dcSDK.BKSendFileResult, error)

ExecuteSendFile send files to remote server

func (*CommonRemoteHandler) ExecuteSendFileLongTCP

func (r *CommonRemoteHandler) ExecuteSendFileLongTCP(
	server *dcProtocol.Host,
	req *dcSDK.BKDistFileSender,
	sandbox *syscall.Sandbox,
	mgr sdk.LockMgr) (*dcSDK.BKSendFileResult, error)

func (*CommonRemoteHandler) ExecuteSyncTime

func (r *CommonRemoteHandler) ExecuteSyncTime(server string) (int64, error)

ExecuteSyncTime get the target server's current timestamp

func (*CommonRemoteHandler) ExecuteSyncTimeLongTCP

func (r *CommonRemoteHandler) ExecuteSyncTimeLongTCP(server string) (int64, error)

func (*CommonRemoteHandler) ExecuteTask

func (r *CommonRemoteHandler) ExecuteTask(
	server *dcProtocol.Host,
	req *dcSDK.BKDistCommand) (*dcSDK.BKDistResult, error)

ExecuteTask do execution in remote and get back the result(and files)

func (*CommonRemoteHandler) ExecuteTaskLongTCP

func (r *CommonRemoteHandler) ExecuteTaskLongTCP(
	server *dcProtocol.Host,
	req *dcSDK.BKDistCommand) (*dcSDK.BKDistResult, error)

ExecuteTaskLongTCP same as ExecuteTask but with long tcp connection

func (*CommonRemoteHandler) ExecuteTaskWithoutSaveFile

func (r *CommonRemoteHandler) ExecuteTaskWithoutSaveFile(
	server *dcProtocol.Host,
	req *dcSDK.BKDistCommand) (*dcSDK.BKDistResult, error)

ExecuteTaskWithoutSaveFile same as ExecuteTask but do not write file to disk directly, the result file will be kept in memory and wait for custom process

func (*CommonRemoteHandler) ExecuteTaskWithoutSaveFileLongTCP

func (r *CommonRemoteHandler) ExecuteTaskWithoutSaveFileLongTCP(
	server *dcProtocol.Host,
	req *dcSDK.BKDistCommand) (*dcSDK.BKDistResult, error)

ExecuteTaskWithoutSaveFileLongTCP same as ExecuteTaskWithoutSaveFile but with long tcp connection

type RemoteWorker

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

RemoteWorker 作为链接管理单元, 通过实例化不同的handler来提供参数隔离的服务, 但最终的连接池都是用的同一个 TODO: 统一管理连接池

func (*RemoteWorker) Handler

func (rw *RemoteWorker) Handler(
	ioTimeout int,
	stats *dcSDK.ControllerJobStats,
	updateJobStatsFunc func(),
	sandbox *syscall.Sandbox) dcSDK.RemoteWorkerHandler

Handler get a remote handler

type TCPClient

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

TCPClient wrapper net.TCPConn

func NewTCPClient

func NewTCPClient(timeout int) *TCPClient

NewTCPClient return new TCPClient

func NewTCPClientWithConn

func NewTCPClientWithConn(conn *net.TCPConn) *TCPClient

NewTCPClientWithConn return new TCPClient with specified conn

func (*TCPClient) Close

func (c *TCPClient) Close() error

Close close conn

func (*TCPClient) ConnDesc

func (c *TCPClient) ConnDesc() string

ConnDesc return desc of conn

func (*TCPClient) Connect

func (c *TCPClient) Connect(server string) error

Connect connect to server

func (*TCPClient) ReadData

func (c *TCPClient) ReadData(expectlen int) ([]byte, int, error)

ReadData read data

func (*TCPClient) ReadUntilEOF

func (c *TCPClient) ReadUntilEOF() ([]byte, int, error)

ReadUntilEOF read data until EOF

func (*TCPClient) RemoteAddr

func (c *TCPClient) RemoteAddr() string

RemoteAddr return RemoteAddr

func (*TCPClient) RemoteIP

func (c *TCPClient) RemoteIP() string

RemoteIP return remote ip

func (*TCPClient) SendFile

func (c *TCPClient) SendFile(infile string, compress protocol.CompressType) error

SendFile send file

func (*TCPClient) TryReadData

func (c *TCPClient) TryReadData(expectlen int) ([]byte, int, error)

TryReadData try read data, return immediately after received any data

func (*TCPClient) WriteData

func (c *TCPClient) WriteData(data []byte) error

WriteData write data

Jump to

Keyboard shortcuts

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