mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #8283 from heyitsanthony/cancel-compact-rpc
v3rpc: set Canceled=true on compacted watch
This commit is contained in:
commit
16943f04e2
@ -514,6 +514,9 @@ func TestWatchCompactRevision(t *testing.T) {
|
|||||||
if wresp.Err() != rpctypes.ErrCompacted {
|
if wresp.Err() != rpctypes.ErrCompacted {
|
||||||
t.Fatalf("wresp.Err() expected %v, but got %v", rpctypes.ErrCompacted, wresp.Err())
|
t.Fatalf("wresp.Err() expected %v, but got %v", rpctypes.ErrCompacted, wresp.Err())
|
||||||
}
|
}
|
||||||
|
if !wresp.Canceled {
|
||||||
|
t.Fatalf("wresp.Canceled expected true, got %+v", wresp)
|
||||||
|
}
|
||||||
|
|
||||||
// ensure the channel is closed
|
// ensure the channel is closed
|
||||||
if wresp, ok = <-wch; ok {
|
if wresp, ok = <-wch; ok {
|
||||||
|
@ -461,7 +461,7 @@ func (w *watchGrpcStream) run() {
|
|||||||
if ws := w.nextResume(); ws != nil {
|
if ws := w.nextResume(); ws != nil {
|
||||||
wc.Send(ws.initReq.toPB())
|
wc.Send(ws.initReq.toPB())
|
||||||
}
|
}
|
||||||
case pbresp.Canceled:
|
case pbresp.Canceled && pbresp.CompactRevision == 0:
|
||||||
delete(cancelSet, pbresp.WatchId)
|
delete(cancelSet, pbresp.WatchId)
|
||||||
if ws, ok := w.substreams[pbresp.WatchId]; ok {
|
if ws, ok := w.substreams[pbresp.WatchId]; ok {
|
||||||
// signal to stream goroutine to update closingc
|
// signal to stream goroutine to update closingc
|
||||||
|
@ -321,11 +321,13 @@ func (sws *serverWatchStream) sendLoop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canceled := wresp.CompactRevision != 0
|
||||||
wr := &pb.WatchResponse{
|
wr := &pb.WatchResponse{
|
||||||
Header: sws.newResponseHeader(wresp.Revision),
|
Header: sws.newResponseHeader(wresp.Revision),
|
||||||
WatchId: int64(wresp.WatchID),
|
WatchId: int64(wresp.WatchID),
|
||||||
Events: events,
|
Events: events,
|
||||||
CompactRevision: wresp.CompactRevision,
|
CompactRevision: wresp.CompactRevision,
|
||||||
|
Canceled: canceled,
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, hasId := ids[wresp.WatchID]; !hasId {
|
if _, hasId := ids[wresp.WatchID]; !hasId {
|
||||||
|
@ -111,6 +111,7 @@ func (w *watcher) send(wr clientv3.WatchResponse) {
|
|||||||
Header: &wr.Header,
|
Header: &wr.Header,
|
||||||
Created: wr.Created,
|
Created: wr.Created,
|
||||||
CompactRevision: wr.CompactRevision,
|
CompactRevision: wr.CompactRevision,
|
||||||
|
Canceled: wr.Canceled,
|
||||||
WatchId: w.id,
|
WatchId: w.id,
|
||||||
Events: events,
|
Events: events,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user