Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
package remotefileupload
import (
"math/rand"
"strconv"
"testing"
"time"
)
// without the goroutine, only sends 11
func BenchmarkAzureUpload(b *testing.B) {
azureAccount = "fiskerclouddev"
azureAccountKey = "REPLACE_ME"
uploader, err := NewAzureUploader("trex-logs", ".txt")
if err != nil {
b.Error(err)
}
benchmarkUploadTime(uploader, b)
}
func BenchmarkAzureBatchUpload(b *testing.B) {
azureAccount = "fiskerclouddev"
azureAccountKey = "REPLACE_ME"
uploader, err := NewAzureBatchUploader("trex-logs", ".txt", 1, "\n")
if err != nil {
b.Error(err)
}
benchmarkUploadTime(uploader, b)
}
// 1762456 messages,
func benchmarkUploadTime(uploader Uploader, b *testing.B) {
endTimer := time.NewTimer(time.Second * 5)
messagesSent := 0
Loop:
for {
select {
case <-endTimer.C:
break Loop
default:
SendMessage(time.Now(), uploader, b)
messagesSent++
}
}
time.Sleep(5 * time.Second)
b.Logf("Benchmark %s 'sent' %d messages\n", b.Name(), messagesSent)
}
func SendMessage(t time.Time, uploader Uploader, b *testing.B) {
thread := rand.Intn(10)
_, err := uploader.Upload([]byte(t.Format(time.RubyDate)), LogPayload{
Title: "This",
Value: "Some",
}, "/benchmark", strconv.Itoa(thread))
if err != nil {
b.Error(b)
}
}