mirror of https://github.com/dexidp/dex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
464 B
24 lines
464 B
package sql |
|
|
|
import ( |
|
"fmt" |
|
"time" |
|
) |
|
|
|
type gc struct { |
|
now func() time.Time |
|
conn *conn |
|
} |
|
|
|
var tablesWithGC = []string{"auth_request", "auth_code"} |
|
|
|
func (gc gc) run() error { |
|
for _, table := range tablesWithGC { |
|
_, err := gc.conn.Exec(`delete from `+table+` where expiry < $1`, gc.now()) |
|
if err != nil { |
|
return fmt.Errorf("gc %s: %v", table, err) |
|
} |
|
// TODO(ericchiang): when we have levelled logging print how many rows were gc'd |
|
} |
|
return nil |
|
}
|
|
|