[v4] hide access to internal mutex (#193)
All checks were successful
test / test (push) Successful in 2m51s
coverage / build (push) Successful in 46s
sync / sync (push) Successful in 10s

* changed embedded mutex to private field

* changed embedded mutex to private field
This commit is contained in:
2025-05-25 03:14:55 +05:00
committed by GitHub
parent 52bbed93c4
commit 372bb37779
3 changed files with 26 additions and 26 deletions

View File

@@ -19,8 +19,8 @@ type grpcStream struct {
response client.Response
close func(err error)
conn *PoolConn
sync.RWMutex
closed bool
mu sync.RWMutex
closed bool
}
func (g *grpcStream) Context() context.Context {
@@ -88,15 +88,15 @@ func (g *grpcStream) RecvMsg(msg interface{}) (err error) {
}
func (g *grpcStream) Error() error {
g.RLock()
defer g.RUnlock()
g.mu.RLock()
defer g.mu.RUnlock()
return g.err
}
func (g *grpcStream) setError(e error) {
g.Lock()
g.mu.Lock()
g.err = e
g.Unlock()
g.mu.Unlock()
}
// Close the gRPC send stream
@@ -105,8 +105,8 @@ func (g *grpcStream) setError(e error) {
// stream should still be able to receive after this function call
// TODO: should the conn be closed in another way?
func (g *grpcStream) Close() error {
g.Lock()
defer g.Unlock()
g.mu.Lock()
defer g.mu.Unlock()
if g.closed {
return nil
@@ -125,8 +125,8 @@ func (g *grpcStream) Close() error {
}
func (g *grpcStream) CloseSend() error {
g.Lock()
defer g.Unlock()
g.mu.Lock()
defer g.mu.Unlock()
if g.closed {
return nil