Need help with go_reuseport?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

kavu
520 Stars 69 Forks MIT License 64 Commits 1 Opened issues

Description

Brings SO_REUSEPORT into your Go server

Services available

!
?

Need anything else?

Contributors list

# 58,177
Express
Node.js
Clojure
rabbitm...
41 commits
# 230,102
Shell
Go
HTML
beego
2 commits
# 105,708
Go
atomic
golang
Linux
1 commit
# 108,821
C++
Perl
routero...
amateur...
1 commit
# 194,340
Go
Shell
documen...
golang
1 commit
# 7,543
Shell
Perl
C
merge-c...
1 commit
# 80,701
Visual ...
Perl
Shell
1 commit
# 518,010
Go
Shell
1 commit
# 20,799
Go
Git
Shell
golang
1 commit
# 5,753
prometh...
SQL
Git
apt
1 commit

GO_REUSEPORT

Build Status codecov GoDoc

GO_REUSEPORT is a little expirement to create a

net.Listener
that supports SO_REUSEPORT socket option.

For now, Darwin and Linux (from 3.9) systems are supported. I'll be pleased if you'll test other systems and tell me the results. documentation on godoc.org.

Example

package main

import ( "fmt" "html" "net/http" "os" "runtime" "github.com/kavu/go_reuseport" )

func main() { listener, err := reuseport.Listen("tcp", "localhost:8881") if err != nil { panic(err) } defer listener.Close()

server := &http.Server{} http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Println(os.Getgid()) fmt.Fprintf(w, "Hello, %q\n", html.EscapeString(r.URL.Path)) })

panic(server.Serve(listener)) }

Now you can run several instances of this tiny server without

Address already in use
errors.

Thanks

Inspired by Artur Siekielski post about

SO_REUSEPORT
.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.