This commit is contained in:
11
rpc-pool.go
11
rpc-pool.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -33,9 +34,6 @@ type RemoteGrain struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRemoteGrain(id CartId, address string) *RemoteGrain {
|
func NewRemoteGrain(id CartId, address string) *RemoteGrain {
|
||||||
if !strings.Contains(address, ":") {
|
|
||||||
address = fmt.Sprintf("[%s]:1337", address)
|
|
||||||
}
|
|
||||||
return &RemoteGrain{
|
return &RemoteGrain{
|
||||||
Id: id,
|
Id: id,
|
||||||
Address: address,
|
Address: address,
|
||||||
@@ -44,7 +42,12 @@ func NewRemoteGrain(id CartId, address string) *RemoteGrain {
|
|||||||
|
|
||||||
func (g *RemoteGrain) Connect() error {
|
func (g *RemoteGrain) Connect() error {
|
||||||
if g.connection == nil {
|
if g.connection == nil {
|
||||||
client, err := net.Dial("tcp", g.Address)
|
addr := g.Address
|
||||||
|
if !strings.Contains(addr, ":") {
|
||||||
|
addr = fmt.Sprintf("%s:1337", addr)
|
||||||
|
}
|
||||||
|
log.Println("Connecting to", addr)
|
||||||
|
client, err := net.Dial("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user