workerrpc

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// SendRequest sends Request
	SendRequest(ctx context.Context, req *Request, timeout time.Duration) (*Response, error)

	// Cloase close client and releases all data
	Close() error
}

Client is a client that sends RPC. It should not be used after calling Close().

type CmdType

type CmdType uint16

CmdType represents the concrete request type in Request or response type in Response.

const (
	CmdStartSubTask CmdType = 1 + iota
	CmdOperateSubTask
	CmdUpdateSubTask

	CmdQueryStatus
	CmdQueryError
	CmdQueryTaskOperation
	CmdQueryWorkerConfig

	CmdHandleSubTaskSQLs
	CmdExecDDL
	CmdBreakDDLLock

	CmdSwitchRelayMaster
	CmdOperateRelay
	CmdPurgeRelay
	CmdUpdateRelay
	CmdMigrateRelay

	CmdFetchDDLInfo
)

CmdType values.

type GRPCClient

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

GRPCClient stores raw grpc connection and worker client

func NewGRPCClient

func NewGRPCClient(addr string) (*GRPCClient, error)

NewGRPCClient initializes a new grpc client from worker address

func NewGRPCClientWrap

func NewGRPCClientWrap(conn *grpc.ClientConn, client pb.WorkerClient) (*GRPCClient, error)

NewGRPCClientWrap initializes a new grpc client from given grpc connection and worker client

func (*GRPCClient) Close

func (c *GRPCClient) Close() error

Close implements Client.Close

func (*GRPCClient) SendRequest

func (c *GRPCClient) SendRequest(ctx context.Context, req *Request, timeout time.Duration) (*Response, error)

SendRequest implements Client.SendRequest

type Request

type Request struct {
	Type CmdType

	StartSubTask   *pb.StartSubTaskRequest
	OperateSubTask *pb.OperateSubTaskRequest
	UpdateSubTask  *pb.UpdateSubTaskRequest

	QueryStatus        *pb.QueryStatusRequest
	QueryError         *pb.QueryErrorRequest
	QueryTaskOperation *pb.QueryTaskOperationRequest
	QueryWorkerConfig  *pb.QueryWorkerConfigRequest

	HandleSubTaskSQLs *pb.HandleSubTaskSQLsRequest
	ExecDDL           *pb.ExecDDLRequest
	BreakDDLLock      *pb.BreakDDLLockRequest

	SwitchRelayMaster *pb.SwitchRelayMasterRequest
	OperateRelay      *pb.OperateRelayRequest
	PurgeRelay        *pb.PurgeRelayRequest
	UpdateRelay       *pb.UpdateRelayRequest
	MigrateRelay      *pb.MigrateRelayRequest
}

Request wraps all dm-worker rpc requests.

func (*Request) IsStreamAPI

func (req *Request) IsStreamAPI() bool

IsStreamAPI checks whether a request is streaming API based on CmdType

type Response

type Response struct {
	Type CmdType

	StartSubTask   *pb.OperateSubTaskResponse
	OperateSubTask *pb.OperateSubTaskResponse
	UpdateSubTask  *pb.OperateSubTaskResponse

	QueryStatus        *pb.QueryStatusResponse
	QueryError         *pb.QueryErrorResponse
	QueryTaskOperation *pb.QueryTaskOperationResponse
	QueryWorkerConfig  *pb.QueryWorkerConfigResponse

	HandleSubTaskSQLs *pb.CommonWorkerResponse
	ExecDDL           *pb.CommonWorkerResponse
	BreakDDLLock      *pb.CommonWorkerResponse

	SwitchRelayMaster *pb.CommonWorkerResponse
	OperateRelay      *pb.OperateRelayResponse
	PurgeRelay        *pb.CommonWorkerResponse
	UpdateRelay       *pb.CommonWorkerResponse
	MigrateRelay      *pb.CommonWorkerResponse

	FetchDDLInfo pb.Worker_FetchDDLInfoClient
}

Response wraps all dm-worker rpc responses.

Jump to

Keyboard shortcuts

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