go-pkgz / jrpc Goto Github PK
View Code? Open in Web Editor NEWRPC with json
License: MIT License
RPC with json
License: MIT License
Currently middleware selection is very opinionated and in some cases user may not like the provided set. Instead to hardcoding it will be better to allow injection of any middlewares user needs.
Probably some may stay mandatory, probably NoCache and Ping, but others (limiter, logger, recovery, throttler and RealIP) should be passed in.
With following change in place I see report on leaking goroutines:
diff --git a/server_test.go b/server_test.go
index 30c07d5..851c09a 100644
--- a/server_test.go
+++ b/server_test.go
@@ -12,9 +12,11 @@ import (
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "go.uber.org/goleak"
)
func TestServerPrimitiveTypes(t *testing.T) {
+ defer goleak.VerifyNone(t)
s := Server{API: "/v1/cmd", Logger: NoOpLogger}
type respData struct {
Report:
=== RUN TestServerPrimitiveTypes
--- FAIL: TestServerPrimitiveTypes (0.46s)
server_test.go:32: [blah 42 true]
server_test.go:32: [blah 42 true]
leaks.go:78: found unexpected goroutines:
[Goroutine 37 in state select, with github.com/patrickmn/go-cache.(*janitor).Run on top of the stack:
goroutine 37 [select]:
github.com/patrickmn/go-cache.(*janitor).Run(0xc00011c3c0, 0xc000132880)
/Users/dmitry/go/pkg/mod/github.com/patrickmn/go-cache@v2.1.0+incompatible/cache.go:1079 +0xd5
created by github.com/patrickmn/go-cache.runJanitor
/Users/dmitry/go/pkg/mod/github.com/patrickmn/go-cache@v2.1.0+incompatible/cache.go:1099 +0xa9
Goroutine 38 in state select, with github.com/patrickmn/go-cache.(*janitor).Run on top of the stack:
goroutine 38 [select]:
github.com/patrickmn/go-cache.(*janitor).Run(0xc00011c3d0, 0xc0001328c0)
/Users/dmitry/go/pkg/mod/github.com/patrickmn/go-cache@v2.1.0+incompatible/cache.go:1079 +0xd5
created by github.com/patrickmn/go-cache.runJanitor
/Users/dmitry/go/pkg/mod/github.com/patrickmn/go-cache@v2.1.0+incompatible/cache.go:1099 +0xa9
]
I haven't yet figured out what is the root cause and or how to fix it.
The effect of this leak is unknown to me, I just know that's it's visible with goleak tool both in this project and also in remark42 which uses it. Feel free to close if you don't think it's worth investigating.
It should work with any mux and not depend on chi exclusively. This will minimize external dependencies and allow user to pick any router. The infamous go-chi/chi/issues/561 proved - such a hard dependency is not the best idea and switching to smth else should be allowed and supported.
#8 should be addressed first as it has some chi dependencies in the list of used middlewares
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.