MCPcopy Create free account
hub / github.com/clrxbl/blockgametracker / Run

Method Run

internal/queue/loop.go:26–43  ·  view source on GitHub ↗

Run blocks until ctx is cancelled. Each tick pings all enabled servers, pushes the batch, and (on success) drains up to DrainPerTick spooled batches in age order. On push failure the batch is written to the spool so it survives restarts.

(ctx context.Context)

Source from the content-addressed store, hash-verified

24// batches in age order. On push failure the batch is written to the spool
25// so it survives restarts.
26func (p *Producer) Run(ctx context.Context) {
27 if existing, err := p.Spool.List(); err == nil && len(existing) > 0 {
28 log.Warn("spool contains batches from previous run", "count", len(existing))
29 }
30
31 ticker := time.NewTicker(p.Interval)
32 defer ticker.Stop()
33
34 p.tick(ctx)
35 for {
36 select {
37 case <-ctx.Done():
38 return
39 case <-ticker.C:
40 p.tick(ctx)
41 }
42 }
43}
44
45func (p *Producer) tick(ctx context.Context) {
46 results := ping.QueryAll(p.Store.Snapshot())

Callers 1

mainFunction · 0.80

Calls 2

tickMethod · 0.95
ListMethod · 0.80

Tested by

no test coverage detected