Skip to content

Commit 312beca

Browse files
committed
feat: migrate to immediate processing
1 parent 45881a4 commit 312beca

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Diff for: cmd/format/format.go

+3
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ func Run(v *viper.Viper, statz *stats.Stats, cmd *cobra.Command, paths []string)
183183
if errors.Is(err, io.EOF) {
184184
// we have finished traversing
185185
break
186+
} else if errors.Is(err, context.DeadlineExceeded) && cfg.Watch {
187+
// we timed out reading files, try again
188+
continue
186189
} else if err != nil {
187190
// something went wrong
188191
return fmt.Errorf("failed to read files: %w", err)

Diff for: format/composite.go

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ func (c *CompositeFormatter) Apply(ctx context.Context, files []*walk.File) erro
107107
}
108108
}
109109

110+
c.scheduler.apply(ctx)
111+
110112
return nil
111113
}
112114

Diff for: format/scheduler.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,16 @@ func (s *scheduler) schedule(ctx context.Context, key batchKey, batch []*walk.Fi
203203
})
204204
}
205205

206-
func (s *scheduler) close(ctx context.Context) error {
206+
func (s *scheduler) apply(ctx context.Context) {
207207
// schedule any partial batches that remain
208208
for key, batch := range s.batches {
209209
if len(batch) > 0 {
210210
s.schedule(ctx, key, batch)
211211
}
212212
}
213+
}
213214

215+
func (s *scheduler) close(ctx context.Context) error {
214216
// wait for processing to complete
215217
if err := s.eg.Wait(); err != nil {
216218
return fmt.Errorf("failed to wait for formatters: %w", err)

0 commit comments

Comments
 (0)