MCPcopy Create free account
hub / github.com/blobcache/blobcache / loop

Method loop

src/bcsdk/watcher.go:92–118  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

90}
91
92func (w *Watcher) loop(ctx context.Context) {
93 defer w.wg.Done()
94 defer close(w.out)
95
96 buf := make([]blobcache.Message, 1)
97 for {
98 n, err := w.svc.Dequeue(ctx, w.qh, buf, blobcache.DequeueOpts{Min: 1})
99 if err != nil {
100 return
101 }
102 if n == 0 {
103 continue
104 }
105 tx, err := BeginTx(ctx, w.svc, w.volh, blobcache.TxParams{
106 Modify: false,
107 })
108 if err != nil {
109 continue
110 }
111 select {
112 case w.out <- tx:
113 case <-ctx.Done():
114 tx.Abort(ctx)
115 return
116 }
117 }
118}

Callers 1

NewWatcherFunction · 0.95

Calls 3

BeginTxFunction · 0.70
DequeueMethod · 0.65
AbortMethod · 0.65

Tested by

no test coverage detected