Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
4421cd58
Verified
Commit
4421cd58
authored
7 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: add handler to reset application state
parent
9ebc5f4c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/tank/web.go
+23
-0
23 additions, 0 deletions
cmd/tank/web.go
with
23 additions
and
0 deletions
cmd/tank/web.go
+
23
−
0
View file @
4421cd58
...
...
@@ -46,6 +46,7 @@ const (
WebAPIDocsPrefix
=
"/api/docs/"
WebAPIv1Prefix
=
"/api/v1/"
HealthzEndpoint
=
"/healthz"
ResetEndpoint
=
"/api/v1/debug/application-state"
)
func
apache2CombinedLogger
(
param
gin
.
LogFormatterParams
)
string
{
...
...
@@ -140,6 +141,24 @@ func healthzHandler(c *gin.Context, st *store.Store, im *importer.Importer) {
c
.
JSON
(
code
,
h
)
}
// resetApplicationStateHandler purges all the data
//
// @Summary Purges all the data
// @Description Purges all the data and returns the deleted count for each of the models
// @Produce json
// @Success 200 {object} store.DeleteCounter
// @Failure 500 {object} apiV1.ErrorResponse
// @Router /api/v1/debug/application-state [delete]
func
resetApplicationStateHandler
(
c
*
gin
.
Context
,
st
*
store
.
Store
)
{
deleteCounter
,
err
:=
st
.
ResetState
()
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
apiV1
.
ErrorResponse
{
Error
:
err
.
Error
()})
}
c
.
JSON
(
http
.
StatusOK
,
deleteCounter
)
}
func
runWeb
(
ln
net
.
Listener
,
st
*
store
.
Store
,
im
*
importer
.
Importer
,
conf
WebConfig
)
error
{
gin
.
SetMode
(
gin
.
ReleaseMode
)
...
...
@@ -174,6 +193,10 @@ func runWeb(ln net.Listener, st *store.Store, im *importer.Importer, conf WebCon
r
.
GET
(
HealthzEndpoint
,
func
(
c
*
gin
.
Context
)
{
healthzHandler
(
c
,
st
,
im
)
})
r
.
GET
(
WebAPIDocsPrefix
+
"*any"
,
ginSwagger
.
WrapHandler
(
swaggerFiles
.
Handler
))
if
os
.
Getenv
(
"OPERATION_MODE"
)
==
"tests"
{
r
.
DELETE
(
ResetEndpoint
,
func
(
c
*
gin
.
Context
)
{
resetApplicationStateHandler
(
c
,
st
)
})
}
srv
:=
&
http
.
Server
{
Handler
:
r
,
WriteTimeout
:
12
*
time
.
Hour
,
...
...
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