Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
"time"
)

var reverse bool

const MultiBundleFileBundleDelimiter = byte('\n')

func NewFileChunkReader(file *os.File, offsetBytes int64, limitBytes int64) (*io.LimitedReader, error) {
Expand Down Expand Up @@ -417,7 +419,14 @@ func newUploadBundleConsumer(client *fhir.Client, uploadResults chan<- bundleUpl
func (consumer *uploadBundleConsumer) uploadBundles(uploadBundles []bundle, concurrency int, wg *sync.WaitGroup) {
limiter := make(chan bool, concurrency)

for _, queueItem := range uploadBundles {
for i := 0; i < len(uploadBundles); i++ {
var queueItem bundle
if reverse {
queueItem = uploadBundles[len(uploadBundles)-(i+1)]
} else {
queueItem = uploadBundles[i]
}

limiter <- true
wg.Add(1)
go func(b bundle, limiter <-chan bool, wg *sync.WaitGroup) {
Expand Down Expand Up @@ -629,6 +638,7 @@ func init() {

uploadCmd.Flags().StringVar(&server, "server", "", "the base URL of the server to use")
uploadCmd.Flags().IntVarP(&concurrency, "concurrency", "c", 2, "number of parallel uploads")
uploadCmd.Flags().BoolVarP(&reverse, "reverse", "r", false, "upload data in reverse order")

_ = uploadCmd.MarkFlagRequired("server")
}