[#1689] treesvc: Create request after client is initialized

Make it easier to follow.

Change-Id: I40c4db77f015bb45cb25f16ce24e68188fc14380
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2025-04-01 13:20:20 +03:00
parent 19ca907223
commit b112a92408
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg

View file

@ -117,13 +117,6 @@ func (c *clientCache) dialTreeService(ctx context.Context, netmapAddr string) (*
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
}
req := &HealthcheckRequest{
Body: &HealthcheckRequest_Body{},
}
if err := SignMessage(req, c.key); err != nil {
return nil, err
}
cc, err := grpc.NewClient(netAddr.URIAddr(), opts...)
if err != nil {
return nil, err
@ -131,6 +124,14 @@ func (c *clientCache) dialTreeService(ctx context.Context, netmapAddr string) (*
ctx, cancel := context.WithTimeout(ctx, defaultClientConnectTimeout)
defer cancel()
req := &HealthcheckRequest{
Body: &HealthcheckRequest_Body{},
}
if err := SignMessage(req, c.key); err != nil {
return nil, err
}
// perform some request to check connection
if _, err := NewTreeServiceClient(cc).Healthcheck(ctx, req); err != nil {
_ = cc.Close()