Skip to content

Commit

Permalink
fix: move handleBubbledPanic and ctx to root
Browse files Browse the repository at this point in the history
  • Loading branch information
benwaples committed Mar 19, 2024
1 parent 79c0e8a commit 285841e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions cmd/list-root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ func listCmdImpl(cmd *cobra.Command, args []string) {
}

func listAll(ctx context.Context, client client.AzureClient, panicChan chan error) <-chan interface{} {
ctx, stop := context.WithCancel(ctx)

var (
azureAD = listAllAD(ctx, client, panicChan)
azureRM = listAllRM(ctx, client, panicChan)
)

handleBubbledPanic(ctx, panicChan, stop)

return pipeline.Mux(ctx.Done(), azureAD, azureRM)
}
3 changes: 3 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ func start(ctx context.Context) {

start := time.Now()

ctx, stop := context.WithCancel(ctx)
handleBubbledPanic(ctx, panicChan, stop)

// Batch data out for ingestion
stream := listAll(ctx, azClient, panicChan)
batches := pipeline.Batch(ctx.Done(), stream, 256, 10*time.Second)
Expand Down
1 change: 0 additions & 1 deletion cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func panicChan() chan error {
// handleBubbledPanic receives errors from panicChan, then it will print them and stop() context.
func handleBubbledPanic(ctx context.Context, panicChan chan error, stop context.CancelFunc) {
go func() {

for {
select {
case err := <-panicChan:
Expand Down

0 comments on commit 285841e

Please sign in to comment.