Changeset 652 in code for trunk/db_sqlite.go
- Timestamp:
- Oct 18, 2021, 5:15:15 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/db_sqlite.go
r645 r652 209 209 } 210 210 211 func (db *SqliteDB) Stats( ) (*DatabaseStats, error) {211 func (db *SqliteDB) Stats(ctx context.Context) (*DatabaseStats, error) { 212 212 db.lock.RLock() 213 213 defer db.lock.RUnlock() 214 214 215 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)215 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 216 216 defer cancel() 217 217 … … 235 235 } 236 236 237 func (db *SqliteDB) ListUsers( ) ([]User, error) {237 func (db *SqliteDB) ListUsers(ctx context.Context) ([]User, error) { 238 238 db.lock.RLock() 239 239 defer db.lock.RUnlock() 240 240 241 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)241 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 242 242 defer cancel() 243 243 … … 267 267 } 268 268 269 func (db *SqliteDB) GetUser( username string) (*User, error) {269 func (db *SqliteDB) GetUser(ctx context.Context, username string) (*User, error) { 270 270 db.lock.RLock() 271 271 defer db.lock.RUnlock() 272 272 273 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)273 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 274 274 defer cancel() 275 275 … … 288 288 } 289 289 290 func (db *SqliteDB) StoreUser( user *User) error {291 db.lock.Lock() 292 defer db.lock.Unlock() 293 294 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)290 func (db *SqliteDB) StoreUser(ctx context.Context, user *User) error { 291 db.lock.Lock() 292 defer db.lock.Unlock() 293 294 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 295 295 defer cancel() 296 296 … … 324 324 } 325 325 326 func (db *SqliteDB) DeleteUser( id int64) error {327 db.lock.Lock() 328 defer db.lock.Unlock() 329 330 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)326 func (db *SqliteDB) DeleteUser(ctx context.Context, id int64) error { 327 db.lock.Lock() 328 defer db.lock.Unlock() 329 330 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 331 331 defer cancel() 332 332 … … 372 372 } 373 373 374 func (db *SqliteDB) ListNetworks( userID int64) ([]Network, error) {374 func (db *SqliteDB) ListNetworks(ctx context.Context, userID int64) ([]Network, error) { 375 375 db.lock.RLock() 376 376 defer db.lock.RUnlock() 377 377 378 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)378 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 379 379 defer cancel() 380 380 … … 421 421 } 422 422 423 func (db *SqliteDB) StoreNetwork( userID int64, network *Network) error {424 db.lock.Lock() 425 defer db.lock.Unlock() 426 427 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)423 func (db *SqliteDB) StoreNetwork(ctx context.Context, userID int64, network *Network) error { 424 db.lock.Lock() 425 defer db.lock.Unlock() 426 427 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 428 428 defer cancel() 429 429 … … 491 491 } 492 492 493 func (db *SqliteDB) DeleteNetwork( id int64) error {494 db.lock.Lock() 495 defer db.lock.Unlock() 496 497 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)493 func (db *SqliteDB) DeleteNetwork(ctx context.Context, id int64) error { 494 db.lock.Lock() 495 defer db.lock.Unlock() 496 497 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 498 498 defer cancel() 499 499 … … 522 522 } 523 523 524 func (db *SqliteDB) ListChannels( networkID int64) ([]Channel, error) {524 func (db *SqliteDB) ListChannels(ctx context.Context, networkID int64) ([]Channel, error) { 525 525 db.lock.RLock() 526 526 defer db.lock.RUnlock() 527 527 528 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)528 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 529 529 defer cancel() 530 530 … … 559 559 } 560 560 561 func (db *SqliteDB) StoreChannel( networkID int64, ch *Channel) error {562 db.lock.Lock() 563 defer db.lock.Unlock() 564 565 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)561 func (db *SqliteDB) StoreChannel(ctx context.Context, networkID int64, ch *Channel) error { 562 db.lock.Lock() 563 defer db.lock.Unlock() 564 565 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 566 566 defer cancel() 567 567 … … 599 599 } 600 600 601 func (db *SqliteDB) DeleteChannel( id int64) error {602 db.lock.Lock() 603 defer db.lock.Unlock() 604 605 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)601 func (db *SqliteDB) DeleteChannel(ctx context.Context, id int64) error { 602 db.lock.Lock() 603 defer db.lock.Unlock() 604 605 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 606 606 defer cancel() 607 607 … … 610 610 } 611 611 612 func (db *SqliteDB) ListDeliveryReceipts( networkID int64) ([]DeliveryReceipt, error) {612 func (db *SqliteDB) ListDeliveryReceipts(ctx context.Context, networkID int64) ([]DeliveryReceipt, error) { 613 613 db.lock.RLock() 614 614 defer db.lock.RUnlock() 615 615 616 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)616 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 617 617 defer cancel() 618 618 … … 643 643 } 644 644 645 func (db *SqliteDB) StoreClientDeliveryReceipts( networkID int64, client string, receipts []DeliveryReceipt) error {646 db.lock.Lock() 647 defer db.lock.Unlock() 648 649 ctx, cancel := context.WithTimeout(c ontext.TODO(), sqliteQueryTimeout)645 func (db *SqliteDB) StoreClientDeliveryReceipts(ctx context.Context, networkID int64, client string, receipts []DeliveryReceipt) error { 646 db.lock.Lock() 647 defer db.lock.Unlock() 648 649 ctx, cancel := context.WithTimeout(ctx, sqliteQueryTimeout) 650 650 defer cancel() 651 651
Note:
See TracChangeset
for help on using the changeset viewer.