forked from TrueCloudLab/frostfs-node
[#290] control: Use generics for response wrappers
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
ff25521204
commit
f73ac6e02d
2 changed files with 31 additions and 187 deletions
|
@ -25,10 +25,7 @@ func HealthCheck(
|
|||
req *HealthCheckRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*HealthCheckResponse, error) {
|
||||
wResp := &healthCheckResponseWrapper{
|
||||
m: new(HealthCheckResponse),
|
||||
}
|
||||
|
||||
wResp := newResponseWrapper[HealthCheckResponse]()
|
||||
wReq := &requestWrapper{
|
||||
m: req,
|
||||
}
|
||||
|
@ -38,7 +35,7 @@ func HealthCheck(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.m, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// SetNetmapStatus executes ControlService.SetNetmapStatus RPC.
|
||||
|
@ -47,9 +44,7 @@ func SetNetmapStatus(
|
|||
req *SetNetmapStatusRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*SetNetmapStatusResponse, error) {
|
||||
wResp := &setNetmapStatusResponseWrapper{
|
||||
m: new(SetNetmapStatusResponse),
|
||||
}
|
||||
wResp := newResponseWrapper[SetNetmapStatusResponse]()
|
||||
|
||||
wReq := &requestWrapper{
|
||||
m: req,
|
||||
|
@ -60,7 +55,7 @@ func SetNetmapStatus(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.m, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// DropObjects executes ControlService.DropObjects RPC.
|
||||
|
@ -69,9 +64,7 @@ func DropObjects(
|
|||
req *DropObjectsRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*DropObjectsResponse, error) {
|
||||
wResp := &dropObjectsResponseWrapper{
|
||||
m: new(DropObjectsResponse),
|
||||
}
|
||||
wResp := newResponseWrapper[DropObjectsResponse]()
|
||||
|
||||
wReq := &requestWrapper{
|
||||
m: req,
|
||||
|
@ -81,7 +74,7 @@ func DropObjects(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.m, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// ListShards executes ControlService.ListShards RPC.
|
||||
|
@ -90,9 +83,7 @@ func ListShards(
|
|||
req *ListShardsRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*ListShardsResponse, error) {
|
||||
wResp := &listShardsResponseWrapper{
|
||||
m: new(ListShardsResponse),
|
||||
}
|
||||
wResp := newResponseWrapper[ListShardsResponse]()
|
||||
|
||||
wReq := &requestWrapper{
|
||||
m: req,
|
||||
|
@ -102,7 +93,7 @@ func ListShards(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.m, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// SetShardMode executes ControlService.SetShardMode RPC.
|
||||
|
@ -111,9 +102,7 @@ func SetShardMode(
|
|||
req *SetShardModeRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*SetShardModeResponse, error) {
|
||||
wResp := &setShardModeResponseWrapper{
|
||||
m: new(SetShardModeResponse),
|
||||
}
|
||||
wResp := newResponseWrapper[SetShardModeResponse]()
|
||||
|
||||
wReq := &requestWrapper{
|
||||
m: req,
|
||||
|
@ -123,12 +112,12 @@ func SetShardMode(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.m, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// SynchronizeTree executes ControlService.SynchronizeTree RPC.
|
||||
func SynchronizeTree(cli *client.Client, req *SynchronizeTreeRequest, opts ...client.CallOption) (*SynchronizeTreeResponse, error) {
|
||||
wResp := &synchronizeTreeResponseWrapper{new(SynchronizeTreeResponse)}
|
||||
wResp := newResponseWrapper[SynchronizeTreeResponse]()
|
||||
wReq := &requestWrapper{m: req}
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcSynchronizeTree), wReq, wResp, opts...)
|
||||
|
@ -136,12 +125,12 @@ func SynchronizeTree(cli *client.Client, req *SynchronizeTreeRequest, opts ...cl
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.SynchronizeTreeResponse, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// EvacuateShard executes ControlService.EvacuateShard RPC.
|
||||
func EvacuateShard(cli *client.Client, req *EvacuateShardRequest, opts ...client.CallOption) (*EvacuateShardResponse, error) {
|
||||
wResp := &evacuateShardResponseWrapper{new(EvacuateShardResponse)}
|
||||
wResp := newResponseWrapper[EvacuateShardResponse]()
|
||||
wReq := &requestWrapper{m: req}
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcEvacuateShard), wReq, wResp, opts...)
|
||||
|
@ -149,12 +138,12 @@ func EvacuateShard(cli *client.Client, req *EvacuateShardRequest, opts ...client
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.EvacuateShardResponse, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// FlushCache executes ControlService.FlushCache RPC.
|
||||
func FlushCache(cli *client.Client, req *FlushCacheRequest, opts ...client.CallOption) (*FlushCacheResponse, error) {
|
||||
wResp := &flushCacheResponseWrapper{new(FlushCacheResponse)}
|
||||
wResp := newResponseWrapper[FlushCacheResponse]()
|
||||
wReq := &requestWrapper{m: req}
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcFlushCache), wReq, wResp, opts...)
|
||||
|
@ -162,12 +151,12 @@ func FlushCache(cli *client.Client, req *FlushCacheRequest, opts ...client.CallO
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.FlushCacheResponse, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
||||
// Doctor executes ControlService.Doctor RPC.
|
||||
func Doctor(cli *client.Client, req *DoctorRequest, opts ...client.CallOption) (*DoctorResponse, error) {
|
||||
wResp := &doctorResponseWrapper{new(DoctorResponse)}
|
||||
wResp := newResponseWrapper[DoctorResponse]()
|
||||
wReq := &requestWrapper{m: req}
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcDoctor), wReq, wResp, opts...)
|
||||
|
@ -175,5 +164,5 @@ func Doctor(cli *client.Client, req *DoctorRequest, opts ...client.CallOption) (
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return wResp.DoctorResponse, nil
|
||||
return wResp.message, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue