[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

12
grpc.go
View File

@@ -38,8 +38,8 @@ type grpcClient struct {
funcStream client.FuncStream
pool *ConnPool
opts client.Options
sync.RWMutex
init bool
mu sync.RWMutex
init bool
}
// secure returns the dial option for whether its a secure or insecure connection
@@ -361,8 +361,8 @@ func (g *grpcClient) maxSendMsgSizeValue() int {
}
func (g *grpcClient) newCodec(ct string) (codec.Codec, error) {
g.RLock()
defer g.RUnlock()
g.mu.RLock()
defer g.mu.RUnlock()
if idx := strings.IndexRune(ct, ';'); idx >= 0 {
ct = ct[:idx]
@@ -398,10 +398,10 @@ func (g *grpcClient) Init(opts ...client.Option) error {
// update pool configuration if the options changed
if size != g.opts.PoolSize || ttl != g.opts.PoolTTL {
g.pool.Lock()
g.pool.mu.Lock()
g.pool.size = g.opts.PoolSize
g.pool.ttl = int64(g.opts.PoolTTL.Seconds())
g.pool.Unlock()
g.pool.mu.Unlock()
}
g.funcCall = g.fnCall