ReplayWithContext replays a write log from other peer to replicate storage state with context.
( ctx context.Context, req *types.Request, resp *types.Response)
| 708 | |
| 709 | // ReplayWithContext replays a write log from other peer to replicate storage state with context. |
| 710 | func (s *State) ReplayWithContext( |
| 711 | ctx context.Context, req *types.Request, resp *types.Response) (err error, |
| 712 | ) { |
| 713 | // NOTE(leventeliu): in the current implementation, failed requests are not tracked in remote |
| 714 | // nodes (while replaying via Replay calls). Because we don't want to actually replay read |
| 715 | // queries in all synchronized nodes, meanwhile, whether a request will fail or not |
| 716 | // remains unknown until we actually replay it -- a dead end here. |
| 717 | // So we just keep failed requests in local pool and report them in the next local block |
| 718 | // producing. |
| 719 | switch req.Header.QueryType { |
| 720 | case types.ReadQuery: |
| 721 | return |
| 722 | case types.WriteQuery: |
| 723 | return s.replay(ctx, req, resp) |
| 724 | default: |
| 725 | err = ErrInvalidRequest |
| 726 | } |
| 727 | return |
| 728 | } |
| 729 | |
| 730 | // Stat prints the statistic message of the State object. |
| 731 | func (s *State) Stat(id proto.DatabaseID) { |