vk-webhook-flooder-mock/main.go

37 lines
834 B
Go
Raw Normal View History

2023-01-13 13:28:05 +03:00
package main
import (
"fmt"
"os"
"time"
"github.com/gin-gonic/gin"
"vk-webhook-flooder-mock/handler"
)
func main() {
if len(os.Args) > 1 && os.Args[1] == "teststore" {
f := newFetcher("token")
go func() {
for i := 0; i < 1000; i++ {
f.Enqueue(int64(i))
time.Sleep(time.Millisecond)
}
}()
fmt.Printf("starting")
for {
fmt.Printf("\033[2K\roffload: %d, output: %d, result: %d", f.offload.Len(), len(f.output), f.result.Len())
time.Sleep(time.Millisecond)
}
}
gin.SetMode(gin.ReleaseMode)
g := gin.New()
g.Use(gin.Recovery())
g.GET("/flood", handler.FloodHandler)
g.GET("/concurrentflood", handler.ConcurrentFloodHandler)
g.POST("/method/users.get", vkRateLimit(), handler.UsersGetHandler)
g.POST("/api/transport/v1/messages", mgRateLimit(), handler.NewMessageHandler)
g.Run(":8090")
}