[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-02-16 18:19:32 +03:00 committed by LeL
parent 28b49419ab
commit 1130c1f5a6

View file

@ -608,7 +608,7 @@ func (p *pool) initCallContext(ctx *callContext, cfg *callConfig) error {
ctx.endpoint = cp.address ctx.endpoint = cp.address
ctx.client = cp.client ctx.client = cp.client
if ctx.sessionTarget == nil && cfg.stoken != nil { if ctx.sessionTarget != nil && cfg.stoken != nil {
ctx.sessionTarget(*cfg.stoken) ctx.sessionTarget(*cfg.stoken)
} }
@ -649,11 +649,7 @@ func (p *pool) openDefaultSession(ctx *callContext) error {
} }
// open new session // open new session
var cliPrm client.CreateSessionPrm cliRes, err := createSessionTokenForDuration(ctx, ctx.client, p.stokenDuration)
cliPrm.SetExp(math.MaxUint32)
cliRes, err := ctx.client.CreateSession(ctx, cliPrm)
if err != nil { if err != nil {
return fmt.Errorf("session API client: %w", err) return fmt.Errorf("session API client: %w", err)
} }