Skip to content

Commit

Permalink
Merge branch 'master' into rewrite-e2e-test-route-with-scripte-luacoe…
Browse files Browse the repository at this point in the history
…-test-with-ginkgo
  • Loading branch information
Jaycean committed Mar 12, 2021
2 parents 0a710f8 + afa05e7 commit 6d54f94
Show file tree
Hide file tree
Showing 22 changed files with 417 additions and 827 deletions.
2 changes: 2 additions & 0 deletions api/conf/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ conf:
logs/access.log # supports relative path, absolute path, standard output
# such as: logs/access.log, /tmp/logs/access.log, /dev/stdout, /dev/stderr
# log example: 2020-12-09T16:38:09.039+0800 INFO filter/logging.go:46 /apisix/admin/routes/r1 {"status": 401, "host": "127.0.0.1:9000", "query": "asdfsafd=adf&a=a", "requestId": "3d50ecb8-758c-46d1-af5b-cd9d1c820156", "latency": 0, "remoteIP": "127.0.0.1", "method": "PUT", "errs": []}
max_cpu: 0 # supports tweaking with the number of OS threads are going to be used for parallelism. Default value: 0 [will use max number of available cpu cores considering hyperthreading (if any)]. If the value is negative, is will not touch the existing parallelism profile.

authentication:
secret:
secret # secret for jwt token generation.
Expand Down
26 changes: 22 additions & 4 deletions api/internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"log"
"os"
"path/filepath"
"runtime"

"github.com/tidwall/gjson"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -96,6 +97,7 @@ type Conf struct {
Listen Listen
Log Log
AllowList []string `yaml:"allow_list"`
MaxCpu int `yaml:"max_cpu"`
}

type User struct {
Expand Down Expand Up @@ -139,14 +141,14 @@ func setConf() {
if configurationContent, err := ioutil.ReadFile(filePath); err != nil {
panic(fmt.Sprintf("fail to read configuration: %s", filePath))
} else {
//configuration := gjson.ParseBytes(configurationContent)
// configuration := gjson.ParseBytes(configurationContent)
config := Config{}
err := yaml.Unmarshal(configurationContent, &config)
if err != nil {
log.Printf("conf: %s, error: %v", configurationContent, err)
}

//listen
// listen
if config.Conf.Listen.Port != 0 {
ServerPort = config.Conf.Listen.Port
}
Expand All @@ -160,7 +162,7 @@ func setConf() {
initEtcdConfig(config.Conf.Etcd)
}

//error log
// error log
if config.Conf.Log.ErrorLog.Level != "" {
ErrorLogLevel = config.Conf.Log.ErrorLog.Level
}
Expand All @@ -187,7 +189,10 @@ func setConf() {

AllowList = config.Conf.AllowList

//auth
// set degree of parallelism
initParallelism(config.Conf.MaxCpu)

// auth
initAuthentication(config.Authentication)

initPlugins(config.Plugins)
Expand Down Expand Up @@ -249,3 +254,16 @@ func initEtcdConfig(conf Etcd) {
Prefix: prefix,
}
}

// initialize parallelism settings
func initParallelism(choiceCores int) {
if choiceCores < 1 {
return
}
maxSupportedCores := runtime.NumCPU()

if choiceCores > maxSupportedCores {
choiceCores = maxSupportedCores
}
runtime.GOMAXPROCS(choiceCores)
}
142 changes: 0 additions & 142 deletions api/internal/core/entity/query.go

This file was deleted.

137 changes: 0 additions & 137 deletions api/internal/core/store/query.go

This file was deleted.

Loading

0 comments on commit 6d54f94

Please sign in to comment.