Skip to content

Commit

Permalink
Merge pull request #744 from Fenny/master
Browse files Browse the repository at this point in the history
🎈 prepare for v1.15.0
  • Loading branch information
Fenny committed Sep 1, 2020
2 parents b4feb5f + 11fdb53 commit be1d3a1
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"bufio"
"crypto/tls"
"fmt"
"io"
"net"
"net/http"
"net/http/httputil"
Expand All @@ -22,7 +23,6 @@ import (
"strconv"
"strings"
"sync"
"text/tabwriter"
"time"

utils "github.com/gofiber/utils"
Expand All @@ -32,7 +32,7 @@ import (
)

// Version of current package
const Version = "1.14.4"
const Version = "1.14.5"

// Map is a shortcut for map[string]interface{}, useful for JSON returns
type Map map[string]interface{}
Expand All @@ -48,6 +48,7 @@ type Error struct {

// App denotes the Fiber application.
type App struct {
out io.Writer
mutex sync.Mutex
// Route stack divided by HTTP methods
stack [][]*Route
Expand Down Expand Up @@ -428,12 +429,6 @@ func (app *App) Routes() []*Route {
return routes
}

// Serve is deprecated, please use app.Listener()
func (app *App) Serve(ln net.Listener, tlsconfig ...*tls.Config) error {
fmt.Println("serve: app.Serve() is deprecated since v1.12.5, please use app.Listener()")
return app.Listener(ln, tlsconfig...)
}

// Listener can be used to pass a custom listener.
// You can pass an optional *tls.Config to enable TLS.
// This method does not support the Prefork feature
Expand Down Expand Up @@ -511,7 +506,8 @@ func (app *App) Stack() [][]*Route {
return app.stack
}

// Shutdown gracefully shuts down the server without interrupting any active connections.
// Shutdown gracefully
// shuts down the server without interrupting any active connections.
// Shutdown works by first closing all open listeners and then waiting indefinitely for all connections to return to idle and then shut down.
//
// When Shutdown is called, Serve, ListenAndServe, and ListenAndServeTLS immediately return nil.
Expand Down Expand Up @@ -645,9 +641,9 @@ func (app *App) init() *App {

const (
cBlack = "\u001b[90m"
// cRed = "\u001b[91m"
// cGreen = "\u001b[92m"
// cYellow = "\u001b[93m"
cRed = "\u001b[91m"
// cGreen = "\u001b[92m"
// cYellow = "\u001b[93m"
// cBlue = "\u001b[94m"
// cMagenta = "\u001b[95m"
cCyan = "\u001b[96m"
Expand All @@ -666,17 +662,20 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
logo += `%s ____%s / ____(_) /_ ___ _____ %s` + "\n"
logo += `%s_____%s / /_ / / __ \/ _ \/ ___/ %s` + "\n"
logo += `%s __%s / __/ / / /_/ / __/ / %s` + "\n"
logo += `%s /_/ /_/_.___/\___/_/%s %s` + "\n"

logo += `%s /_/ /_/_.___/\___/_/%s %s` + ""
logo += cRed + "v1.15.0 will be released on 15 September 2020 and contains breaking changes!\nPlease visit https://github.com/gofiber/fiber/issues/736 for more information.\n" + cReset
host, port := parseAddr(addr)
padding := strconv.Itoa(len(host))
if len(host) <= 4 {
padding = "5"
}
var (
tlsStr = "FALSE"
preforkStr = "FALSE"
handlerCount = app.handlerCount
handlerCount = strconv.Itoa(app.handlerCount)
osName = utils.ToUpper(runtime.GOOS)

cpuThreads = runtime.NumCPU()
pid = os.Getpid()
cpuThreads = runtime.NumCPU()
pid = os.Getpid()
)
if host == "" {
host = "0.0.0.0"
Expand All @@ -689,25 +688,26 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
}
// tabwriter makes sure the spacing are consistent across different values
// colorable handles the escape sequence for stdout using ascii color codes
var out *tabwriter.Writer
host = fmt.Sprintf("%-"+padding+"s", host)
port = fmt.Sprintf("%-"+padding+"s", port)
tlsStr = fmt.Sprintf("%-"+padding+"s", tlsStr)
handlerCount = fmt.Sprintf("%-"+padding+"s", handlerCount)

app.out = colorable.NewColorableStdout()
// Check if colors are supported
if os.Getenv("TERM") == "dumb" ||
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd())) {
out = tabwriter.NewWriter(colorable.NewNonColorable(os.Stdout), 0, 0, 2, ' ', 0)
} else {
out = tabwriter.NewWriter(colorable.NewColorableStdout(), 0, 0, 2, ' ', 0)
app.out = colorable.NewNonColorable(os.Stdout)
}
// simple Sprintf function that defaults back to black
cyan := func(v interface{}) string {
return fmt.Sprintf("%s%v%s", cCyan, v, cBlack)
}
// Build startup banner
fmt.Fprintf(out, logo, cBlack, cBlack,
cCyan, cBlack, fmt.Sprintf(" HOST %s\tOS %s", cyan(host), cyan(osName)),
cCyan, cBlack, fmt.Sprintf(" PORT %s\tTHREADS %s", cyan(port), cyan(cpuThreads)),
cCyan, cBlack, fmt.Sprintf(" TLS %s\tPREFORK %s", cyan(tlsStr), cyan(preforkStr)),
cBlack, cyan(Version), fmt.Sprintf(" HANDLERS %s\t\t\t PID %s%s%s\n", cyan(handlerCount), cyan(pid), pids, cReset),
fmt.Fprintf(app.out, logo, cBlack, cBlack,
cCyan, cBlack, fmt.Sprintf(" HOST %s OS %s", cyan(host), cyan(osName)),
cCyan, cBlack, fmt.Sprintf(" PORT %s THREADS %s", cyan(port), cyan(cpuThreads)),
cCyan, cBlack, fmt.Sprintf(" TLS %s PREFORK %s", cyan(tlsStr), cyan(preforkStr)),
cBlack, cyan(Version), fmt.Sprintf(" HANDLERS %s PID %s%s%s\n", cyan(handlerCount), cyan(pid), pids, cReset),
)
// Write to io.write
_ = out.Flush()
}

2 comments on commit be1d3a1

@Fenny
Copy link
Member Author

@Fenny Fenny commented on be1d3a1 Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: be1d3a1 Previous: 1920d48 Ratio
Benchmark_Ctx_Send 282 ns/op 64 B/op 4 allocs/op 7.7 ns/op 0 B/op 0 allocs/op 36.62
Benchmark_Ctx_Write 373 ns/op 261 B/op 4 allocs/op 57.8 ns/op 68 B/op 0 allocs/op 6.45
Benchmark_Route_Match_Star 19 ns/op 0 B/op 0 allocs/op 5.76 ns/op 0 B/op 0 allocs/op 3.30

This comment was automatically generated by workflow using github-action-benchmark.

@Fenny
Copy link
Member Author

@Fenny Fenny commented on be1d3a1 Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: be1d3a1 Previous: 1920d48 Ratio
Benchmark_Ctx_Send 301 ns/op 64 B/op 4 allocs/op 7.7 ns/op 0 B/op 0 allocs/op 39.09
Benchmark_Ctx_Write 355 ns/op 262 B/op 4 allocs/op 57.8 ns/op 68 B/op 0 allocs/op 6.14
Benchmark_Route_Match 78.1 ns/op 0 B/op 0 allocs/op 37.1 ns/op 0 B/op 0 allocs/op 2.11
Benchmark_Route_Match_Star 19.8 ns/op 0 B/op 0 allocs/op 5.76 ns/op 0 B/op 0 allocs/op 3.44

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.