Skip to content

Commit

Permalink
make subscribe channel send map rather than a reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
nullfunc committed Jun 19, 2024
1 parent 9511b3d commit 795605e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cmd/cli/command/servicemonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func waitServiceStatus(ctx context.Context, targetStatus cli.ServiceStatus, serv

// monitor for when all services are completed to end this command
for serviceStatus := range serviceStatusChan {
if allInStatus(targetStatus, *serviceStatus) {
if allInStatus(targetStatus, serviceStatus) {
for _, sInfo := range serviceInfos {
sInfo.Status = string(targetStatus)
}
Expand Down
6 changes: 3 additions & 3 deletions src/pkg/cli/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
defangv1 "github.com/DefangLabs/defang/src/protos/io/defang/v1"
)

func Subscribe(ctx context.Context, client client.Client, services []string) (<-chan *map[string]string, error) {
func Subscribe(ctx context.Context, client client.Client, services []string) (<-chan map[string]string, error) {
if len(services) == 0 {
return nil, fmt.Errorf("no services specified")
}
Expand All @@ -23,7 +23,7 @@ func Subscribe(ctx context.Context, client client.Client, services []string) (<-
serviceStatus[service] = string(ServiceUnknown)
}

statusChan := make(chan *map[string]string, len(services))
statusChan := make(chan map[string]string, len(services))
if DoDryRun {
defer close(statusChan)
return statusChan, ErrDryRun
Expand Down Expand Up @@ -72,7 +72,7 @@ func Subscribe(ctx context.Context, client client.Client, services []string) (<-
//make a copy to be put into channel
serviceStatusCopy := cloneServiceStatus(serviceStatus)

statusChan <- &serviceStatusCopy
statusChan <- serviceStatusCopy
term.Debugf("service %s with status %s\n", serviceName, servInfo.Status)
}
}()
Expand Down

0 comments on commit 795605e

Please sign in to comment.