(ctx context.Context, wg *sync.WaitGroup, errch chan error)
| 67 | } |
| 68 | |
| 69 | func (g *MapGenerator) Run(ctx context.Context, wg *sync.WaitGroup, errch chan error) { |
| 70 | defer log.Debug("mapgenerator: exit") |
| 71 | |
| 72 | defer wg.Done() |
| 73 | wg.Add(1) |
| 74 | |
| 75 | events := g.updates.Subscribe("mapgenerator", func(u Update) bool { |
| 76 | return u.IsFresh |
| 77 | }) |
| 78 | defer g.updates.Unsubscribe(events) |
| 79 | |
| 80 | for { |
| 81 | select { |
| 82 | case event, ok := <-events: |
| 83 | if !ok { |
| 84 | return |
| 85 | } |
| 86 | |
| 87 | if !event.IsLast { |
| 88 | continue |
| 89 | } |
| 90 | |
| 91 | if err := g.GenerateMap(g.updaterState, "", true); err != nil { |
| 92 | errch <- fmt.Errorf("mapgenerator: regenerate map: %w", err) |
| 93 | |
| 94 | return |
| 95 | } |
| 96 | case <-ctx.Done(): |
| 97 | return |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | func (g *MapGenerator) GenerateMap(updaterState *UpdaterState, title string, transparent bool) error { |
| 103 | stateAlerts := map[int]bool{} |
no test coverage detected