some useful improvements for debugging
This commit is contained in:
parent
b93c2d4874
commit
21c72b43b0
@ -68,6 +68,7 @@ func main() {
|
||||
na,
|
||||
rate.Every(time.Duration(float64(time.Second)*cfg.TaskRateLimitEvery)),
|
||||
cfg.TaskRateLimitBurst,
|
||||
cfg.Debug,
|
||||
)
|
||||
apiHandler.SetupRoutes(e.Group("/api/v1"))
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ async function generate() {
|
||||
try {
|
||||
resultLink.value = await encodeUrl(store.specs);
|
||||
resultPreset.value = await encodePreset(store.specs);
|
||||
console.debug(JSON.stringify(store.specs));
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
alert(`Encoding error: ${e}`);
|
||||
|
||||
@ -41,9 +41,10 @@ type Handler struct {
|
||||
rateLimitBurst int
|
||||
limits map[string]*rate.Limiter
|
||||
limitsMu sync.RWMutex
|
||||
debug bool
|
||||
}
|
||||
|
||||
func New(wq adapters.WorkQueue, cache adapters.Cache, rateLimit rate.Limit, rateLimitBurst int) *Handler {
|
||||
func New(wq adapters.WorkQueue, cache adapters.Cache, rateLimit rate.Limit, rateLimitBurst int, debug bool) *Handler {
|
||||
if wq == nil || cache == nil {
|
||||
panic("you fckd up with di again")
|
||||
}
|
||||
@ -53,6 +54,7 @@ func New(wq adapters.WorkQueue, cache adapters.Cache, rateLimit rate.Limit, rate
|
||||
rateLimit: rateLimit,
|
||||
rateLimitBurst: rateLimitBurst,
|
||||
limits: make(map[string]*rate.Limiter),
|
||||
debug: debug,
|
||||
}
|
||||
h.validate = validator.New(validator.WithRequiredStructEnabled())
|
||||
if err := h.validate.RegisterValidation("selector", validators.ValidateSelector); err != nil {
|
||||
@ -97,6 +99,9 @@ func (h *Handler) handleRender(c echo.Context) error {
|
||||
if cacheLifetime > maxLifetime {
|
||||
cacheLifetime = maxLifetime
|
||||
}
|
||||
if h.debug {
|
||||
cacheLifetime = 0
|
||||
}
|
||||
|
||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), taskTimeout)
|
||||
defer cancel()
|
||||
@ -105,6 +110,7 @@ func (h *Handler) handleRender(c echo.Context) error {
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(500, fmt.Errorf("task marshal error: %v", err))
|
||||
}
|
||||
log.Debugf("Encoded task: %s", encodedTask)
|
||||
|
||||
taskResultBytes, cachedTS, err := h.cache.Get(task.CacheKey())
|
||||
if err != nil && !errors.Is(err, adapters.ErrKeyNotFound) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user