(ctx context.Context, tm *timer.Timer, reqPayload interface{}, prepareLog *kt.Log)
| 30 | ) |
| 31 | |
| 32 | func (r *Runtime) leaderCommitResult(ctx context.Context, tm *timer.Timer, reqPayload interface{}, prepareLog *kt.Log) (res *commitFuture) { |
| 33 | defer trace.StartRegion(ctx, "leaderCommitResult").End() |
| 34 | |
| 35 | // decode log and send to commit channel to process |
| 36 | res = newCommitFuture() |
| 37 | |
| 38 | if prepareLog == nil { |
| 39 | res.Set(&commitResult{err: errors.Wrap(kt.ErrInvalidLog, "nil prepare log in commit")}) |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | // decode prepare log |
| 44 | req := &commitReq{ |
| 45 | ctx: ctx, |
| 46 | data: reqPayload, |
| 47 | index: prepareLog.Index, |
| 48 | result: res, |
| 49 | tm: tm, |
| 50 | } |
| 51 | |
| 52 | select { |
| 53 | case <-ctx.Done(): |
| 54 | res = nil |
| 55 | case r.commitCh <- req: |
| 56 | } |
| 57 | |
| 58 | return |
| 59 | } |
| 60 | |
| 61 | func (r *Runtime) followerCommitResult(ctx context.Context, tm *timer.Timer, commitLog *kt.Log, prepareLog *kt.Log, lastCommit uint64) (res *commitFuture) { |
| 62 | defer trace.StartRegion(ctx, "followerCommitResult").End() |
no test coverage detected