From 0417b90d39e1c2cde2d91de8d5e978b1950e80bf Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 30 Jul 2015 11:03:07 -0400 Subject: [PATCH] Add Go RPC in the README example --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 39afd79..d3dfcac 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,11 @@ if err != nil { // Create a cmux. m := cmux.New(l) -// Match connections in order. +// Match connections in order: +// First grpc, then HTTP, and otherwise Go RPC/TCP. grpcL := m.Match(cmux.HTTP2HeaderField("content-type", "application/grpc")) -httpL := m.Match(cmux.Any()) // Any means anything that is not yet matched. +httpL := m.Match(cmux.HTTP1Fast()) +trpcL := m.Match(cmux.Any()) // Any means anything that is not yet matched. // Create your protocol servers. grpcS := grpc.NewServer() @@ -30,9 +32,13 @@ httpS := &http.Server{ Handler: &helloHTTP1Handler{}, } +trpcS := rpc.NewServer() +s.Register(&ExampleRPCRcvr{}) + // Use the muxed listeners for your servers. go grpcS.Serve(grpcL) go httpS.Serve(httpL) +go trpcS.Accept(trpcL) // Start serving! m.Serve()