From 1130c1f5a63a383cf4ff13532fc5bf615121e8bc Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 16 Feb 2022 18:19:32 +0300 Subject: [PATCH] [#131] pool: Limit session lifetime in `openDefaultSession` method Call `createSessionTokenForDuration` function for session opening in `pool.openDefaultSession` method in order to limit session lifetime according to pool configuration (`SessionExpirationDuration`). Signed-off-by: Leonard Lyubich --- pool/pool.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pool/pool.go b/pool/pool.go index ee6ff7f..f516024 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -608,7 +608,7 @@ func (p *pool) initCallContext(ctx *callContext, cfg *callConfig) error { ctx.endpoint = cp.address ctx.client = cp.client - if ctx.sessionTarget == nil && cfg.stoken != nil { + if ctx.sessionTarget != nil && cfg.stoken != nil { ctx.sessionTarget(*cfg.stoken) } @@ -649,11 +649,7 @@ func (p *pool) openDefaultSession(ctx *callContext) error { } // open new session - var cliPrm client.CreateSessionPrm - - cliPrm.SetExp(math.MaxUint32) - - cliRes, err := ctx.client.CreateSession(ctx, cliPrm) + cliRes, err := createSessionTokenForDuration(ctx, ctx.client, p.stokenDuration) if err != nil { return fmt.Errorf("session API client: %w", err) }