Skip to content

Commit

Permalink
Adding psql update
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Maertz <[email protected]>
  • Loading branch information
bobmaertz committed Feb 4, 2025
1 parent bcf402a commit a22644a
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions storage/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c *conn) Close() error {
}

func (c *conn) GarbageCollect(ctx context.Context, now time.Time) (result storage.GCResult, err error) {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
authRequests, err := c.listAuthRequests(ctx)
if err != nil {
Expand Down Expand Up @@ -125,7 +125,7 @@ func (c *conn) GetAuthRequest(ctx context.Context, id string) (a storage.AuthReq
}

func (c *conn) UpdateAuthRequest(ctx context.Context, id string, updater func(a storage.AuthRequest) (storage.AuthRequest, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keyID(authRequestPrefix, id), func(currentValue []byte) ([]byte, error) {
var current AuthRequest
Expand All @@ -143,7 +143,7 @@ func (c *conn) UpdateAuthRequest(ctx context.Context, id string, updater func(a
}

func (c *conn) DeleteAuthRequest(ctx context.Context, id string) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.deleteKey(ctx, keyID(authRequestPrefix, id))
}
Expand All @@ -164,7 +164,7 @@ func (c *conn) GetAuthCode(ctx context.Context, id string) (a storage.AuthCode,
}

func (c *conn) DeleteAuthCode(ctx context.Context, id string) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.deleteKey(ctx, keyID(authCodePrefix, id))
}
Expand All @@ -184,7 +184,7 @@ func (c *conn) GetRefresh(ctx context.Context, id string) (r storage.RefreshToke
}

func (c *conn) UpdateRefreshToken(ctx context.Context, id string, updater func(old storage.RefreshToken) (storage.RefreshToken, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keyID(refreshTokenPrefix, id), func(currentValue []byte) ([]byte, error) {
var current RefreshToken
Expand All @@ -202,7 +202,7 @@ func (c *conn) UpdateRefreshToken(ctx context.Context, id string, updater func(o
}

func (c *conn) DeleteRefresh(ctx context.Context, id string) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.deleteKey(ctx, keyID(refreshTokenPrefix, id))
}
Expand Down Expand Up @@ -236,7 +236,7 @@ func (c *conn) GetClient(ctx context.Context, id string) (cli storage.Client, er
}

func (c *conn) UpdateClient(ctx context.Context, id string, updater func(old storage.Client) (storage.Client, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keyID(clientPrefix, id), func(currentValue []byte) ([]byte, error) {
var current storage.Client
Expand All @@ -254,7 +254,7 @@ func (c *conn) UpdateClient(ctx context.Context, id string, updater func(old sto
}

func (c *conn) DeleteClient(ctx context.Context, id string) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.deleteKey(ctx, keyID(clientPrefix, id))
}
Expand Down Expand Up @@ -288,7 +288,7 @@ func (c *conn) GetPassword(ctx context.Context, email string) (p storage.Passwor
}

func (c *conn) UpdatePassword(ctx context.Context, email string, updater func(p storage.Password) (storage.Password, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keyEmail(passwordPrefix, email), func(currentValue []byte) ([]byte, error) {
var current storage.Password
Expand All @@ -306,7 +306,7 @@ func (c *conn) UpdatePassword(ctx context.Context, email string, updater func(p
}

func (c *conn) DeletePassword(ctx context.Context, email string) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.deleteKey(ctx, keyEmail(passwordPrefix, email))
}
Expand All @@ -333,7 +333,7 @@ func (c *conn) CreateOfflineSessions(ctx context.Context, s storage.OfflineSessi
}

func (c *conn) UpdateOfflineSessions(ctx context.Context, userID string, connID string, updater func(s storage.OfflineSessions) (storage.OfflineSessions, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keySession(userID, connID), func(currentValue []byte) ([]byte, error) {
var current OfflineSessions
Expand Down Expand Up @@ -361,7 +361,7 @@ func (c *conn) GetOfflineSessions(ctx context.Context, userID string, connID str
}

func (c *conn) DeleteOfflineSessions(ctx context.Context, userID string, connID string) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.deleteKey(ctx, keySession(userID, connID))
}
Expand All @@ -378,7 +378,7 @@ func (c *conn) GetConnector(ctx context.Context, id string) (conn storage.Connec
}

func (c *conn) UpdateConnector(ctx context.Context, id string, updater func(s storage.Connector) (storage.Connector, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keyID(connectorPrefix, id), func(currentValue []byte) ([]byte, error) {
var current storage.Connector
Expand All @@ -396,7 +396,7 @@ func (c *conn) UpdateConnector(ctx context.Context, id string, updater func(s st
}

func (c *conn) DeleteConnector(ctx context.Context, id string) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.deleteKey(ctx, keyID(connectorPrefix, id))
}
Expand Down Expand Up @@ -432,7 +432,7 @@ func (c *conn) GetKeys(ctx context.Context) (keys storage.Keys, err error) {
}

func (c *conn) UpdateKeys(ctx context.Context, updater func(old storage.Keys) (storage.Keys, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keysName, func(currentValue []byte) ([]byte, error) {
var current storage.Keys
Expand Down Expand Up @@ -616,7 +616,7 @@ func (c *conn) listDeviceTokens(ctx context.Context) (deviceTokens []DeviceToken
}

func (c *conn) UpdateDeviceToken(ctx context.Context, deviceCode string, updater func(old storage.DeviceToken) (storage.DeviceToken, error)) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultStorageTimeout)
defer cancel()
return c.txnUpdate(ctx, keyID(deviceTokenPrefix, deviceCode), func(currentValue []byte) ([]byte, error) {
var current DeviceToken
Expand Down

0 comments on commit a22644a

Please sign in to comment.