Remove context.TODO() (#310)
Remove almost all (except the ones created by informer-gen) context.TODOs. Signed-off-by: leonnicolas <leonloechner@gmx.de>
This commit is contained in:
		| @@ -15,6 +15,7 @@ | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| @@ -275,15 +276,16 @@ func runRoot(_ *cobra.Command, _ []string) error { | ||||
| 	} | ||||
|  | ||||
| 	{ | ||||
| 		ctx, cancel := context.WithCancel(context.Background()) | ||||
| 		// Start the mesh. | ||||
| 		g.Add(func() error { | ||||
| 			logger.Log("msg", fmt.Sprintf("Starting Kilo network mesh '%v'.", version.Version)) | ||||
| 			if err := m.Run(); err != nil { | ||||
| 			if err := m.Run(ctx); err != nil { | ||||
| 				return fmt.Errorf("error: Kilo exited unexpectedly: %v", err) | ||||
| 			} | ||||
| 			return nil | ||||
| 		}, func(error) { | ||||
| 			m.Stop() | ||||
| 			cancel() | ||||
| 		}) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -71,7 +71,7 @@ var ( | ||||
| 	topologyLabel string | ||||
| ) | ||||
|  | ||||
| func runRoot(_ *cobra.Command, _ []string) error { | ||||
| func runRoot(c *cobra.Command, _ []string) error { | ||||
| 	if opts.port < 1 || opts.port > 1<<16-1 { | ||||
| 		return fmt.Errorf("invalid port: port mus be in range [%d:%d], but got %d", 1, 1<<16-1, opts.port) | ||||
| 	} | ||||
| @@ -99,11 +99,11 @@ func runRoot(_ *cobra.Command, _ []string) error { | ||||
| 		return fmt.Errorf("backend %s unknown; posible values are: %s", backend, availableBackends) | ||||
| 	} | ||||
|  | ||||
| 	if err := opts.backend.Nodes().Init(make(chan struct{})); err != nil { | ||||
| 	if err := opts.backend.Nodes().Init(c.Context()); err != nil { | ||||
| 		return fmt.Errorf("failed to initialize node backend: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	if err := opts.backend.Peers().Init(make(chan struct{})); err != nil { | ||||
| 	if err := opts.backend.Peers().Init(c.Context()); err != nil { | ||||
| 		return fmt.Errorf("failed to initialize peer backend: %w", err) | ||||
| 	} | ||||
| 	return nil | ||||
|   | ||||
		Reference in New Issue
	
	Block a user