diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-09-09 12:07:15 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-09-09 12:07:15 -0700 |
| commit | daf0a449f7424d4a8252673509af5afd0b9bd8ec (patch) | |
| tree | e9b9ba152b2fade26b71e7710ae6730dafe9d39e /weed/operation/tail_volume.go | |
| parent | 7f69acd1f21b4e42afff155b633419eda17af331 (diff) | |
| download | seaweedfs-daf0a449f7424d4a8252673509af5afd0b9bd8ec.tar.xz seaweedfs-daf0a449f7424d4a8252673509af5afd0b9bd8ec.zip | |
properly cancel context for streaming grpc
Diffstat (limited to 'weed/operation/tail_volume.go')
| -rw-r--r-- | weed/operation/tail_volume.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/weed/operation/tail_volume.go b/weed/operation/tail_volume.go index 3cd66b5da..a15c21ae4 100644 --- a/weed/operation/tail_volume.go +++ b/weed/operation/tail_volume.go @@ -28,8 +28,10 @@ func TailVolume(master string, grpcDialOption grpc.DialOption, vid needle.Volume func TailVolumeFromSource(volumeServer string, grpcDialOption grpc.DialOption, vid needle.VolumeId, sinceNs uint64, idleTimeoutSeconds int, fn func(n *needle.Needle) error) error { return WithVolumeServerClient(volumeServer, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() - stream, err := client.VolumeTailSender(context.Background(), &volume_server_pb.VolumeTailSenderRequest{ + stream, err := client.VolumeTailSender(ctx, &volume_server_pb.VolumeTailSenderRequest{ VolumeId: uint32(vid), SinceNs: sinceNs, IdleTimeoutSeconds: uint32(idleTimeoutSeconds), |
