Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
m-team
oidc
mytoken
server
Commits
bc9e1250
Commit
bc9e1250
authored
4 years ago
by
Gabriel Zachmann
Browse files
Options
Downloads
Patches
Plain Diff
add db garbage collector
parent
d2c8e58f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/dbGarbageCollector/main.go
+29
-0
29 additions, 0 deletions
cmd/dbGarbageCollector/main.go
cmd/mytoken/main.go
+3
-4
3 additions, 4 deletions
cmd/mytoken/main.go
with
32 additions
and
4 deletions
cmd/dbGarbageCollector/main.go
0 → 100644
+
29
−
0
View file @
bc9e1250
package
main
import
(
"log"
"github.com/zachmann/mytoken/internal/config"
"github.com/zachmann/mytoken/internal/db"
)
func
main
()
{
config
.
Load
()
if
err
:=
db
.
Connect
();
err
!=
nil
{
log
.
Fatal
(
err
)
}
deleteExpiredPollingCodes
()
deleteExpiredAuthInfo
()
}
func
deleteExpiredPollingCodes
()
{
if
_
,
err
:=
db
.
DB
()
.
Exec
(
`DELETE FROM PollingCodes WHERE expires_at < CURRENT_TIMESTAMP()`
);
err
!=
nil
{
log
.
Printf
(
"%s"
,
err
)
}
}
func
deleteExpiredAuthInfo
()
{
if
_
,
err
:=
db
.
DB
()
.
Exec
(
`DELETE FROM AuthInfo WHERE expires_at < CURRENT_TIMESTAMP()`
);
err
!=
nil
{
log
.
Printf
(
"%s"
,
err
)
}
}
This diff is collapsed.
Click to expand it.
cmd/mytoken/main.go
+
3
−
4
View file @
bc9e1250
...
...
@@ -3,7 +3,7 @@ package main
import
(
"github.com/zachmann/mytoken/internal/config"
"github.com/zachmann/mytoken/internal/db"
"github.com/zachmann/mytoken/internal/endpoints/configuration"
configurationEndpoint
"github.com/zachmann/mytoken/internal/endpoints/configuration"
"github.com/zachmann/mytoken/internal/jws"
"github.com/zachmann/mytoken/internal/oidc/authcode"
"github.com/zachmann/mytoken/internal/server"
...
...
@@ -11,10 +11,9 @@ import (
func
main
()
{
config
.
Load
()
configuration
.
Init
()
configuration
Endpoint
.
Init
()
authcode
.
Init
()
err
:=
db
.
Connect
()
if
err
!=
nil
{
if
err
:=
db
.
Connect
();
err
!=
nil
{
panic
(
err
)
}
jws
.
LoadKey
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment