Skip to content

Commit

Permalink
Background Jobs (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Oct 8, 2023
1 parent b8cf1c2 commit dcabfc8
Show file tree
Hide file tree
Showing 37 changed files with 1,146 additions and 95 deletions.
21 changes: 19 additions & 2 deletions backend/pkg/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package pkg

type ResourceGraphType string
type BackgroundJobStatus string
type BackgroundJobType string
type BackgroundJobSchedule string

const (
ResourceListPageSize int = 20
Expand All @@ -10,13 +13,27 @@ const (
ContextKeyTypeLogger string = "LOGGER"
ContextKeyTypeEventBusServer string = "EVENT_BUS_SERVER"

ContextKeyTypeAuthUsername string = "AUTH_USERNAME"
ContextKeyTypeAuthToken string = "AUTH_TOKEN"
ContextKeyTypeAuthUsername string = "AUTH_USERNAME"
ContextKeyTypeAuthToken string = "AUTH_TOKEN"
ContextKeyTypeBackgroundJobID string = "BACKGROUND_JOB_ID"

FhirResourceTypeComposition string = "Composition"

ResourceGraphTypeMedicalHistory ResourceGraphType = "MedicalHistory"
ResourceGraphTypeAddressBook ResourceGraphType = "AddressBook"
ResourceGraphTypeMedications ResourceGraphType = "Medications"
ResourceGraphTypeBillingReport ResourceGraphType = "BillingReport"

BackgroundJobStatusReady BackgroundJobStatus = "STATUS_READY"
BackgroundJobStatusLocked BackgroundJobStatus = "STATUS_LOCKED"
BackgroundJobStatusFailed BackgroundJobStatus = "STATUS_FAILED"
BackgroundJobStatusDone BackgroundJobStatus = "STATUS_DONE"

BackgroundJobTypeSync BackgroundJobType = "SYNC"
BackgroundJobTypeScheduledSync BackgroundJobType = "SCHEDULED_SYNC"

BackgroundJobScheduleDaily BackgroundJobSchedule = "DAILY"
BackgroundJobScheduleWeekly BackgroundJobSchedule = "WEEKLY"
BackgroundJobScheduleBiWeekly BackgroundJobSchedule = "BIWEEKLY"
BackgroundJobScheduleMonthly BackgroundJobSchedule = "MONTHLY"
)
7 changes: 7 additions & 0 deletions backend/pkg/database/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ type DatabaseRepository interface {
CreateGlossaryEntry(ctx context.Context, glossaryEntry *models.Glossary) error
GetGlossaryEntry(ctx context.Context, code string, codeSystem string) (*models.Glossary, error)

//background jobs
CreateBackgroundJob(ctx context.Context, backgroundJob *models.BackgroundJob) error
GetBackgroundJob(ctx context.Context, backgroundJobId string) (*models.BackgroundJob, error)
UpdateBackgroundJob(ctx context.Context, backgroundJob *models.BackgroundJob) error
ListBackgroundJobs(ctx context.Context, queryOptions models.BackgroundJobQueryOptions) ([]models.BackgroundJob, error)

//settings
LoadUserSettings(ctx context.Context) (*models.UserSettings, error)
SaveUserSettings(context.Context, *models.UserSettings) error
PopulateDefaultUserSettings(ctx context.Context, userId uuid.UUID) error

//used by fasten-sources Clients
UpsertRawResource(ctx context.Context, sourceCredentials sourcePkg.SourceCredential, rawResource sourcePkg.RawResourceFhir) (bool, error)
BackgroundJobCheckpoint(ctx context.Context, checkpointData map[string]interface{}, errorData map[string]interface{})
}
68 changes: 62 additions & 6 deletions backend/pkg/database/mock/mock_database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dcabfc8

Please sign in to comment.