-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aleksei Pleshakov
committed
Oct 29, 2024
1 parent
fa9a2d6
commit cf3da7e
Showing
17 changed files
with
834 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package common | ||
|
||
import ( | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
"log" | ||
"time" | ||
) | ||
|
||
func CreateGRPCClient(endpoint string) *grpc.ClientConn { | ||
var opts []grpc.DialOption | ||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
for range 5 { | ||
conn, err := grpc.NewClient(endpoint, opts...) | ||
if err == nil { | ||
return conn | ||
} | ||
time.Sleep(time.Second) // Wait before retrying | ||
} | ||
log.Panicln("failed to dial") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package queries | ||
|
||
import ( | ||
"fmt" | ||
"ydbcp/internal/types" | ||
) | ||
|
||
var ( | ||
ListSchedulesQuery = fmt.Sprintf( | ||
`$last_successful_backup_id = SELECT schedule_id, MAX(b.completed_at) AS recovery_point, MAX_BY(b.id, b.completed_at) AS last_successful_backup_id FROM Backups AS b WHERE b.status = '%s' GROUP BY schedule_id; | ||
$last_backup_id = SELECT schedule_id AS schedule_id_2, MAX_BY(b.id, b.completed_at) AS last_backup_id FROM Backups AS b GROUP BY schedule_id; | ||
SELECT * FROM BackupSchedules AS schedules | ||
LEFT JOIN $last_successful_backup_id AS b1 ON schedules.id = b1.schedule_id | ||
LEFT JOIN $last_backup_id AS b2 ON schedules.id = b2.schedule_id_2 | ||
`, types.BackupStateAvailable, | ||
) | ||
GetScheduleQuery = fmt.Sprintf( | ||
`$rpo_info = SELECT | ||
<| | ||
recovery_point: MAX(b.completed_at), | ||
last_successful_backup_id: MAX_BY(b.id, b.completed_at) | ||
|> FROM Backups AS b WHERE b.status = '%s' AND b.schedule_id = $schedule_id; | ||
$last_backup_id = SELECT MAX_BY(b.id, b.completed_at) AS last_backup_id FROM Backups AS b WHERE b.schedule_id = $schedule_id; | ||
SELECT s.*, $last_backup_id AS last_backup_id, $rpo_info.recovery_point AS recovery_point, $rpo_info.last_successful_backup_id AS last_successful_backup_id FROM BackupSchedules AS s WHERE s.id = $schedule_id | ||
`, types.BackupStateAvailable, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.