sessionStore returns the backend-owned session store, opening it on first use. The store is shared by the initial runtime and by every runtime spawned by [localBackend.Spawner].
(ctx context.Context, req runtime.CreateSessionRequest)
| 90 | // first use. The store is shared by the initial runtime and by every |
| 91 | // runtime spawned by [localBackend.Spawner]. |
| 92 | func (b *localBackend) sessionStore(ctx context.Context, req runtime.CreateSessionRequest) (session.Store, error) { |
| 93 | b.storeOnce.Do(func() { |
| 94 | sessionDB, err := pathx.ExpandHomeDir(req.SessionDB) |
| 95 | if err != nil { |
| 96 | b.storeErr = err |
| 97 | return |
| 98 | } |
| 99 | store, err := session.NewSQLiteSessionStore(context.WithoutCancel(ctx), sessionDB) |
| 100 | if err != nil { |
| 101 | b.storeErr = fmt.Errorf("creating session store: %w", err) |
| 102 | return |
| 103 | } |
| 104 | b.store = store |
| 105 | }) |
| 106 | return b.store, b.storeErr |
| 107 | } |
| 108 | |
| 109 | func (b *localBackend) CreateSession(ctx context.Context, loaded *teamloader.LoadResult, req runtime.CreateSessionRequest) (runtime.Runtime, *session.Session, func(), error) { |
| 110 | store, err := b.sessionStore(ctx, req) |
no test coverage detected