fixup 3d8e552c6a: validate streamrpc config in factory constructors

This commit is contained in:
Christian Schwarz 2018-09-03 13:17:53 -07:00
parent 2da0e51fda
commit 03f9f81cb5
2 changed files with 11 additions and 3 deletions

View File

@ -34,7 +34,11 @@ func FromConfig(g *config.Global, in config.ConnectEnum) (*ClientFactory, error)
return nil, errRPC
}
return &ClientFactory{connecter: connecter, config: &streamrpc.ClientConfig{connConf}}, nil
config := streamrpc.ClientConfig{connConf}
if err := config.Validate(); err != nil {
return nil, err
}
return &ClientFactory{connecter: connecter, config: &config}, nil
}
type ClientFactory struct {

View File

@ -10,7 +10,7 @@ func FromDaemonConfig(g *config.Global, in *config.RPCConfig) (*streamrpc.ConnCo
if conf == nil {
conf = g.RPC
}
return &streamrpc.ConnConfig{
srpcConf := &streamrpc.ConnConfig{
RxHeaderMaxLen: conf.RxHeaderMaxLen,
RxStructuredMaxLen: conf.RxStructuredMaxLen,
RxStreamMaxChunkSize: conf.RxStreamChunkMaxLen,
@ -18,5 +18,9 @@ func FromDaemonConfig(g *config.Global, in *config.RPCConfig) (*streamrpc.ConnCo
Timeout: streamrpc.Timeout{
Progress: conf.Timeout,
},
}, nil
}
if err := srpcConf.Validate(); err != nil {
return nil, err
}
return srpcConf, nil
}