update to streamrpc 0.4 & adjust config (not breaking)

This commit is contained in:
Christian Schwarz 2018-09-23 20:28:30 +02:00
parent 9dd662df08
commit 4a6160baf3
5 changed files with 21 additions and 7 deletions

6
Gopkg.lock generated
View File

@ -170,15 +170,15 @@
revision = "391d2c78c8404a9683d79f75dd24ab53040f89f7" revision = "391d2c78c8404a9683d79f75dd24ab53040f89f7"
[[projects]] [[projects]]
digest = "1:f6bc2d2f9c00737754ef87dba06c851458523fa382a61e1e2e5270c1f39a6622" digest = "1:c2ba1c9dc003c15856e4529dac028cacba08ee8924300f058b3467cde9acf7a9"
name = "github.com/problame/go-streamrpc" name = "github.com/problame/go-streamrpc"
packages = [ packages = [
".", ".",
"internal/pdu", "internal/pdu",
] ]
pruneopts = "" pruneopts = ""
revision = "a67d93db93b3dc8c2d6901a1b2183ff42dea8f7d" revision = "de6f6a4041c77f700f02d8fe749e54efa50811f7"
version = "v0.3" version = "v0.4"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -69,4 +69,4 @@ ignored = [ "github.com/inconshreveable/mousetrap" ]
[[constraint]] [[constraint]]
name = "github.com/problame/go-streamrpc" name = "github.com/problame/go-streamrpc"
version = "0.3.0" version = "0.4.0"

View File

@ -130,6 +130,8 @@ type RPCConfig struct {
RxStructuredMaxLen uint32 `yaml:"rx_structured_max,optional,default=16777216"` RxStructuredMaxLen uint32 `yaml:"rx_structured_max,optional,default=16777216"`
RxStreamChunkMaxLen uint32 `yaml:"rx_stream_chunk_max,optional,default=16777216"` RxStreamChunkMaxLen uint32 `yaml:"rx_stream_chunk_max,optional,default=16777216"`
RxHeaderMaxLen uint32 `yaml:"rx_header_max,optional,default=40960"` RxHeaderMaxLen uint32 `yaml:"rx_header_max,optional,default=40960"`
SendHeartbeatInterval time.Duration `yaml:"send_heartbeat_interval,optional,positive,default=5s"`
} }
type ConnectEnum struct { type ConnectEnum struct {

View File

@ -53,11 +53,24 @@ jobs:
rpc: rpc:
rx_structured_max: 0x2342 rx_structured_max: 0x2342
- type: sink
name: "other_sink"
root_dataset: "pool2/backup_laptops"
serve:
type: tcp
listen: "192.168.122.189:8888"
clients: {
"10.23.42.23":"client1"
}
rpc:
send_heartbeat_interval: 10s
`) `)
assert.Equal(t, 20*time.Second, conf.Jobs[0].Ret.(*PullJob).Connect.Ret.(*TCPConnect).RPC.Timeout) assert.Equal(t, 20*time.Second, conf.Jobs[0].Ret.(*PullJob).Connect.Ret.(*TCPConnect).RPC.Timeout)
assert.Equal(t, uint32(0xabcd), conf.Jobs[1].Ret.(*PullJob).Connect.Ret.(*TCPConnect).RPC.TxChunkSize) assert.Equal(t, uint32(0xabcd), conf.Jobs[1].Ret.(*PullJob).Connect.Ret.(*TCPConnect).RPC.TxChunkSize)
assert.Equal(t, uint32(0x2342), conf.Jobs[2].Ret.(*SinkJob).Serve.Ret.(*TCPServe).RPC.RxStructuredMaxLen) assert.Equal(t, uint32(0x2342), conf.Jobs[2].Ret.(*SinkJob).Serve.Ret.(*TCPServe).RPC.RxStructuredMaxLen)
assert.Equal(t, 10*time.Second, conf.Jobs[3].Ret.(*SinkJob).Serve.Ret.(*TCPServe).RPC.SendHeartbeatInterval)
defConf := RPCConfig{} defConf := RPCConfig{}
Default(&defConf) Default(&defConf)
assert.Equal(t, defConf.Timeout, conf.Global.RPC.Timeout) assert.Equal(t, defConf.Timeout, conf.Global.RPC.Timeout)

View File

@ -15,9 +15,8 @@ func FromDaemonConfig(g *config.Global, in *config.RPCConfig) (*streamrpc.ConnCo
RxStructuredMaxLen: conf.RxStructuredMaxLen, RxStructuredMaxLen: conf.RxStructuredMaxLen,
RxStreamMaxChunkSize: conf.RxStreamChunkMaxLen, RxStreamMaxChunkSize: conf.RxStreamChunkMaxLen,
TxChunkSize: conf.TxChunkSize, TxChunkSize: conf.TxChunkSize,
Timeout: streamrpc.Timeout{ Timeout: conf.Timeout,
Progress: conf.Timeout, SendHeartbeatInterval: conf.SendHeartbeatInterval,
},
} }
if err := srpcConf.Validate(); err != nil { if err := srpcConf.Validate(); err != nil {
return nil, err return nil, err