[#28] Client: Apply code optimizations

Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
Pavel Gross 2024-11-18 16:57:20 +03:00
parent 766f61a5f7
commit 749000a090
57 changed files with 845 additions and 1116 deletions

View file

@ -9,14 +9,15 @@ internal interface ISessionProvider
internal sealed class SessionProvider(ClientContext envCtx)
{
public async ValueTask<Session.SessionToken> GetOrCreateSession(ISessionToken args, CallContext ctx)
public async Task<FrostFsSessionToken> CreateSession(ISessionToken args, CallContext ctx)
{
if (args.SessionToken is null)
{
return await envCtx.Client.CreateSessionInternalAsync(new PrmSessionCreate(uint.MaxValue, ctx))
.ConfigureAwait(false);
}
var token = await GetDefaultSession(args, ctx).ConfigureAwait(false);
return new Session.SessionToken().Deserialize(args.SessionToken.Token);
return new FrostFsSessionToken(token);
}
internal async Task<Session.SessionToken> GetDefaultSession(ISessionToken args, CallContext ctx)
{
return await envCtx.Client.CreateSessionInternalAsync(new PrmSessionCreate(uint.MaxValue, ctx)).ConfigureAwait(false);
}
}