mirror of https://github.com/grpc/grpc-go.git
Add grpc.Version string and use it in the UA (#1144)
This commit is contained in:
parent
0a20758157
commit
14a6be430b
|
|
@ -310,6 +310,14 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(&cc.dopts)
|
opt(&cc.dopts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grpcUA := "grpc-go/" + Version
|
||||||
|
if cc.dopts.copts.UserAgent != "" {
|
||||||
|
cc.dopts.copts.UserAgent += " " + grpcUA
|
||||||
|
} else {
|
||||||
|
cc.dopts.copts.UserAgent = grpcUA
|
||||||
|
}
|
||||||
|
|
||||||
if cc.dopts.timeout > 0 {
|
if cc.dopts.timeout > 0 {
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
ctx, cancel = context.WithTimeout(ctx, cc.dopts.timeout)
|
ctx, cancel = context.WithTimeout(ctx, cc.dopts.timeout)
|
||||||
|
|
|
||||||
|
|
@ -527,3 +527,6 @@ type ServiceConfig struct {
|
||||||
// requires a synchronised update of grpc-go and protoc-gen-go. This constant
|
// requires a synchronised update of grpc-go and protoc-gen-go. This constant
|
||||||
// should not be referenced from any other code.
|
// should not be referenced from any other code.
|
||||||
const SupportPackageIsVersion4 = true
|
const SupportPackageIsVersion4 = true
|
||||||
|
|
||||||
|
// Version is the current grpc version.
|
||||||
|
const Version = "1.3.0-dev"
|
||||||
|
|
|
||||||
|
|
@ -187,10 +187,6 @@ func newHTTP2Client(ctx context.Context, addr TargetInfo, opts ConnectOptions) (
|
||||||
return nil, connectionErrorf(temp, err, "transport: %v", err)
|
return nil, connectionErrorf(temp, err, "transport: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ua := primaryUA
|
|
||||||
if opts.UserAgent != "" {
|
|
||||||
ua = opts.UserAgent + " " + ua
|
|
||||||
}
|
|
||||||
kp := opts.KeepaliveParams
|
kp := opts.KeepaliveParams
|
||||||
// Validate keepalive parameters.
|
// Validate keepalive parameters.
|
||||||
if kp.Time == 0 {
|
if kp.Time == 0 {
|
||||||
|
|
@ -203,7 +199,7 @@ func newHTTP2Client(ctx context.Context, addr TargetInfo, opts ConnectOptions) (
|
||||||
t := &http2Client{
|
t := &http2Client{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
target: addr.Addr,
|
target: addr.Addr,
|
||||||
userAgent: ua,
|
userAgent: opts.UserAgent,
|
||||||
md: addr.Metadata,
|
md: addr.Metadata,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
remoteAddr: conn.RemoteAddr(),
|
remoteAddr: conn.RemoteAddr(),
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// The primary user agent
|
|
||||||
primaryUA = "grpc-go/1.0"
|
|
||||||
// http2MaxFrameLen specifies the max length of a HTTP2 frame.
|
// http2MaxFrameLen specifies the max length of a HTTP2 frame.
|
||||||
http2MaxFrameLen = 16384 // 16KB frame
|
http2MaxFrameLen = 16384 // 16KB frame
|
||||||
// http://http2.github.io/http2-spec/#SettingValues
|
// http://http2.github.io/http2-spec/#SettingValues
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue