Fetch defines entry for missing log startFetch.
(ctx context.Context, index uint64)
| 330 | |
| 331 | // Fetch defines entry for missing log startFetch. |
| 332 | func (r *Runtime) Fetch(ctx context.Context, index uint64) (l *kt.Log, err error) { |
| 333 | if atomic.LoadUint32(&r.started) != 1 { |
| 334 | err = kt.ErrStopped |
| 335 | return |
| 336 | } |
| 337 | |
| 338 | tm := timer.NewTimer() |
| 339 | |
| 340 | defer func() { |
| 341 | log.WithField("l", index). |
| 342 | WithFields(tm.ToLogFields()). |
| 343 | WithError(err). |
| 344 | Debug("kayak log startFetch") |
| 345 | }() |
| 346 | |
| 347 | r.peersLock.RLock() |
| 348 | defer r.peersLock.RUnlock() |
| 349 | |
| 350 | tm.Add("peers_lock") |
| 351 | |
| 352 | if r.role != proto.Leader { |
| 353 | // not leader |
| 354 | err = kt.ErrNotLeader |
| 355 | return |
| 356 | } |
| 357 | |
| 358 | // wal get |
| 359 | return r.wal.Get(index) |
| 360 | } |
| 361 | |
| 362 | // FollowerApply defines entry for follower node. |
| 363 | func (r *Runtime) FollowerApply(l *kt.Log) (err error) { |
nothing calls this directly
no test coverage detected