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

Method tick

internal/queue/loop.go:45–66  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

43}
44
45func (p *Producer) tick(ctx context.Context) {
46 results := ping.QueryAll(p.Store.Snapshot())
47 if len(results) == 0 {
48 log.Warn("queue tick produced no ping results, skipping push")
49 return
50 }
51
52 payload := EncodeBatch(p.Source, results)
53
54 if err := p.Client.Push(ctx, payload); err != nil {
55 log.Warn("queue push failed, spooling batch", "err", err.Error(), "pings", len(results))
56 if path, werr := p.Spool.Write(payload); werr != nil {
57 log.Error("failed to spool batch", "err", werr.Error())
58 } else {
59 log.Info("spooled batch", "path", path)
60 }
61 return
62 }
63 log.Info("pushed batch", "pings", len(results))
64
65 p.drain(ctx)
66}
67
68func (p *Producer) drain(ctx context.Context) {
69 paths, err := p.Spool.List()

Callers 1

RunMethod · 0.95

Calls 6

drainMethod · 0.95
QueryAllFunction · 0.92
EncodeBatchFunction · 0.85
SnapshotMethod · 0.80
PushMethod · 0.80
WriteMethod · 0.80

Tested by

no test coverage detected