Documentation
¶
Index ¶
- func RunWorker(masterAddr string, addr string)
- type AverageArgs
- type AverageResult
- type Configuration
- type DoTaskArgs
- type GenerateArgs
- type Master
- func (master *Master) Average()
- func (master *Master) CloseWorkers()
- func (master *Master) Generate()
- func (master *Master) Median()
- func (master *Master) Register(args *RegisterArgs, _ *struct{}) error
- func (master *Master) Sort()
- func (master *Master) Unregister(args *UnregisterArgs, _ *struct{}) error
- type RegisterArgs
- type SortArgs
- type UnregisterArgs
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AverageResult ¶
AverageResult holds the result of average action
type Configuration ¶
Configuration save master and workers' configuration
type DoTaskArgs ¶
type DoTaskArgs struct {
JobName string
}
DoTaskArgs holds the arguments that are passed to a worker when a job is scheduled on it.
type GenerateArgs ¶
type GenerateArgs struct {
DoTaskArgs
Min, Max, Size int
}
GenerateArgs used for send generate request
type Master ¶
type Master struct {
// contains filtered or unexported fields
}
Master schedule tasks
func (*Master) Average ¶
func (master *Master) Average()
Average calculate the average of all pods' numbers
func (*Master) Generate ¶
func (master *Master) Generate()
Generate generate chunkSize numbers in each pod
func (*Master) Median ¶
func (master *Master) Median()
Median calculate the median of all pods' numbers
func (*Master) Register ¶
func (master *Master) Register(args *RegisterArgs, _ *struct{}) error
Register is an RPC method that is called by workers after they have started up to report that they are ready to receive tasks.
func (*Master) Sort ¶
func (master *Master) Sort()
Sort sort all the numbers, the results are stored in order on each workers
func (*Master) Unregister ¶
func (master *Master) Unregister(args *UnregisterArgs, _ *struct{}) error
Unregister is an RPC method that is called by workers to unregist themselfs
type RegisterArgs ¶
type RegisterArgs struct {
Worker string
}
RegisterArgs is the argument passed when a worker registers with the master.
type UnregisterArgs ¶
type UnregisterArgs struct {
Worker string
}
UnregisterArgs is the argument passed when a worker unregisters with the master.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker run task and communicationi with master
func (*Worker) Average ¶
func (wk *Worker) Average(arg *AverageArgs, res *AverageResult) error
Average api
func (*Worker) Generate ¶
func (wk *Worker) Generate(arg *GenerateArgs, _ *struct{}) error
Generate api