Skip to content

Commit

Permalink
sleeps infinitly when done
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillezi committed Oct 8, 2024
1 parent 7306e67 commit d77a153
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

## Overview

`go-hapingest` is a specialized file server designed to simplify bulk importing of FHIR data into a HAPI server. It makes sure that data is bulk imported in the correct order by creating multiple manifests based on what thr resources depends on. It is only made to handle ndjson files, which are commonly used in FHIR bulk imports.
`go-hapingest` is a specialized file server designed to simplify bulk importing of FHIR data into a HAPI server. It makes sure that data is bulk imported in the correct order by creating multiple manifests based on what the resources depends on. It is only made to handle ndjson files, which are commonly used in FHIR bulk imports.

You can run `go-hapingest` as a Docker container, mounting your FHIR data files to the `/fhir-data` directory within the container. This approach simplifies access to large datasets and facilitates their import directly into the HAPI server by letting the HAPI server fetch the content from the fileserver.

Expand All @@ -28,10 +28,11 @@ To enable bulk importing on your HAPI server, make sure to set the `HAPI_FHIR_BU

`go-hapingest` can be configured using environment variables. Below is a table of configurable environment variables:

| Environment Variable | Description | Default Value |
| --------------------------- | ------------------------------------------------------------------------------------ | ----------------------------- |
| `DATA_DIR` | Directory for storing FHIR data files | `./fhir-data` |
| `URL_BASE` | Base URL for the application | `http://host.docker.internal` |
| `FHIR_SERVER_URL` | URL for the FHIR server | `http://127.0.0.1:8080/fhir` |
| `PORT` | Port on which the fileserver runs | `8001` |
| `BLOCKING_PING_FHIR_SERVER` | Blocks the main thread until the FHIR server responds with an ok code on /fhir/$meta | `true` |
| Environment Variable | Description | Default Value |
| --------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------- |
| `DATA_DIR` | Directory for storing FHIR data files | `./fhir-data` |
| `URL_BASE` | Base URL for the application | `http://host.docker.internal` |
| `FHIR_SERVER_URL` | URL for the FHIR server | `http://host.docker.internal:8080/fhir` |
| `PORT` | Port on which the fileserver runs | `8001` |
| `BLOCKING_PING_FHIR_SERVER` | Blocks the main thread until the FHIR server responds with an ok code on /fhir/$meta | `true` |
| `SLEEP_WHEN_DONE` | Sleeps infinitly when done | `true` |
11 changes: 9 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Config struct {
FHIRServerURL string
Port string
PingServer bool
SleepWhenDone bool
}

const (
Expand All @@ -21,6 +22,7 @@ const (
defaultFHIRServerURL = "http://host.docker.internal:8080/fhir"
defaultPort = "8001"
defaultPingServer = true
defaultSleepWhenDone = true
)

var (
Expand All @@ -36,6 +38,7 @@ func GetInstance() *Config {
FHIRServerURL: getEnv("FHIR_SERVER_URL", defaultFHIRServerURL),
Port: getEnv("PORT", defaultPort),
PingServer: getEnvBool("BLOCKING_PING_FHIR_SERVER", defaultPingServer),
SleepWhenDone: getEnvBool("SLEEP_WHEN_DONE", defaultSleepWhenDone),
}
})
return instance
Expand All @@ -57,9 +60,13 @@ func getEnvBool(key string, fallback bool) bool {

func (c *Config) String() string {
pingServerStr := "true"
sleepWhenDoneStr := "true"
if !c.PingServer {
pingServerStr = "false"
}
return fmt.Sprintf("Config:\n\tDataDir: %s\n\tURLBase: %s\n\tFHIRServerURL: %s\n\tPort: %s\n\tBlockingPingFhirServer: %s\n\n",
c.DataDir, c.URLBase, c.FHIRServerURL, c.Port, pingServerStr)
if !c.SleepWhenDone {
sleepWhenDoneStr = "false"
}
return fmt.Sprintf("Config:\n\tDataDir: %s\n\tURLBase: %s\n\tFHIRServerURL: %s\n\tPort: %s\n\tBlockingPingFhirServer: %s\n\tSleepWhenDone: %s\n\n",
c.DataDir, c.URLBase, c.FHIRServerURL, c.Port, pingServerStr, sleepWhenDoneStr)
}
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,13 @@ func main() {
}
time.Sleep(1 * time.Second)
}
if cfg.SleepWhenDone {
sleepInfinityly()
}
}

func sleepInfinityly() {
for {
time.Sleep(100000 * time.Hour)
}
}

0 comments on commit d77a153

Please sign in to comment.