mirror of
https://github.com/elyby/chrly.git
synced 2024-12-23 13:40:11 +05:30
Increase queue loop delay from 1 to 2.5 seconds. Add configuration param to adjust its value
This commit is contained in:
parent
b2a1fd450b
commit
7353047467
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
## [Unreleased] - xxxx-xx-xx
|
||||
### Added
|
||||
- 403 Forbidden errors from the Mojang's API are now logged
|
||||
- `QUEUE_LOOP_DELAY` configuration param to adjust Mojang's textures queue performance
|
||||
|
||||
### Changed
|
||||
- Mojang's textures queue loop is now has an iteration delay of 2.5 seconds (was 1)
|
||||
|
||||
## [4.2.3] - 2019-10-03
|
||||
### Changed
|
||||
|
11
README.md
11
README.md
@ -57,11 +57,12 @@ docker-compose up -d app
|
||||
|
||||
**Variables to adjust:**
|
||||
|
||||
| ENV | Description | Example |
|
||||
|--------------------|------------------------------------------------------------------------------------|-------------------------------------------|
|
||||
| STORAGE_REDIS_POOL | By default, Chrly creates pool with 10 connection, but you may want to increase it | `20` |
|
||||
| STATSD_ADDR | StatsD can be used to collect metrics | `localhost:8125` |
|
||||
| SENTRY_DSN | Sentry can be used to collect app errors | `https://public:private@your.sentry.io/1` |
|
||||
| ENV | Description | Example |
|
||||
|--------------------|-------------------------------------------------------------------------------------------------|-------------------------------------------|
|
||||
| STORAGE_REDIS_POOL | By default, Chrly creates pool with 10 connection, but you may want to increase it | `20` |
|
||||
| STATSD_ADDR | StatsD can be used to collect metrics | `localhost:8125` |
|
||||
| SENTRY_DSN | Sentry can be used to collect app errors | `https://public:private@your.sentry.io/1` |
|
||||
| QUEUE_LOOP_DELAY | Parameter is sets the delay before each iteration of the Mojang's textures queue (milliseconds) | `3200` |
|
||||
|
||||
If something goes wrong, you can always access logs by executing `docker-compose logs -f app`.
|
||||
|
||||
|
@ -14,9 +14,10 @@ import (
|
||||
"github.com/elyby/chrly/api/mojang"
|
||||
)
|
||||
|
||||
var UuidsQueueIterationDelay = 2*time.Second + 500*time.Millisecond
|
||||
|
||||
var usernamesToUuids = mojang.UsernamesToUuids
|
||||
var uuidToTextures = mojang.UuidToTextures
|
||||
var uuidsQueueIterationDelay = time.Second
|
||||
var forever = func() bool {
|
||||
return true
|
||||
}
|
||||
@ -97,13 +98,13 @@ func (ctx *JobsQueue) GetTexturesForUsername(username string) chan *mojang.Signe
|
||||
|
||||
func (ctx *JobsQueue) startQueue() {
|
||||
go func() {
|
||||
time.Sleep(uuidsQueueIterationDelay)
|
||||
time.Sleep(UuidsQueueIterationDelay)
|
||||
for forever() {
|
||||
start := time.Now()
|
||||
ctx.queueRound()
|
||||
elapsed := time.Since(start)
|
||||
ctx.Logger.RecordTimer("mojang_textures.usernames.round_time", elapsed)
|
||||
time.Sleep(uuidsQueueIterationDelay)
|
||||
time.Sleep(UuidsQueueIterationDelay)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ type queueTestSuite struct {
|
||||
}
|
||||
|
||||
func (suite *queueTestSuite) SetupSuite() {
|
||||
uuidsQueueIterationDelay = 0
|
||||
UuidsQueueIterationDelay = 0
|
||||
}
|
||||
|
||||
func (suite *queueTestSuite) SetupTest() {
|
||||
|
@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@ -51,6 +52,7 @@ var serveCmd = &cobra.Command{
|
||||
return
|
||||
}
|
||||
|
||||
queue.UuidsQueueIterationDelay = time.Duration(viper.GetInt("queue.loop_delay")) * time.Millisecond
|
||||
texturesStorage := queue.CreateInMemoryTexturesStorage()
|
||||
texturesStorage.Start()
|
||||
mojangTexturesQueue := &queue.JobsQueue{
|
||||
@ -86,4 +88,5 @@ func init() {
|
||||
viper.SetDefault("storage.redis.poll", 10)
|
||||
viper.SetDefault("storage.filesystem.basePath", "data")
|
||||
viper.SetDefault("storage.filesystem.capesDirName", "capes")
|
||||
viper.SetDefault("queue.loop_delay", 2_500)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user