Skip to content

Commit c6dd605

Browse files
ealekseev123KaymeKaydex
authored andcommitted
Add ability to use custom dialer
1 parent 6ff0df4 commit c6dd605

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGES:
66
* Bump go-tarantool from v2.3.0 to v2.3.1.
77
* Get rid of nameToReplicasetMutex, use atomic instead.
88
* Add configurable pause before retrying r.Route in Router.Call method.
9+
* Add ability to set custom dialer in InstaceInfo.
910

1011
## v2.0.5
1112

topology.go

+20-10
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,19 @@ func (r *Router) AddInstance(ctx context.Context, rsName string, info InstanceIn
6464
return err
6565
}
6666

67-
instance := pool.Instance{
68-
Name: info.Name,
69-
Dialer: tarantool.NetDialer{
67+
dialer := info.Dialer
68+
if dialer == nil {
69+
dialer = tarantool.NetDialer{
7070
Address: info.Addr,
7171
User: r.cfg.User,
7272
Password: r.cfg.Password,
73-
},
74-
Opts: r.cfg.PoolOpts,
73+
}
74+
}
75+
76+
instance := pool.Instance{
77+
Name: info.Name,
78+
Dialer: dialer,
79+
Opts: r.cfg.PoolOpts,
7580
}
7681

7782
nameToReplicasetRef := r.getNameToReplicaset()
@@ -133,14 +138,19 @@ func (r *Router) AddReplicaset(ctx context.Context, rsInfo ReplicasetInfo, insta
133138

134139
rsInstances := make([]pool.Instance, 0, len(instances))
135140
for _, instance := range instances {
136-
rsInstances = append(rsInstances, pool.Instance{
137-
Name: instance.Name,
138-
Dialer: tarantool.NetDialer{
141+
dialer := instance.Dialer
142+
if dialer == nil {
143+
dialer = tarantool.NetDialer{
139144
Address: instance.Addr,
140145
User: r.cfg.User,
141146
Password: r.cfg.Password,
142-
},
143-
Opts: r.cfg.PoolOpts,
147+
}
148+
}
149+
150+
rsInstances = append(rsInstances, pool.Instance{
151+
Name: instance.Name,
152+
Dialer: dialer,
153+
Opts: r.cfg.PoolOpts,
144154
})
145155
}
146156

vshard.go

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ type InstanceInfo struct {
163163
// While this information is not mandatory, it can be useful for internal management or tracking purposes.
164164
// The UUID ensures that each instance can be identified uniquely, but it is not required for basic operations.
165165
UUID uuid.UUID
166+
167+
// Dialer allows to use a custom dialer instead of the default one (tarantool.NetDialer).
168+
// This parameter is temporarily optional and will become mandatory in the future.
169+
Dialer tarantool.Dialer
166170
}
167171

168172
func (ii InstanceInfo) String() string {

0 commit comments

Comments
 (0)