fix: regist endpoints outside of goroutine
This commit is contained in:
parent
96368b78f6
commit
2118e0fb86
18
main.go
18
main.go
@ -103,7 +103,6 @@ func main() {
|
||||
DisableStartupMessage: true,
|
||||
})
|
||||
|
||||
go func() {
|
||||
app.Post("/api/streams/persist", func(c *fiber.Ctx) error {
|
||||
data := struct {
|
||||
GeneratedUserId string `json:"generated_user_id"`
|
||||
@ -133,6 +132,7 @@ func main() {
|
||||
return c.JSON(data)
|
||||
})
|
||||
|
||||
go func() {
|
||||
for {
|
||||
preferred_categories, _ := weightedrand.NewChooser(
|
||||
weightedrand.Choice{Item: "Development", Weight: gofakeit.UintN(10) + 1},
|
||||
@ -173,7 +173,7 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
func() {
|
||||
KAFKA_BROKERS, ok := os.LookupEnv("KAFKA_BROKERS")
|
||||
if !ok {
|
||||
return
|
||||
@ -265,6 +265,7 @@ func main() {
|
||||
return c.JSON(data)
|
||||
})
|
||||
|
||||
go func() {
|
||||
for {
|
||||
is_anon := gofakeit.IntN(10) > 3
|
||||
preferred_categories, _ := weightedrand.NewChooser(
|
||||
@ -337,8 +338,8 @@ func main() {
|
||||
}
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
app.Post("/api/streams/log", func(c *fiber.Ctx) error {
|
||||
data := struct {
|
||||
GeneratedReferrer string `json:"generated_referrer"`
|
||||
@ -358,7 +359,7 @@ func main() {
|
||||
gofakeit.IPv4Address(),
|
||||
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
||||
method,
|
||||
"/api/qry/"+gofakeit.Noun()+"?_qtt="+gofakeit.UUID()+"&_st="+url.QueryEscape(gofakeit.StreetName()),
|
||||
"/api/qry/"+url.PathEscape(gofakeit.Noun())+"?_qtt="+gofakeit.UUID()+"&_st="+url.QueryEscape(gofakeit.StreetName()),
|
||||
gofakeit.HTTPStatusCode(),
|
||||
"100MB",
|
||||
"100s",
|
||||
@ -379,7 +380,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
data.SampledLog = fmt.Sprintf("%s - [%s] %s %s %d %s %s %s %s \"%s\"\n",
|
||||
data.SampledLog = fmt.Sprintf("%s - [%s] %s %s %d %s %s %s %s \"%s\"",
|
||||
gofakeit.IPv4Address(),
|
||||
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
||||
"POST",
|
||||
@ -388,13 +389,14 @@ func main() {
|
||||
"1MB",
|
||||
"1B",
|
||||
"1s",
|
||||
"referrer",
|
||||
"http://referrer",
|
||||
"test/"+gofakeit.UUID())
|
||||
|
||||
fmt.Print(data.SampledLog)
|
||||
fmt.Println(data.SampledLog)
|
||||
return c.JSON(data)
|
||||
})
|
||||
|
||||
go func() {
|
||||
for {
|
||||
rxSeed := gofakeit.IntN(50) + 1
|
||||
txSeed := gofakeit.IntN(100) + 1
|
||||
@ -417,7 +419,7 @@ func main() {
|
||||
gofakeit.IPv4Address(),
|
||||
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
||||
method,
|
||||
"/api/qry/"+gofakeit.Noun()+"?_qtt="+gofakeit.UUID()+"&_st="+url.QueryEscape(gofakeit.StreetName()),
|
||||
"/api/qry/"+url.PathEscape(gofakeit.Noun())+"?_qtt="+gofakeit.UUID()+"&_st="+url.QueryEscape(gofakeit.StreetName()),
|
||||
gofakeit.HTTPStatusCode(),
|
||||
ByteCountSI(gofakeit.IntN(1000*10*txSeed)),
|
||||
duration,
|
||||
|
Loading…
Reference in New Issue
Block a user