mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-10 06:14:22 +00:00
Add task api and resource locking ability
This commit is contained in:
committed by
Lorenzo Bolla
parent
e63d74dff2
commit
6ab5e60833
+14
-4
@@ -20,15 +20,15 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
// We use a goroutine to count the number of
|
||||
// concurrent requests. When no more requests are
|
||||
// running, we close the database to free the lock.
|
||||
requests := make(chan dbRequest)
|
||||
dbRequests = make(chan dbRequest)
|
||||
|
||||
go acquireDatabase(requests)
|
||||
go acquireDatabase()
|
||||
|
||||
router.Use(func(c *gin.Context) {
|
||||
var err error
|
||||
|
||||
errCh := make(chan error)
|
||||
requests <- dbRequest{acquiredb, errCh}
|
||||
dbRequests <- dbRequest{acquiredb, errCh}
|
||||
|
||||
err = <-errCh
|
||||
if err != nil {
|
||||
@@ -37,7 +37,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
}
|
||||
|
||||
defer func() {
|
||||
requests <- dbRequest{releasedb, errCh}
|
||||
dbRequests <- dbRequest{releasedb, errCh}
|
||||
err = <-errCh
|
||||
if err != nil {
|
||||
c.AbortWithError(500, err)
|
||||
@@ -111,6 +111,16 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
{
|
||||
root.GET("/graph.:ext", apiGraph)
|
||||
}
|
||||
{
|
||||
root.GET("/tasks", apiTasksList)
|
||||
root.POST("/tasks-clear", apiTasksClear)
|
||||
root.GET("/tasks-wait", apiTasksWait)
|
||||
root.GET("/tasks/:id/wait", apiTasksWaitForTaskByID)
|
||||
root.GET("/tasks/:id/output", apiTasksOutputShow)
|
||||
root.GET("/tasks/:id/detail", apiTasksDetailShow)
|
||||
root.GET("/tasks/:id", apiTasksShow)
|
||||
root.DELETE("/tasks/:id", apiTasksDelete)
|
||||
}
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user