AlexStocks commented on code in PR #496:
URL: https://github.com/apache/dubbo-go-pixiu/pull/496#discussion_r972530340
##########
pixiu/pkg/filter/traffic/models.go:
##########
@@ -18,61 +18,13 @@
package traffic
import (
- "math/rand"
"net/http"
- "strconv"
- "time"
)
-type splitAction func(header string, expectedValue string, r *http.Request)
bool
-
-type ActionWrapper struct {
- name CanaryHeaders
- action splitAction
-}
-
-type Actions struct {
- wrappers []*ActionWrapper
-}
-
-var actions Actions
-
-func initActions() {
- // canaryByHeader
- headerAction := &ActionWrapper{
- name: canaryByHeader,
- action: func(header string, value string, r *http.Request) bool
{
- if v := r.Header.Get(header); v != "" {
- return v == value
- }
- return false
- },
- }
-
- // canaryWeight
- weightAction := &ActionWrapper{
- name: canaryWeight,
- action: func(header string, value string, r *http.Request) bool
{
- rand.Seed(time.Now().UnixNano())
- num := rand.Intn(100) + 1
- intValue, _ := strconv.Atoi(value)
- return num <= intValue
- },
- }
-
- actions.wrappers = append(actions.wrappers, headerAction)
- actions.wrappers = append(actions.wrappers, weightAction)
+func headerSpilt(req *http.Request, value string) bool {
Review Comment:
改成 spitHeader
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]