Skip to content

Commit 37399cc

Browse files
authored
feat: task logs for database operations (#36)
2 parents 183aadc + 1950037 commit 37399cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+8792
-10199
lines changed

api/design/api.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ var _ = g.Service("control-plane", func() {
151151
g.Method("create-database", func() {
152152
g.Description("Creates a new database in the cluster.")
153153
g.Payload(CreateDatabaseRequest)
154-
g.Result(Database, func() {
155-
g.View("default")
156-
})
154+
g.Result(CreateDatabaseResponse)
157155
g.Error("cluster_not_initialized")
158156
g.Error("invalid_input")
159157
g.Error("database_already_exists")
@@ -196,9 +194,7 @@ var _ = g.Service("control-plane", func() {
196194
})
197195
g.Attribute("request", UpdateDatabaseRequest)
198196
})
199-
g.Result(Database, func() {
200-
g.View("default")
201-
})
197+
g.Result(UpdateDatabaseResponse)
202198
g.Error("cluster_not_initialized")
203199
g.Error("not_found")
204200
g.Error("database_not_modifiable")
@@ -221,6 +217,7 @@ var _ = g.Service("control-plane", func() {
221217

222218
g.Required("database_id")
223219
})
220+
g.Result(DeleteDatabaseResponse)
224221
g.Error("cluster_not_initialized")
225222
g.Error("not_found")
226223
g.Error("database_not_modifiable")
@@ -230,8 +227,8 @@ var _ = g.Service("control-plane", func() {
230227
})
231228
})
232229

233-
g.Method("initiate-database-backup", func() {
234-
g.Description("Initiates a backup for a database.")
230+
g.Method("backup-database-node", func() {
231+
g.Description("Initiates a backup for a database node.")
235232
g.Payload(func() {
236233
g.Attribute("database_id", g.String, func() {
237234
g.Format(g.FormatUUID)
@@ -246,7 +243,7 @@ var _ = g.Service("control-plane", func() {
246243

247244
g.Required("database_id", "node_name", "options")
248245
})
249-
g.Result(Task)
246+
g.Result(BackupDatabaseNodeResponse)
250247
g.Error("cluster_not_initialized")
251248
g.Error("not_found")
252249
g.Error("database_not_modifiable")
@@ -334,13 +331,13 @@ var _ = g.Service("control-plane", func() {
334331
g.Description("ID of the task to get log for.")
335332
g.Example("3c875a27-f6a6-4c1c-ba5f-6972fb1fc348")
336333
})
337-
g.Attribute("after_line_id", g.String, func() {
334+
g.Attribute("after_entry_id", g.String, func() {
338335
g.Format(g.FormatUUID)
339-
g.Description("ID of the line to start from.")
336+
g.Description("ID of the entry to start from.")
340337
g.Example("3c875a27-f6a6-4c1c-ba5f-6972fb1fc348")
341338
})
342339
g.Attribute("limit", g.Int, func() {
343-
g.Description("Maximum number of lines to return.")
340+
g.Description("Maximum number of entries to return.")
344341
g.Example(100)
345342
})
346343

@@ -352,7 +349,7 @@ var _ = g.Service("control-plane", func() {
352349

353350
g.HTTP(func() {
354351
g.GET("/databases/{database_id}/tasks/{task_id}/log")
355-
g.Param("after_line_id")
352+
g.Param("after_entry_id")
356353
g.Param("limit")
357354
})
358355
})

api/design/database.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,15 @@ var CreateDatabaseRequest = g.Type("CreateDatabaseRequest", func() {
480480
})
481481
})
482482

483+
var CreateDatabaseResponse = g.Type("CreateDatabaseResponse", func() {
484+
g.Attribute("task", Task, func() {
485+
g.Description("The task that will create this database.")
486+
})
487+
g.Attribute("database", Database, func() {
488+
g.Description("The database being created.")
489+
})
490+
})
491+
483492
var UpdateDatabaseRequest = g.Type("UpdateDatabaseRequest", func() {
484493
g.Attribute("tenant_id", g.String, func() {
485494
g.Format(g.FormatUUID)
@@ -491,6 +500,27 @@ var UpdateDatabaseRequest = g.Type("UpdateDatabaseRequest", func() {
491500
})
492501
})
493502

503+
var UpdateDatabaseResponse = g.Type("UpdateDatabaseResponse", func() {
504+
g.Attribute("task", Task, func() {
505+
g.Description("The task that will update this database.")
506+
})
507+
g.Attribute("database", Database, func() {
508+
g.Description("The database being updated.")
509+
})
510+
})
511+
512+
var DeleteDatabaseResponse = g.Type("DeleteDatabaseResponse", func() {
513+
g.Attribute("task", Task, func() {
514+
g.Description("The task that will delete this database.")
515+
})
516+
})
517+
518+
var BackupDatabaseNodeResponse = g.Type("BackupDatabaseNodeResponse", func() {
519+
g.Attribute("task", Task, func() {
520+
g.Description("The task that will backup this database node.")
521+
})
522+
})
523+
494524
var RestoreDatabaseRequest = g.Type("RestoreDatabaseRequest", func() {
495525
g.Attribute("restore_config", RestoreConfigSpec, func() {
496526
g.Description("Configuration for the restore process.")
@@ -505,12 +535,15 @@ var RestoreDatabaseRequest = g.Type("RestoreDatabaseRequest", func() {
505535
})
506536

507537
var RestoreDatabaseResponse = g.Type("RestoreDatabaseResponse", func() {
538+
g.Attribute("task", Task, func() {
539+
g.Description("The task that will restore this database.")
540+
})
541+
g.Attribute("node_tasks", g.ArrayOf(Task), func() {
542+
g.Description("The tasks that will restore each database node.")
543+
})
508544
g.Attribute("database", Database, func() {
509545
g.Description("The database being restored.")
510546
})
511-
g.Attribute("tasks", g.ArrayOf(Task), func() {
512-
g.Description("The restore tasks that were created to restore this database.")
513-
})
514547
})
515548

516549
var ExtraVolumesSpec = g.Type("ExtraVolumesSpec", func() {

api/design/task.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import (
55
)
66

77
var Task = g.Type("Task", func() {
8+
g.Attribute("parent_id", g.String, func() {
9+
g.Format(g.FormatUUID)
10+
g.Description("The parent task ID of the task.")
11+
g.Example("439eb515-e700-4740-b508-4a3f12ec4f83")
12+
})
813
g.Attribute("database_id", g.String, func() {
914
g.Format(g.FormatUUID)
1015
g.Description("The database ID of the task.")
@@ -56,6 +61,26 @@ var Task = g.Type("Task", func() {
5661
g.Required("database_id", "task_id", "created_at", "type", "status")
5762
})
5863

64+
var TaskLogEntry = g.Type("TaskLogEntry", func() {
65+
g.Attribute("timestamp", g.String, func() {
66+
g.Format(g.FormatDateTime)
67+
g.Description("The timestamp of the log entry.")
68+
g.Example("2025-05-29T15:43:13Z")
69+
})
70+
g.Attribute("message", g.String, func() {
71+
g.Description("The log message.")
72+
g.Example("task started")
73+
})
74+
g.Attribute("fields", g.MapOf(g.String, g.Any), func() {
75+
g.Description("Additional fields for the log entry.")
76+
g.Example(map[string]any{
77+
"status": "creating",
78+
"option.enabled": true,
79+
})
80+
})
81+
g.Required("timestamp", "message")
82+
})
83+
5984
var TaskLog = g.Type("TaskLog", func() {
6085
g.Attribute("database_id", g.String, func() {
6186
g.Format(g.FormatUUID)
@@ -72,15 +97,14 @@ var TaskLog = g.Type("TaskLog", func() {
7297
g.Description("The status of the task.")
7398
g.Example("pending")
7499
})
75-
g.Attribute("last_line_id", g.String, func() {
100+
g.Attribute("last_entry_id", g.String, func() {
76101
g.Format(g.FormatUUID)
77-
g.Description("The ID of the last line in the task log.")
102+
g.Description("The ID of the last entry in the task log.")
78103
g.Example("3c875a27-f6a6-4c1c-ba5f-6972fb1fc348")
79104
})
80-
g.Attribute("lines", g.ArrayOf(g.String), func() {
81-
g.Description("The lines of the task log.")
82-
g.Example([]string{"Task started", "Task completed"})
105+
g.Attribute("entries", g.ArrayOf(TaskLogEntry), func() {
106+
g.Description("Entries in the task log.")
83107
})
84108

85-
g.Required("database_id", "task_id", "task_status", "lines")
109+
g.Required("database_id", "task_id", "task_status", "entries")
86110
})

api/gen/control_plane/client.go

Lines changed: 55 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)