Add default dialer #8

Merged
fyrchik merged 1 commit from dstepanov-yadro/multinet:feat/default_dialer into master 2024-09-04 19:51:22 +00:00
5 changed files with 52 additions and 1 deletions

View file

@ -4,3 +4,6 @@ integration-test:
test:
go test -count=1 -v ./...
patch-example:
gopatch -d -p ./multinet.patch ./testdata/patch*

View file

@ -39,3 +39,11 @@ if err != nil {
`NetlinkWatcher` can wrap `Multidialer` type and perform all updates automatically.
TODO: describe needed capabilities here.
## Patch
To perform refactoring (use `multinet.Dial` instead of `net.Dial`) using [gopatch](https://github.com/uber-go/gopatch):
```bash
gopatch -p ./multinet.patch <project directory>
```

7
multinet.patch Normal file
View file

@ -0,0 +1,7 @@
@@
@@
+import "git.frostfs.info/TrueCloudLab/multinet"
-import "net"
-net.Dial(...)
+multinet.Dial(...)

19
testdata/patch_0.go vendored Normal file
View file

@ -0,0 +1,19 @@
package main
import (
"log"
"net"
)
const addr = "s01.frostfs.devenv:8080"
func main() {
_, err := net.Dial(getNetwork(), addr)
if err != nil {
log.Fatal(err)
}
}
func getNetwork() string {
return "tcp"
}

14
testdata/patch_1.go vendored Normal file
View file

@ -0,0 +1,14 @@
package main
import (
"log"
"net"
)
func main() {
ip := net.IPv4(192, 168, 0, 10)
_, err := net.Dial("tcp", ip.String()+":8080")
if err != nil {
log.Fatal(err)
}
}