forked from TrueCloudLab/frostfs-node
[#1456] morph: Use DialerSource interface instead of internal struct
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
433aab12bb
commit
d5ee6d3039
1 changed files with 14 additions and 3 deletions
|
@ -4,11 +4,11 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/metrics"
|
||||
internalNet "git.frostfs.info/TrueCloudLab/frostfs-node/internal/net"
|
||||
morphmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/metrics"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
lru "github.com/hashicorp/golang-lru/v2"
|
||||
|
@ -48,7 +48,7 @@ type cfg struct {
|
|||
|
||||
morphCacheMetrics metrics.MorphCacheMetrics
|
||||
|
||||
dialerSource *internalNet.DialerSource
|
||||
dialerSource DialerSource
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -68,6 +68,7 @@ func defaultConfig() *cfg {
|
|||
Scopes: transaction.Global,
|
||||
},
|
||||
morphCacheMetrics: &morphmetrics.NoopMorphCacheMetrics{},
|
||||
dialerSource: &noopDialerSource{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,17 @@ func WithMorphCacheMetrics(morphCacheMetrics metrics.MorphCacheMetrics) Option {
|
|||
}
|
||||
}
|
||||
|
||||
func WithDialerSource(ds *internalNet.DialerSource) Option {
|
||||
type DialerSource interface {
|
||||
NetContextDialer() func(context.Context, string, string) (net.Conn, error)
|
||||
}
|
||||
|
||||
type noopDialerSource struct{}
|
||||
|
||||
func (ds *noopDialerSource) NetContextDialer() func(context.Context, string, string) (net.Conn, error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func WithDialerSource(ds DialerSource) Option {
|
||||
return func(c *cfg) {
|
||||
c.dialerSource = ds
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue