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,
|
DisableStartupMessage: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
go func() {
|
|
||||||
app.Post("/api/streams/persist", func(c *fiber.Ctx) error {
|
app.Post("/api/streams/persist", func(c *fiber.Ctx) error {
|
||||||
data := struct {
|
data := struct {
|
||||||
GeneratedUserId string `json:"generated_user_id"`
|
GeneratedUserId string `json:"generated_user_id"`
|
||||||
@ -133,6 +132,7 @@ func main() {
|
|||||||
return c.JSON(data)
|
return c.JSON(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
go func() {
|
||||||
for {
|
for {
|
||||||
preferred_categories, _ := weightedrand.NewChooser(
|
preferred_categories, _ := weightedrand.NewChooser(
|
||||||
weightedrand.Choice{Item: "Development", Weight: gofakeit.UintN(10) + 1},
|
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")
|
KAFKA_BROKERS, ok := os.LookupEnv("KAFKA_BROKERS")
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@ -265,6 +265,7 @@ func main() {
|
|||||||
return c.JSON(data)
|
return c.JSON(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
go func() {
|
||||||
for {
|
for {
|
||||||
is_anon := gofakeit.IntN(10) > 3
|
is_anon := gofakeit.IntN(10) > 3
|
||||||
preferred_categories, _ := weightedrand.NewChooser(
|
preferred_categories, _ := weightedrand.NewChooser(
|
||||||
@ -337,8 +338,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
}()
|
||||||
|
|
||||||
go func() {
|
|
||||||
app.Post("/api/streams/log", func(c *fiber.Ctx) error {
|
app.Post("/api/streams/log", func(c *fiber.Ctx) error {
|
||||||
data := struct {
|
data := struct {
|
||||||
GeneratedReferrer string `json:"generated_referrer"`
|
GeneratedReferrer string `json:"generated_referrer"`
|
||||||
@ -358,7 +359,7 @@ func main() {
|
|||||||
gofakeit.IPv4Address(),
|
gofakeit.IPv4Address(),
|
||||||
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
||||||
method,
|
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(),
|
gofakeit.HTTPStatusCode(),
|
||||||
"100MB",
|
"100MB",
|
||||||
"100s",
|
"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(),
|
gofakeit.IPv4Address(),
|
||||||
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
||||||
"POST",
|
"POST",
|
||||||
@ -388,13 +389,14 @@ func main() {
|
|||||||
"1MB",
|
"1MB",
|
||||||
"1B",
|
"1B",
|
||||||
"1s",
|
"1s",
|
||||||
"referrer",
|
"http://referrer",
|
||||||
"test/"+gofakeit.UUID())
|
"test/"+gofakeit.UUID())
|
||||||
|
|
||||||
fmt.Print(data.SampledLog)
|
fmt.Println(data.SampledLog)
|
||||||
return c.JSON(data)
|
return c.JSON(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
go func() {
|
||||||
for {
|
for {
|
||||||
rxSeed := gofakeit.IntN(50) + 1
|
rxSeed := gofakeit.IntN(50) + 1
|
||||||
txSeed := gofakeit.IntN(100) + 1
|
txSeed := gofakeit.IntN(100) + 1
|
||||||
@ -417,7 +419,7 @@ func main() {
|
|||||||
gofakeit.IPv4Address(),
|
gofakeit.IPv4Address(),
|
||||||
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
time.Now().Format("2006-01-02T15:04:05.999999 -07:00"),
|
||||||
method,
|
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(),
|
gofakeit.HTTPStatusCode(),
|
||||||
ByteCountSI(gofakeit.IntN(1000*10*txSeed)),
|
ByteCountSI(gofakeit.IntN(1000*10*txSeed)),
|
||||||
duration,
|
duration,
|
||||||
|
Loading…
Reference in New Issue
Block a user