mirror of
https://github.com/elyby/chrly.git
synced 2025-01-03 18:51:49 +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
|
## [Unreleased] - xxxx-xx-xx
|
||||||
### Added
|
### Added
|
||||||
- 403 Forbidden errors from the Mojang's API are now logged
|
- 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
|
## [4.2.3] - 2019-10-03
|
||||||
### Changed
|
### Changed
|
||||||
|
11
README.md
11
README.md
@ -57,11 +57,12 @@ docker-compose up -d app
|
|||||||
|
|
||||||
**Variables to adjust:**
|
**Variables to adjust:**
|
||||||
|
|
||||||
| ENV | Description | Example |
|
| ENV | Description | Example |
|
||||||
|--------------------|------------------------------------------------------------------------------------|-------------------------------------------|
|
|--------------------|-------------------------------------------------------------------------------------------------|-------------------------------------------|
|
||||||
| STORAGE_REDIS_POOL | By default, Chrly creates pool with 10 connection, but you may want to increase it | `20` |
|
| 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` |
|
| 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` |
|
| 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`.
|
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"
|
"github.com/elyby/chrly/api/mojang"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var UuidsQueueIterationDelay = 2*time.Second + 500*time.Millisecond
|
||||||
|
|
||||||
var usernamesToUuids = mojang.UsernamesToUuids
|
var usernamesToUuids = mojang.UsernamesToUuids
|
||||||
var uuidToTextures = mojang.UuidToTextures
|
var uuidToTextures = mojang.UuidToTextures
|
||||||
var uuidsQueueIterationDelay = time.Second
|
|
||||||
var forever = func() bool {
|
var forever = func() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -97,13 +98,13 @@ func (ctx *JobsQueue) GetTexturesForUsername(username string) chan *mojang.Signe
|
|||||||
|
|
||||||
func (ctx *JobsQueue) startQueue() {
|
func (ctx *JobsQueue) startQueue() {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(uuidsQueueIterationDelay)
|
time.Sleep(UuidsQueueIterationDelay)
|
||||||
for forever() {
|
for forever() {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
ctx.queueRound()
|
ctx.queueRound()
|
||||||
elapsed := time.Since(start)
|
elapsed := time.Since(start)
|
||||||
ctx.Logger.RecordTimer("mojang_textures.usernames.round_time", elapsed)
|
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() {
|
func (suite *queueTestSuite) SetupSuite() {
|
||||||
uuidsQueueIterationDelay = 0
|
UuidsQueueIterationDelay = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *queueTestSuite) SetupTest() {
|
func (suite *queueTestSuite) SetupTest() {
|
||||||
|
@ -3,6 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@ -51,6 +52,7 @@ var serveCmd = &cobra.Command{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queue.UuidsQueueIterationDelay = time.Duration(viper.GetInt("queue.loop_delay")) * time.Millisecond
|
||||||
texturesStorage := queue.CreateInMemoryTexturesStorage()
|
texturesStorage := queue.CreateInMemoryTexturesStorage()
|
||||||
texturesStorage.Start()
|
texturesStorage.Start()
|
||||||
mojangTexturesQueue := &queue.JobsQueue{
|
mojangTexturesQueue := &queue.JobsQueue{
|
||||||
@ -86,4 +88,5 @@ func init() {
|
|||||||
viper.SetDefault("storage.redis.poll", 10)
|
viper.SetDefault("storage.redis.poll", 10)
|
||||||
viper.SetDefault("storage.filesystem.basePath", "data")
|
viper.SetDefault("storage.filesystem.basePath", "data")
|
||||||
viper.SetDefault("storage.filesystem.capesDirName", "capes")
|
viper.SetDefault("storage.filesystem.capesDirName", "capes")
|
||||||
|
viper.SetDefault("queue.loop_delay", 2_500)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user