feat: better random pricision
This commit is contained in:
parent
bd2c08aa53
commit
80ba3890d1
9
main.go
9
main.go
@ -60,6 +60,8 @@ func main() {
|
|||||||
log.Fatalln("DATABASE_SCHEMA_NOT_FOUND")
|
log.Fatalln("DATABASE_SCHEMA_NOT_FOUND")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, DISABLE_LARGE_POOL := os.LookupEnv("DISABLE_LARGE_POOL")
|
||||||
|
|
||||||
cfg := mysql.Config{
|
cfg := mysql.Config{
|
||||||
User: DATABASE_USER,
|
User: DATABASE_USER,
|
||||||
Passwd: DATABASE_PASS,
|
Passwd: DATABASE_PASS,
|
||||||
@ -79,6 +81,7 @@ func main() {
|
|||||||
log.Fatalln("DATABASE_CONNECTION_FAILED")
|
log.Fatalln("DATABASE_CONNECTION_FAILED")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !DISABLE_LARGE_POOL {
|
||||||
stopConn := false
|
stopConn := false
|
||||||
log.Println("Creating large DB connection pool... Please wait...")
|
log.Println("Creating large DB connection pool... Please wait...")
|
||||||
for i := 0; i < 7000; i++ {
|
for i := 0; i < 7000; i++ {
|
||||||
@ -98,6 +101,7 @@ func main() {
|
|||||||
log.Println("Ctrl+C to terminate DB connection pool")
|
log.Println("Ctrl+C to terminate DB connection pool")
|
||||||
<-make(chan int)
|
<-make(chan int)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app := fiber.New(fiber.Config{
|
app := fiber.New(fiber.Config{
|
||||||
DisableStartupMessage: true,
|
DisableStartupMessage: true,
|
||||||
@ -270,7 +274,6 @@ func main() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
is_anon := gofakeit.IntN(10) > 3
|
|
||||||
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},
|
||||||
weightedrand.Choice{Item: "Novel", Weight: gofakeit.UintN(10) + 1},
|
weightedrand.Choice{Item: "Novel", Weight: gofakeit.UintN(10) + 1},
|
||||||
@ -281,9 +284,11 @@ func main() {
|
|||||||
weightedrand.Choice{Item: "Science", Weight: gofakeit.UintN(10) + 1},
|
weightedrand.Choice{Item: "Science", Weight: gofakeit.UintN(10) + 1},
|
||||||
)
|
)
|
||||||
|
|
||||||
for i := 1; i <= 100*60*5; i++ {
|
for i := 1; i <= 10*60*5; i++ {
|
||||||
click_events := []string{}
|
click_events := []string{}
|
||||||
click_event_count := gofakeit.IntRange(1, 5)
|
click_event_count := gofakeit.IntRange(1, 5)
|
||||||
|
is_anon := gofakeit.IntN(10) > 3
|
||||||
|
|
||||||
if is_anon {
|
if is_anon {
|
||||||
for j := 0; j < click_event_count; j++ {
|
for j := 0; j < click_event_count; j++ {
|
||||||
click_events = append(click_events, fmt.Sprintf("{\"type\":\"click\",\"details\":{\"element\":\".%s\",\"content\":{\"item_name\":\"%s\",\"item_category\":\"%s\",\"item_location\":\"%s\"}},\"credentials\":{\"session_id\":null,\"session_issuer\":null,\"sys_trace_id\":\"ubks__mainsvc__vNeptune_1_%s\"},\"event_at\":\"%s\"}",
|
click_events = append(click_events, fmt.Sprintf("{\"type\":\"click\",\"details\":{\"element\":\".%s\",\"content\":{\"item_name\":\"%s\",\"item_category\":\"%s\",\"item_location\":\"%s\"}},\"credentials\":{\"session_id\":null,\"session_issuer\":null,\"sys_trace_id\":\"ubks__mainsvc__vNeptune_1_%s\"},\"event_at\":\"%s\"}",
|
||||||
|
Loading…
Reference in New Issue
Block a user