Add first set of import/export APIs

This commit is contained in:
Daniel
2023-09-19 16:10:10 +02:00
parent 7c3925db32
commit cf3bd9f671
8 changed files with 743 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ import (
// core:profiles/<scope>/<id>
// cache:profiles/index/<identifier>/<value>
const profilesDBPath = "core:profiles/"
const ProfilesDBPath = "core:profiles/"
var profileDB = database.NewInterface(&database.Options{
Local: true,
@@ -28,17 +28,17 @@ func makeScopedID(source profileSource, id string) string {
}
func makeProfileKey(source profileSource, id string) string {
return profilesDBPath + string(source) + "/" + id
return ProfilesDBPath + string(source) + "/" + id
}
func registerValidationDBHook() (err error) {
_, err = database.RegisterHook(query.New(profilesDBPath), &databaseHook{})
_, err = database.RegisterHook(query.New(ProfilesDBPath), &databaseHook{})
return
}
func startProfileUpdateChecker() error {
module.StartServiceWorker("update active profiles", 0, func(ctx context.Context) (err error) {
profilesSub, err := profileDB.Subscribe(query.New(profilesDBPath))
profilesSub, err := profileDB.Subscribe(query.New(ProfilesDBPath))
if err != nil {
return err
}
@@ -59,7 +59,7 @@ func startProfileUpdateChecker() error {
}
// Get active profile.
activeProfile := getActiveProfile(strings.TrimPrefix(r.Key(), profilesDBPath))
activeProfile := getActiveProfile(strings.TrimPrefix(r.Key(), ProfilesDBPath))
if activeProfile == nil {
// Don't do any additional actions if the profile is not active.
continue profileFeed