cluster

package
v0.0.0-...-ebe581b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mpc

type Mpc interface {
	Predict(*pb.PredictRequest) (*pb.PredictResponse, error)
	Train(*pb.TrainRequest) (*pb.TrainResponse, error)
}

Mpc is used to handle requests for training and prediction

type P2P

type P2P interface {
	GetPeer(address string) (*p2p.Peer, error)
	FreePeer()
}

P2P is used to get rpc connection to remote cluster nodes, remember to call FreePeer() when rpc requests finish

type PredictHandler

type PredictHandler interface {
	StepPredict(req *pb.PredictRequest, peerName string) (*pb.PredictResponse, error)

	// StepPredictWithRetry sends prediction message to remote mpc-node
	// retries 2 times at most
	// inteSec indicates the interval between retry requests, in seconds
	StepPredictWithRetry(req *pb.PredictRequest, peerName string, times int, inteSec int64) (*pb.PredictResponse, error)
}

type Rpc

type Rpc interface {
	PredictHandler
	TrainHandler
}

Rpc performs remote procedure calls to remote cluster nodes.

PredictHandler could be called during prediction
TrainHandler could be called during training

func NewRpcClient

func NewRpcClient(clu P2P, timeout time.Duration) Rpc

NewRpcClient returns RpcClient instance timeout eg. 3*time.Second connection releases when timeout elapses

type RpcClient

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

RpcClient implements Rpc interface,

performs remote procedure calls to remote cluster nodes.

func (*RpcClient) StepPredict

func (rc *RpcClient) StepPredict(req *pb.PredictRequest, peerName string) (*pb.PredictResponse, error)

func (*RpcClient) StepPredictWithRetry

func (rc *RpcClient) StepPredictWithRetry(req *pb.PredictRequest, peerName string, times int, inteSec int64) (*pb.PredictResponse, error)

StepPredictWithRetry sends prediction message to remote mpc-node retries 2 times at most inteSec indicates the interval between retry requests, in seconds

func (*RpcClient) StepTrain

func (rc *RpcClient) StepTrain(req *pb.TrainRequest, peerName string) (*pb.TrainResponse, error)

func (*RpcClient) StepTrainWithRetry

func (rc *RpcClient) StepTrainWithRetry(req *pb.TrainRequest, peerName string, times int, inteSec int64) (*pb.TrainResponse, error)

StepTrainWithRetry sends training message to remote mpc-node retries 2 times at most inteSec indicates the interval between retry requests, in seconds

type Service

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

Service is implementation for mpc.Cluster

func NewService

func NewService(m Mpc) *Service

NewService to create a Service instance

func (*Service) RegisterClusterServer

func (s *Service) RegisterClusterServer(grpcServer *grpc.Server)

RegisterClusterServer to register mpc.cluster.Service to grpcServer

func (*Service) Step

func (s *Service) Step(ctx context.Context, in *pb.StepRequest) (resp *pb.StepResponse, err error)

Step @implementation mpc.Cluster.Step

type TrainHandler

type TrainHandler interface {
	StepTrain(req *pb.TrainRequest, peerName string) (*pb.TrainResponse, error)

	// StepTrainWithRetry sends training message to remote mpc-node
	// retries 2 times at most
	// inteSec indicates the interval between retry requests, in seconds
	StepTrainWithRetry(req *pb.TrainRequest, peerName string, times int, inteSec int64) (*pb.TrainResponse, error)
}

Jump to

Keyboard shortcuts

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