github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/lib/objectserver/client/client.go (about) 1 package client 2 3 import ( 4 "errors" 5 "fmt" 6 7 "github.com/Cloud-Foundations/Dominator/lib/srpc" 8 ) 9 10 func (objClient *ObjectClient) close() error { 11 if objClient.client != nil && objClient.address != "" { 12 return objClient.client.Close() 13 } 14 return nil 15 } 16 17 func (objClient *ObjectClient) getClient() (*srpc.Client, error) { 18 if objClient.client != nil { 19 return objClient.client, nil 20 } 21 if objClient.address == "" { 22 return nil, errors.New("no client address") 23 } 24 srpcClient, err := srpc.DialHTTP("tcp", objClient.address, 0) 25 if err != nil { 26 return nil, fmt.Errorf("error dialing: %s: %s", objClient.address, err) 27 } 28 objClient.client = srpcClient 29 return objClient.client, nil 30 }