Skip to content

Commit

Permalink
Add a new configuration download_buf_pool_size
Browse files Browse the repository at this point in the history
  • Loading branch information
fireworkmarks authored and thesues committed Jul 23, 2019
1 parent df7c18a commit 6296f6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions helper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

const (
YIG_CONF_PATH = "/etc/yig/yig.toml"
MIN_DOWNLOAD_BUFPOOL_SIZE = 512 << 10 // 512k
MAX_DOWNLOAD_BUFPOOL_SIZE = 8 << 20 // 8M
)

type Config struct {
Expand Down Expand Up @@ -65,6 +67,8 @@ type Config struct {
// This property sets the minimum number of requests in a rolling window that will trip the circuit.
CacheCircuitOpenThreshold int `toml:"cache_circuit_open_threshold"`

DownLoadBufPoolSize int `toml:"download_buf_pool_size"`

KMS KMSConfig `toml:"kms"`

// Message Bus
Expand Down Expand Up @@ -177,6 +181,8 @@ func MarshalTOMLConfig() error {
CONFIG.CacheCircuitCloseRequiredCount = Ternary(c.CacheCircuitCloseRequiredCount < 0, 0, c.CacheCircuitCloseRequiredCount).(int)
CONFIG.CacheCircuitOpenThreshold = Ternary(c.CacheCircuitOpenThreshold < 0, 0, c.CacheCircuitOpenThreshold).(int)

CONFIG.DownLoadBufPoolSize = Ternary(c.DownLoadBufPoolSize < MIN_DOWNLOAD_BUFPOOL_SIZE || c.DownLoadBufPoolSize > MAX_DOWNLOAD_BUFPOOL_SIZE, MIN_DOWNLOAD_BUFPOOL_SIZE, c.DownLoadBufPoolSize).(int)

CONFIG.KMS = c.KMS

CONFIG.MsgBus = c.MsgBus
Expand Down
1 change: 1 addition & 0 deletions integrate/yigconf/yig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cache_circuit_open_threshold = 1

# Ceph Config
ceph_config_pattern = "/etc/ceph/*.conf"
download_buf_pool_size = 524288

[kms]
type = "vault"
Expand Down
2 changes: 1 addition & 1 deletion storage/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var (

func init() {
downloadBufPool.New = func() interface{} {
return make([]byte, MIN_CHUNK_SIZE)
return make([]byte, helper.CONFIG.DownLoadBufPoolSize)
}
}

Expand Down

0 comments on commit 6296f6d

Please sign in to comment.