-
Notifications
You must be signed in to change notification settings - Fork 8
Rename Worker in master package to WorkerClient #10
base: master
Are you sure you want to change the base?
Conversation
BTW, the edit on go.sum and go.mod is automatically improved by GoLand. so I think those changes should be okay. Let me know if they should not be there. |
master/master.go
Outdated
// process the current site there is idle worker | ||
worker := <-m.idleWorkers | ||
// process the current site there is idle workerClients | ||
worker := <-m.idleWorkerClients |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worker := <-m.idleWorkerClients | |
workerClient := <-m.idleWorkers |
master/server.go
Outdated
workerID := s.master.RegisterWorker(worker) | ||
fmt.Printf("Worker registed: ID(%d) IP(%s) PORT(%d) SECRET(%s)\n", workerID, request.Ip, int(request.Port), request.Secret) | ||
workerID := s.master.RegisterWorker(workerClient) | ||
fmt.Printf("WorkerClient registed: ID(%d) IP(%s) PORT(%d) SECRET(%s)\n", workerID, request.Ip, int(request.Port), request.Secret) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Printf("WorkerClient registed: ID(%d) IP(%s) PORT(%d) SECRET(%s)\n", workerID, request.Ip, int(request.Port), request.Secret) | |
fmt.Printf("Worker registered: ID(%d) IP(%s) PORT(%d) SECRET(%s)\n", workerID, request.Ip, int(request.Port), request.Secret) |
master/master.go
Outdated
workerClients []WorkerClient | ||
idleWorkerClients chan WorkerClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workerClients []WorkerClient | |
idleWorkerClients chan WorkerClient | |
workers []WorkerClient | |
idleWorkers chan WorkerClient |
Thank you making the changes. I feel calling them workers is more natural in this code. You may disagree though.
master/master.go
Outdated
@@ -46,11 +46,11 @@ func (m *Master) ExploreWebsite(ctx context.Context, siteURL string) { | |||
} | |||
case link := <-linkCh: | |||
go func(link string) { | |||
// process the current site there is idle worker | |||
worker := <-m.idleWorkers | |||
// process the current site there is idle workerClients |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// process the current site there is idle workerClients | |
// process the current site there is idle worker |
master/master.go
Outdated
err := worker.FetchLinks(ctx, link) | ||
if err != nil { | ||
m.idleWorkers <- worker | ||
m.idleWorkerClients <- worker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m.idleWorkerClients <- worker | |
m.idleWorkers <- worker |
master/master.go
Outdated
@@ -62,21 +62,21 @@ func (m *Master) ExploreWebsite(ctx context.Context, siteURL string) { | |||
func (m *Master) FinishExtractingLinks(workerID int, links []string) { | |||
m.linksCh <- links | |||
go func() { | |||
m.idleWorkers <- m.workers[workerID] | |||
m.idleWorkerClients <- m.workerClients[workerID] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m.idleWorkerClients <- m.workerClients[workerID] | |
m.idleWorkers <- m.workers[workerID] |
master/master.go
Outdated
func (m *Master) RegisterWorker(worker Worker) int { | ||
workID := len(m.workers) | ||
m.workers = append(m.workers, worker) | ||
func (m *Master) RegisterWorker(workerClient WorkerClient) int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (m *Master) RegisterWorker(workerClient WorkerClient) int { | |
func (m *Master) RegisterWorker(worker WorkerClient) int { |
@eugeneYWang Sounds good! |
suggested changes were applied. Does it look good? |
This time it should be right.