gRPC is great, but is not available on Classic AppEngine at this time, so while working on the [nextgen CI for Chromium][luci] we wrote pRPC (provisional RPC) for Go that is compatible with gRPC server/client code, but works on HTTP 1.x and Classic AppEngine. In addition it has gRPC-compatible discovery and a CLI tool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// init registers HTTP routes. | |
func init() { | |
// pRPC uses luci-go router that implements http.Handler. | |
r := router.New() | |
// We use no middleware in this example. | |
middleware := router.MiddlewareChain{} | |
// Configure pRPC server. | |
var server prpc.Server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type greeterService struct{} | |
func (s *greeterService) SayHello(c context.Context, req *helloworld.HelloRequest) (*helloworld.HelloReply, error) { | |
if req.Name == "" { | |
return nil, grpc.Errorf(codes.InvalidArgument, "Name unspecified") | |
} | |
return &helloworld.HelloReply{ | |
Message: "Hello " + req.Name, | |
}, nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// helloworld.proto | |
syntax = "proto3"; | |
package helloworld; | |
// The greeting service definition. | |
service Greeter { | |
// Sends a greeting | |
rpc SayHello (HelloRequest) returns (HelloReply) {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package better is a better implementation of log.Logger | |
package better | |
type Logger struct { | |
} | |
func (l *Logger) Print(v ...interface{}) { | |
//.... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"better" | |
"log" | |
) | |
// Logger is a subset of log.Logger methods that we need. | |
type MyLogger interface { | |
Print(v ...interface{}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package better is a better implementation of log.Logger | |
package better | |
type Logger struct { | |
} | |
func (l *Logger) Print(v ...interface{}) { | |
//.... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MyLogger interface { | |
Print(v ...interface{}) | |
} | |
var l MyLogger = log.New(os.Stderr, "", 0) |
Author(s): Nodir Turakulov <[email protected]>
With initial input by Russ Cox, Caleb Spare, Andrew Gerrand and Minux Ma.
Last updated: 2015-10-07
Discussion at https://golang.org/issue/2981.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p $WORK/compress/zlib/_test/compress/ | |
# | |
# compress/zlib | |
# | |
mkdir -p $WORK/compress/zlib/_test/_obj_test/ | |
cd /Users/nodir/go/src/github.com/golang/go/src/compress/zlib | |
/Users/nodir/go/src/github.com/golang/go/pkg/tool/darwin_amd64/compile -o $WORK/compress/zlib/_test/compress/zlib.a -trimpath $WORK -p compress/zlib -complete -buildid d766f85b5551c2e988b19e7a04fd06d10cb0b7b3 -D _/Users/nodir/go/src/github.com/golang/go/src/compress/zlib -I $WORK -pack ./reader.go ./writer.go ./reader_test.go ./writer_test.go |