MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / waitForLog

Method waitForLog

kayak/waiter.go:153–185  ·  view source on GitHub ↗
(ctx context.Context, index uint64)

Source from the content-addressed store, hash-verified

151}
152
153func (r *Runtime) waitForLog(ctx context.Context, index uint64) (l *kt.Log, err error) {
154 defer trace.StartRegion(ctx, "waitForLog").End()
155
156 if l, err = r.wal.Get(index); err == nil {
157 // exists
158 return
159 }
160
161 rawItem, _ := r.waitLogMap.LoadOrStore(index, newWaitItem(r, index))
162 item := rawItem.(*waitItem)
163
164 if item == nil {
165 err = kt.ErrInvalidLog
166 return
167 }
168
169 item.startFetch()
170
171 select {
172 case <-item.waitCh:
173 l = item.get()
174 if l != nil {
175 err = nil
176 } else {
177 err = errors.Wrapf(kt.ErrInvalidLog, "could not fetch log %d", index)
178 }
179 r.waitLogMap.Delete(index)
180 case <-ctx.Done():
181 err = ctx.Err()
182 }
183
184 return
185}
186
187func (r *Runtime) triggerLogAwaits(l *kt.Log) {
188 rawItem, ok := r.waitLogMap.Load(l.Index)

Callers 2

followerDoCommitMethod · 0.95
getPrepareLogMethod · 0.95

Calls 7

StartRegionFunction · 0.92
newWaitItemFunction · 0.85
startFetchMethod · 0.80
DeleteMethod · 0.80
GetMethod · 0.65
EndMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected