Skip to content

Commit 52dc4bd

Browse files
committed
session: pass context to NewSession
1 parent aa8080d commit 52dc4bd

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

session/interface.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package session
22

33
import (
4+
"context"
45
"fmt"
56
"time"
67

@@ -190,7 +191,8 @@ type Store interface {
190191
// NewSession creates a new session with the given user-defined
191192
// parameters. The session will remain in the StateReserved state until
192193
// ShiftState is called to update the state.
193-
NewSession(label string, typ Type, expiry time.Time, serverAddr string,
194+
NewSession(ctx context.Context, label string, typ Type,
195+
expiry time.Time, serverAddr string,
194196
devServer bool, perms []bakery.Op, caveats []macaroon.Caveat,
195197
featureConfig FeaturesConfig, privacy bool, linkedGroupID *ID,
196198
flags PrivacyFlags) (*Session, error)

session/kvdb_store.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package session
22

33
import (
44
"bytes"
5+
"context"
56
"encoding/binary"
67
"errors"
78
"fmt"
@@ -187,7 +188,8 @@ func getSessionKey(session *Session) []byte {
187188
// ShiftState is called with StateCreated.
188189
//
189190
// NOTE: this is part of the Store interface.
190-
func (db *BoltStore) NewSession(label string, typ Type, expiry time.Time,
191+
func (db *BoltStore) NewSession(_ context.Context, label string, typ Type,
192+
expiry time.Time,
191193
serverAddr string, devServer bool, perms []bakery.Op,
192194
caveats []macaroon.Caveat, featureConfig FeaturesConfig, privacy bool,
193195
linkedGroupID *ID, flags PrivacyFlags) (*Session, error) {

session/store_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package session
22

33
import (
4+
"context"
45
"testing"
56
"time"
67

@@ -372,7 +373,8 @@ func reserveSession(db Store, label string,
372373
mod(opts)
373374
}
374375

375-
return db.NewSession(label, opts.sessType,
376+
return db.NewSession(
377+
context.Background(), label, opts.sessType,
376378
time.Date(99999, 1, 1, 0, 0, 0, 0, time.UTC),
377379
"foo.bar.baz:1234", true, nil, nil, nil, true, opts.groupID,
378380
[]PrivacyFlag{ClearPubkeys},

session_rpcserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (s *sessionRpcServer) AddSession(ctx context.Context,
309309
}
310310

311311
sess, err := s.cfg.db.NewSession(
312-
req.Label, typ, expiry, req.MailboxServerAddr,
312+
ctx, req.Label, typ, expiry, req.MailboxServerAddr,
313313
req.DevServer, uniquePermissions, caveats, nil, false, nil,
314314
session.PrivacyFlags{},
315315
)
@@ -1121,7 +1121,7 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context,
11211121
}
11221122

11231123
sess, err := s.cfg.db.NewSession(
1124-
req.Label, session.TypeAutopilot, expiry,
1124+
ctx, req.Label, session.TypeAutopilot, expiry,
11251125
req.MailboxServerAddr, req.DevServer, perms, caveats,
11261126
clientConfig, privacy, linkedGroupID, privacyFlags,
11271127
)

0 commit comments

Comments
 (0)