32 lines
510 B
Go
32 lines
510 B
Go
package blob
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type CloseReaderArgs struct {
|
|
ReaderID ReaderID
|
|
}
|
|
|
|
type CloseReaderReply struct {
|
|
}
|
|
|
|
func (s *Service) CloseReader(ctx context.Context, args *CloseReaderArgs, reply *CloseReaderReply) error {
|
|
reader, err := s.getOpenedReader(args.ReaderID)
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
if err := reader.Close(); err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
s.readers.Delete(args.ReaderID)
|
|
|
|
*reply = CloseReaderReply{}
|
|
|
|
return nil
|
|
}
|