Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Pixiu com files in /cmd/pixiu to pkg/cmd #594

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
# Release Notes

---
## 1.0.0

### New Features
- [fail inject](https://github.com/apache/dubbo-go-pixiu/pull/571)
- [add support for header based route](https://github.com/apache/dubbo-go-pixiu/pull/565)
- [Add Maglev hashing LB algorithm](https://github.com/apache/dubbo-go-pixiu/pull/554)
- [triple proxy support import protosets](https://github.com/apache/dubbo-go-pixiu/pull/548)
- [Add GracefulShutdown Signal For Windows ](https://github.com/apache/dubbo-go-pixiu/pull/522)
- [Tracing support dubbo invoke](https://github.com/apache/dubbo-go-pixiu/pull/559)

### Enhancement
- [refactor prometheus metric](https://github.com/apache/dubbo-go-pixiu/pull/573)
- [remove unused pkg imports](https://github.com/apache/dubbo-go-pixiu/pull/574)
- [chore: unnecessary use of fmt.Sprintf](https://github.com/apache/dubbo-go-pixiu/pull/575)
- [chore:use wasm filter build tags add wasm](https://github.com/apache/dubbo-go-pixiu/pull/567)
- [docs:format and change samples link](https://github.com/apache/dubbo-go-pixiu/pull/556)
- [revert gatewayCmd to Run dubbo go pixiu](https://github.com/apache/dubbo-go-pixiu/pull/557)
- [full import format](https://github.com/apache/dubbo-go-pixiu/pull/527)
- [upgrade hessian2 to v1.11.3](https://github.com/apache/dubbo-go-pixiu/pull/516)

### Bugfixes
- [register hashing and array out of bounds and init hashing](https://github.com/apache/dubbo-go-pixiu/pull/530)
- [optimize timeout statusCode](https://github.com/apache/dubbo-go-pixiu/pull/521)
- [optimizing Metric Implementation](https://github.com/apache/dubbo-go-pixiu/pull/528)
- [add and modify nacos config arguments](https://github.com/apache/dubbo-go-pixiu/pull/524)
- [fix NPE when filter config is nil](https://github.com/apache/dubbo-go-pixiu/pull/517)
- [use wasmer-go v1.0.4 which is compatible with mac arm](https://github.com/apache/dubbo-go-pixiu/pull/515)
- [fix sample url using github.com/apache/dubbo-go-pixiu-samples](https://github.com/apache/dubbo-go-pixiu/pull/506)
- [traffic filter fix weight strategy and error handle within Apply method](https://github.com/apache/dubbo-go-pixiu/pull/507)
- [httpfilter loadbalancer does not work when it has spaces between multiple urls](https://github.com/apache/dubbo-go-pixiu/pull/513)

Milestone: [https://github.com/apache/dubbo-go-pixiu/milestone/8](https://github.com/apache/dubbo-go-pixiu/milestone/8)

## 0.6.0

### New Features
Expand All @@ -17,7 +50,7 @@
### Enhancement
- [Remove "Types" on Http to dubbo proxy](https://github.com/apache/dubbo-go-pixiu/pull/456)
- [ASoC 2002: Optimization of Pixiu timeout feature ](https://github.com/apache/dubbo-go-pixiu/pull/475)
-
-

### Bugfixes

Expand Down Expand Up @@ -110,7 +143,7 @@ Milestone: [https://github.com/apache/dubbo-go-pixiu/milestone/6](https://github
- [Fix filterManager get filters with random order](https://github.com/apache/dubbo-go-pixiu/pull/264)
- [Fix nil issue for timeout filter](https://github.com/apache/dubbo-go-pixiu/pull/278)

Milestone: [https://github.com/apache/dubbo-go-pixiu/milestone/5](https://github.com/apache/dubbo-go-pixiu/milestone/5)
Milestone: [https://github.com/apache/dubbo-go-pixiu/milestone/5](https://github.com/apache/dubbo-go-pixiu/milestone/5)


## 0.3.0
Expand All @@ -120,25 +153,25 @@ Milestone: [https://github.com/apache/dubbo-go-pixiu/milestone/5](https://github
- [add integrate test](https://github.com/apache/dubbo-go-pixiu/pull/183)
- [handle rate limit config update event](https://github.com/apache/dubbo-go-pixiu/pull/196)
- [add otel metric export to prometheus in pixiu](https://github.com/apache/dubbo-go-pixiu/pull/204)
- [make Pixiu Admin config management finer-grained](https://github.com/apache/dubbo-go-pixiu/pull/171)
- [make Pixiu Admin config management finer-grained](https://github.com/apache/dubbo-go-pixiu/pull/171)

### Enhancement
- [update samples/admin](https://github.com/apache/dubbo-go-pixiu/pull/208)
- [update ratelimit samples](https://github.com/apache/dubbo-go-pixiu/pull/206)
- [make router case sensitive](https://github.com/apache/dubbo-go-pixiu/pull/209)
- [add more test case](https://github.com/apache/dubbo-go-pixiu/pull/203)
- [Enrich filter test case](https://github.com/apache/dubbo-go-pixiu/pull/202)
- [Enrich response.go's test case](https://github.com/apache/dubbo-go-pixiu/pull/197)
- [Enrich response.go's test case](https://github.com/apache/dubbo-go-pixiu/pull/197)

### Bugfixes
- [Fix CI check status not match required](https://github.com/apache/dubbo-go-pixiu/pull/199)
- [Fix timeout config overridden](https://github.com/apache/dubbo-go-pixiu/pull/190)
- [Fix/quickstart](https://github.com/apache/dubbo-go-pixiu/pull/191)
- [FixBug: can't delete node by path](https://github.com/apache/dubbo-go-pixiu/pull/201)
- [Fix flow chart](https://github.com/apache/dubbo-go-pixiu/pull/205)
- [Fix reviewdog](https://github.com/apache/dubbo-go-pixiu/pull/195)
Milestone: [https://github.com/apache/dubbo-go-pixiu/milestone/4](https://github.com/apache/dubbo-go-pixiu/milestone/4)
- [Fix reviewdog](https://github.com/apache/dubbo-go-pixiu/pull/195)

Milestone: [https://github.com/apache/dubbo-go-pixiu/milestone/4](https://github.com/apache/dubbo-go-pixiu/milestone/4)


## 0.2.1
Expand Down
70 changes: 0 additions & 70 deletions cmd/pixiu/gateway.go

This file was deleted.

146 changes: 5 additions & 141 deletions cmd/pixiu/pixiu.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
package main

import (
"fmt"
_ "net/http/pprof"
"runtime"
"strconv"
"time"
)
Expand All @@ -30,45 +28,15 @@ import (
)

import (
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/common/constant"
pxruntime "github.com/apache/dubbo-go-pixiu/pixiu/pkg/common/runtime"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/config"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/cmd"
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/pluginregistry"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/server"
)

var (
const (
// Version pixiu version
Version = "0.6.0"

flagToLogLevel = map[string]string{
"trace": "TRACE",
"debug": "DEBUG",
"info": "INFO",
"warning": "WARN",
"error": "ERROR",
"critical": "FATAL",
}

configPath string
apiConfigPath string
logConfigPath string
logLevel string

// CURRENTLY USELESS
logFormat string

limitCpus string

// Currently default set to false, wait for up coming support
initFromRemote = false
Version = "1.0.0"
)

// deploy server deployment
var deploy = &DefaultDeployer{}

// main pixiu run method
func main() {
app := getRootCmd()
Expand All @@ -88,112 +56,8 @@ func getRootCmd() *cobra.Command {
Version: Version,
}

rootCmd.AddCommand(gatewayCmd)
rootCmd.AddCommand(sideCarCmd)
rootCmd.AddCommand(cmd.GatewayCmd)
rootCmd.AddCommand(cmd.SideCarCmd)

return rootCmd
}

type DefaultDeployer struct {
bootstrap *model.Bootstrap
configManger *config.ConfigManager
}

func (d *DefaultDeployer) initialize() error {

err := initLog()
if err != nil {
logger.Warnf("[startGatewayCmd] failed to init logger, %s", err.Error())
}

// load Bootstrap config
d.bootstrap = d.configManger.LoadBootConfig(configPath)
if err != nil {
panic(fmt.Errorf("[startGatewayCmd] failed to get api meta config, %s", err.Error()))
}

err = initLimitCpus()
if err != nil {
logger.Errorf("[startCmd] failed to get limit cpu number, %s", err.Error())
}

return err
}

func (d *DefaultDeployer) start() error {
server.Start(d.bootstrap)
return nil
}

func (d *DefaultDeployer) stop() error {
//TODO implement me
panic("implement me")
}

// initDefaultValue If not set both in args and env, set default values
func initDefaultValue() {
if configPath == "" {
configPath = constant.DefaultConfigPath
}

if apiConfigPath == "" {
apiConfigPath = constant.DefaultApiConfigPath
}

if logConfigPath == "" {
logConfigPath = constant.DefaultLogConfigPath
}

if logLevel == "" {
logLevel = constant.DefaultLogLevel
}

if limitCpus == "" {
limitCpus = constant.DefaultLimitCpus
}

if logFormat == "" {
logFormat = constant.DefaultLogFormat
}
}

// initLog
func initLog() error {
err := logger.InitLog(logConfigPath)
if err != nil {
// cause `logger.InitLog` already handle init failed, so just use logger to log
return err
}

if level, ok := flagToLogLevel[logLevel]; ok {
logger.SetLoggerLevel(level)
} else {
logger.SetLoggerLevel(flagToLogLevel[constant.DefaultLogLevel])
return fmt.Errorf("logLevel is invalid, set log level to default: %s", constant.DefaultLogLevel)
}
return nil
}

// initApiConfig return value of the bool is for the judgment of whether is a api meta data error, a kind of silly (?)
func initApiConfig() (*model.Bootstrap, error) {
bootstrap := config.Load(configPath)
return bootstrap, nil
}

func initLimitCpus() error {
limitCpuNumberFromEnv, err := strconv.ParseInt(limitCpus, 10, 64)
if err != nil {
return err
}
limitCpuNumber := int(limitCpuNumberFromEnv)
if limitCpuNumber <= 0 {
limitCpuNumber = pxruntime.GetCPUNum()
}
runtime.GOMAXPROCS(limitCpuNumber)
logger.Infof("GOMAXPROCS set to %v", limitCpuNumber)
return nil
}

func init() {
deploy.configManger = config.NewConfigManger()
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,4 @@ require (
)

replace google.golang.org/protobuf v1.28.1 => google.golang.org/protobuf v1.28.0

2 changes: 1 addition & 1 deletion cmd/pixiu/deployer.go → pixiu/pkg/cmd/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package main
package cmd

type Deployer interface {
initialize() error
Expand Down
Loading