Source File
trace.go
Belonging Package
google.golang.org/grpc
package grpc
import (
)
var EnableTracing bool
type firstLine struct {
mu sync.Mutex
client bool // whether this is a client (outgoing) RPC
remoteAddr net.Addr
deadline time.Duration // may be zero
}
func ( *firstLine) ( net.Addr) {
.mu.Lock()
.remoteAddr =
.mu.Unlock()
}
func ( *firstLine) () string {
.mu.Lock()
defer .mu.Unlock()
var bytes.Buffer
io.WriteString(&, "RPC: ")
if .client {
io.WriteString(&, "to")
} else {
io.WriteString(&, "from")
}
fmt.Fprintf(&, " %v deadline:", .remoteAddr)
if .deadline != 0 {
fmt.Fprint(&, .deadline)
} else {
io.WriteString(&, "none")
}
return .String()
}
const truncateSize = 100
func ( string, int) string {
if > len() {
return
}
return [:]
}
}
func ( payload) () string {
if .sent {
return truncate(fmt.Sprintf("sent: %v", .msg), truncateSize)
}
return truncate(fmt.Sprintf("recv: %v", .msg), truncateSize)
}
type fmtStringer struct {
format string
a []interface{}
}
func ( *fmtStringer) () string {
return fmt.Sprintf(.format, .a...)
}
type stringer string
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |