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