コード例 #1
0
ファイル: oneway.go プロジェクト: yarpc/yarpc-go
func newDispatcher(t crossdock.T) yarpc.Dispatcher {
	server := t.Param(params.Server)
	crossdock.Fatals(t).NotEmpty(server, "server is required")

	dispatcher := yarpc.NewDispatcher(yarpc.Config{
		Name: "client",
		Outbounds: yarpc.Outbounds{
			"oneway-test": {
				Oneway: http.NewOutbound(fmt.Sprintf("http://%s:8084", server)),
			},
		},
		//for call back
		Inbounds: []transport.Inbound{http.NewInbound(fmt.Sprintf("%s:8089", server))},
	})

	// register procedure for remote server to call us back on
	dispatcher.Register(raw.OnewayProcedure("call-back", callBack))
	return dispatcher
}
コード例 #2
0
ファイル: server.go プロジェクト: yarpc/yarpc-go
// Start starts the test server that clients will make requests to
func Start() {
	h := onewayHandler{
		Outbound: http.NewOutbound("http://127.0.0.1:8089"),
	}

	dispatcher = yarpc.NewDispatcher(yarpc.Config{
		Name: "oneway-test",
		Inbounds: []transport.Inbound{
			http.NewInbound(":8084"),
		},
		Outbounds: yarpc.Outbounds{
			"client": {Oneway: h.Outbound},
		},
	})

	dispatcher.Register(raw.OnewayProcedure("echo/raw", h.EchoRaw))
	dispatcher.Register(json.OnewayProcedure("echo/json", h.EchoJSON))
	dispatcher.Register(onewayserver.New(&h))

	if err := dispatcher.Start(); err != nil {
		fmt.Println("error:", err.Error())
	}
}