funnel icon indicating copy to clipboard operation
funnel copied to clipboard

events: cannot be used as a library

Open buchanae opened this issue 7 years ago • 4 comments

events imports grpc, and grpc does something with net/http. Since we vendor grpc (rightly so, it releases breaking changes frequently), importing events from an external codebase causes a panic:

panic: http: multiple registrations for /debug/requests

goroutine 1 [running]:
net/http.(*ServeMux).Handle(0xe49680, 0xaea1a8, 0xf, 0xdf5020, 0xb05748)
	/usr/local/go/src/net/http/server.go:2254 +0x610
net/http.(*ServeMux).HandleFunc(0xe49680, 0xaea1a8, 0xf, 0xb05748)
	/usr/local/go/src/net/http/server.go:2286 +0x55
net/http.HandleFunc(0xaea1a8, 0xf, 0xb05748)
	/usr/local/go/src/net/http/server.go:2298 +0x4b
github.com/ohsu-comp-bio/funnel/vendor/golang.org/x/net/trace.init.1()
	/home/ubuntu/src/github.com/ohsu-comp-bio/funnel/vendor/golang.org/x/net/trace/trace.go:115 +0x42
github.com/ohsu-comp-bio/funnel/vendor/golang.org/x/net/trace.init()
	/home/ubuntu/src/github.com/ohsu-comp-bio/funnel/vendor/golang.org/x/net/trace/trace_go17.go:22 +0x1cd
github.com/ohsu-comp-bio/funnel/vendor/google.golang.org/grpc.init()
	/home/ubuntu/src/github.com/ohsu-comp-bio/funnel/vendor/google.golang.org/grpc/trace.go:114 +0x9b
github.com/ohsu-comp-bio/funnel/proto/tes.init()
	/home/ubuntu/src/github.com/ohsu-comp-bio/funnel/proto/tes/validate.go:95 +0x67
github.com/ohsu-comp-bio/funnel/events.init()
	/home/ubuntu/src/github.com/ohsu-comp-bio/funnel/events/writer.go:34 +0x64
main.init()
	/home/ubuntu/src/github.com/bmeg/arachne/import.go:58 +0x4e

I am so tired of grpc's issues. This is not going to be easy to solve.

One idea is to break the events writers into separate packages. We could introduce and rpc package and move all grpc code there. Other packages would define interfaces so they don't need to import grpc.

buchanae avatar Feb 03 '18 01:02 buchanae

Another idea is to nuke grpc and hope this issue goes away.

buchanae avatar Feb 03 '18 01:02 buchanae

looks like this isn't grpc specific, but due to vendoring golang.org/x/net/trace.

https://github.com/grpc/grpc-go/issues/566

adamstruck avatar Feb 05 '18 15:02 adamstruck

So unvendoring golang.org/x/net/trace should fix it? Does it change infrequently enough?

kellrott avatar Feb 05 '18 17:02 kellrott

Ah, ok, that's good actually. We shouldn't be vendoring anything under golang.org, we can trust that enough. We should drop the vendetta tools, so this problem doesn't come back.

buchanae avatar Feb 05 '18 17:02 buchanae