QueryWithContext does the query(ies) in req, pools the request and persists any change to the underlying storage.
( ctx context.Context, req *types.Request, isLeader bool)
| 688 | // QueryWithContext does the query(ies) in req, pools the request and persists any change to |
| 689 | // the underlying storage. |
| 690 | func (s *State) QueryWithContext( |
| 691 | ctx context.Context, req *types.Request, isLeader bool) (ref *QueryTracker, resp *types.Response, err error, |
| 692 | ) { |
| 693 | switch req.Header.QueryType { |
| 694 | case types.ReadQuery: |
| 695 | return s.readTx(ctx, req) |
| 696 | case types.WriteQuery: |
| 697 | return s.write(ctx, req, isLeader) |
| 698 | default: |
| 699 | err = ErrInvalidRequest |
| 700 | } |
| 701 | return |
| 702 | } |
| 703 | |
| 704 | // Replay replays a write log from other peer to replicate storage state. |
| 705 | func (s *State) Replay(req *types.Request, resp *types.Response) (err error) { |