mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-29 03:45:27 +01:00
27 lines
626 B
Go
27 lines
626 B
Go
package streamrpcconfig
|
|
|
|
import (
|
|
"github.com/problame/go-streamrpc"
|
|
"github.com/zrepl/zrepl/config"
|
|
)
|
|
|
|
func FromDaemonConfig(g *config.Global, in *config.RPCConfig) (*streamrpc.ConnConfig, error) {
|
|
conf := in
|
|
if conf == nil {
|
|
conf = g.RPC
|
|
}
|
|
srpcConf := &streamrpc.ConnConfig{
|
|
RxHeaderMaxLen: conf.RxHeaderMaxLen,
|
|
RxStructuredMaxLen: conf.RxStructuredMaxLen,
|
|
RxStreamMaxChunkSize: conf.RxStreamChunkMaxLen,
|
|
TxChunkSize: conf.TxChunkSize,
|
|
Timeout: streamrpc.Timeout{
|
|
Progress: conf.Timeout,
|
|
},
|
|
}
|
|
if err := srpcConf.Validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
return srpcConf, nil
|
|
}
|