func TestTCPConnect(t *testing.T) { client, err := gorpc.TCPConnect(clientBuilder, "tcp-client", "127.0.0.1:13512") if err != nil { t.Fatal(err) } api := BindRESTfull(1, client.Pipeline()) _, err = api.Get(nil, "test") if err == nil { t.Fatalf("test rpc exception -- failed") } if _, ok := err.(*ResourceError); !ok { t.Fatalf("test rpc exception -- failed:%s", err) } api.Put(nil, "test", "hello world") val, err := api.Get(nil, "test") if err != nil { t.Fatal(err) } if val != "hello world" { t.Fatalf("test get val error :%s", val) } }
// Connect func (system *_System) Connect(name string, raddr string) (gorpc.Client, error) { builder := gorpc.NewClientBuilder( name, gorpc.BuildPipeline(time.Millisecond*10).Handler( "profile", gorpc.ProfileHandler, ).Handler( "tunnel-client", func() gorpc.Handler { return system.newTunnelClient(raddr) }, ).Timeout(system.timeout), ) builder.Reconnect(system.timeout) return gorpc.TCPConnect(builder, name, raddr) }