benschw / dns-clb-go Goto Github PK
View Code? Open in Web Editor NEWClient-Side Load-Balancer for DNS based Service Discovery written in Golang
Client-Side Load-Balancer for DNS based Service Discovery written in Golang
RandomClb.GetAddress() panics when there are no SRV records found for the given name. RoundRobinClb guards against this, returning fmt.Errorf("no SRV records found"), but RandomClb gives:
panic: invalid argument to Intn
goroutine 16 [running]:
runtime.panic(0x5cf040, 0xc208000710)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
math/rand.(*Rand).Intn(0xc208000160, 0x0, 0x0)
/usr/local/go/src/pkg/math/rand/rand.go:95 +0x71
math/rand.Intn(0x0, 0x698577)
/usr/local/go/src/pkg/math/rand/rand.go:195 +0x34
github.com/benschw/dns-clb-go/randomclb.(*RandomClb).GetAddress(0xc2080005a0, 0x698577, 0x17, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/sheldonh/go/src/github.com/benschw/dns-clb-go/randomclb/random.go:27 +0x126
main.main()
/home/sheldonh/go/src/github.com/sheldonh/foo/foo.go:24 +0x36d
-- FAIL: TestGet (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x146263]
goroutine 5 [running]:
testing.func·006()
/Users/youngking/.gvm/gos/go1.4.2/src/testing/testing.go:441 +0x181
github.com/benschw/dns-clb-go/dns.(_LookupLib).lookup(0xc20800abb0, 0xc20801e0c0, 0x1a, 0x3d59b0, 0x3, 0x3df690, 0x3, 0xc20802a600, 0x0, 0x0)
/Users/youngking/gspace/src/github.com/benschw/dns-clb-go/dns/lib.go:107 +0x3d3
github.com/benschw/dns-clb-go/dns.(_LookupLib).lookup(0xc20800abb0, 0xc20801e0c0, 0x1a, 0x3d59b0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/youngking/gspace/src/github.com/benschw/dns-clb-go/dns/lib.go:104 +0x39b
github.com/benschw/dns-clb-go/dns.(_LookupLib).lookupType(0xc20800abb0, 0x4228f0, 0x19, 0x3d59b0, 0x3, 0x0, 0x0, 0x0)
/Users/youngking/gspace/src/github.com/benschw/dns-clb-go/dns/lib.go:85 +0x7c
github.com/benschw/dns-clb-go/dns.(_LookupLib).LookupSRV(0xc20800abb0, 0x4228f0, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/youngking/gspace/src/github.com/benschw/dns-clb-go/dns/lib.go:43 +0xce
github.com/benschw/dns-clb-go/randomclb.(*RandomClb).GetAddress(0xc20800abc0, 0x4228f0, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/youngking/gspace/src/github.com/benschw/dns-clb-go/randomclb/random.go:22 +0xbf
I really like this approach.
So, for dumb web apps, some extra things are needed.
Lets asume:
to make this work a web sockets Or http long polling layer is needed to constantly update the web clients about what servers are up, with them ordered based on priority.
What do you think ?
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.