[GitHub] [apisix-dashboard] membphis commented on a change in pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


membphis commented on a change in pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#discussion_r502209694



##
File path: api/internal/handler/ssl/ssl.go
##
@@ -54,14 +57,16 @@ func (h *Handler) ApplyRoute(r *gin.Engine) {
wrapper.InputType(reflect.TypeOf(ListInput{}
r.POST("/apisix/admin/ssl", wgin.Wraps(h.Create,
wrapper.InputType(reflect.TypeOf(entity.SSL{}
-   r.POST("/apisix/admin/check_ssl_cert", wgin.Wraps(h.Validate,
-   wrapper.InputType(reflect.TypeOf(entity.SSL{}
r.PUT("/apisix/admin/ssl/:id", wgin.Wraps(h.Update,
wrapper.InputType(reflect.TypeOf(UpdateInput{}
r.PATCH("/apisix/admin/ssl/:id", wgin.Wraps(h.Patch,
wrapper.InputType(reflect.TypeOf(UpdateInput{}
-   r.DELETE("/apisix/admin/ssl", wgin.Wraps(h.BatchDelete,
+   r.DELETE("/apisix/admin/ssl/:ids", wgin.Wraps(h.BatchDelete,

Review comment:
   why we use `ids` here? I think it should be `id`, the singular should be 
used here.

##
File path: api/internal/core/entity/query.go
##
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

Review comment:
   ping @nic-chen 

##
File path: api/internal/core/store/query.go
##
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Copyright 2017 The Kubernetes Authors.

Review comment:
   ping @moonming 





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706032151


   > @nic-chen what's the code coverage?
   
   you could see in my repo:
   
https://github.com/nic-chen/incubator-apisix-dashboard/pull/7/checks?check_run_id=1212879646
   
   main code of refactoring:
   coverage: 81.3% of statements
   github.com/apisix/manager-api/internal/core/store
   coverage: 63.3% of statements
   github.com/apisix/manager-api/internal/utils
   
   the handlers using api test, so it couldn't  calculate coverage correctly.
   
   
   
   
   
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706032588


   @membphis  we leave the license issues and fix it later.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[apisix] branch master updated: optimize: use table.isarray to check whether table is an array. (#2365)

2020-10-09 Thread wenming
This is an automated email from the ASF dual-hosted git repository.

wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 87a107f  optimize: use table.isarray to check whether table is an 
array. (#2365)
87a107f is described below

commit 87a107ff4bcfaff97562d27c54e5801a946243e0
Author: Alex Zhang 
AuthorDate: Fri Oct 9 15:58:40 2020 +0800

optimize: use table.isarray to check whether table is an array. (#2365)
---
 apisix/core/config_local.lua | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/apisix/core/config_local.lua b/apisix/core/config_local.lua
index 42e6ae7..aa9252f 100644
--- a/apisix/core/config_local.lua
+++ b/apisix/core/config_local.lua
@@ -17,7 +17,9 @@
 
 local log = require("apisix.core.log")
 local profile = require("apisix.core.profile")
+local table = require("apisix.core.table")
 local yaml = require("tinyyaml")
+
 local io_open = io.open
 local type = type
 local str_gmatch = string.gmatch
@@ -57,16 +59,6 @@ local function is_empty_yaml_line(line)
 end
 
 
-local function tab_is_array(t)
-local count = 0
-for k,v in pairs(t) do
-count = count + 1
-end
-
-return #t == count
-end
-
-
 local function tinyyaml_type(t)
 local mt = getmetatable(t)
 if mt then
@@ -84,7 +76,7 @@ local function merge_conf(base, new_tab, ppath)
 if tinyyaml_type(val) == "null" then
 base[key] = nil
 
-elseif tab_is_array(val) then
+elseif table.isarray(val) then
 base[key] = val
 
 else



[GitHub] [apisix] moonming merged pull request #2365: optimize: use table.isarray to check whether table is an array.

2020-10-09 Thread GitBox


moonming merged pull request #2365:
URL: https://github.com/apache/apisix/pull/2365


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] moonming closed issue #2361: perf: use `table.isarray` which is can be JIT compiled

2020-10-09 Thread GitBox


moonming closed issue #2361:
URL: https://github.com/apache/apisix/issues/2361


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706033238


   I will merge this pr. 
   so that we could move forward.
   we could fix other issues later.
   
   @moonming @membphis @juzhiyuan @ShiningRush 
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] moonming commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


moonming commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706034228


   > I will merge this pr.
   > so that we could move forward.
   > we could fix other issues later.
   > 
   > @moonming @membphis @juzhiyuan @ShiningRush
   
   please create issues for them



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] tanjiancheng opened a new issue #2366: bug: gRPC transcoding plugin how to support import other proto file?

2020-10-09 Thread GitBox


tanjiancheng opened a new issue #2366:
URL: https://github.com/apache/apisix/issues/2366


   ###
   I use the `import google/api/annotations.proto` just for test 
   ```
   curl http://127.0.0.1:9080/apisix/admin/proto/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
   "content" : "syntax = \"proto3\";
   package helloworld;
import \"google/api/annotations.proto\";
   service Greeter {
   rpc SayHello (HelloRequest) returns (HelloReply) {}
   }
   message HelloRequest {
   string name = 1;
   }
   message HelloReply {
   string message = 1;
   }"
   }'
   ```
   and then return the error like this:
   ```
   2020/10/09 07:47:23 [error] 25#25: *168534 lua entry thread aborted: runtime 
error: /usr/local/apisix//deps/share/lua/5.1/protoc.lua:283: module load error: 
google/api/annotations.proto
   ./google/api/annotations.proto: No such file or directory
   stack traceback:
   coroutine 0:
   [C]: in function 'error'
   /usr/local/apisix//deps/share/lua/5.1/protoc.lua:283: in function 
'parsefile'
   /usr/local/apisix//deps/share/lua/5.1/protoc.lua:447: in function 
'top_parser'
   /usr/local/apisix//deps/share/lua/5.1/protoc.lua:771: in function 'f'
   /usr/local/apisix//deps/share/lua/5.1/protoc.lua:1028: in function 
'do_compile'
   /usr/local/apisix//deps/share/lua/5.1/protoc.lua:1032: in function 
'compile'
   /usr/local/apisix//deps/share/lua/5.1/protoc.lua:1042: in function 
'load'
   /usr/local/apisix/apisix/plugins/grpc-transcode/proto.lua:46: in 
function 'create_obj_fun'
   /usr/local/apisix/apisix/core/lrucache.lua:134: in function 'fetch'
   /usr/local/apisix/apisix/plugins/grpc-transcode.lua:117: in function 
'phase_func'
   /usr/local/apisix/apisix/init.lua:138: in function 'run_plugin'
   /usr/local/apisix/apisix/init.lua:595: in function 
'grpc_access_phase'
   ```
   The actual use contains other more complex scenarios,how to support this?
   
   ### Environment
   
   * apisix version:1.5
   * OS: centos7



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen opened a new issue #545: feature: add code coverage for `api`

2020-10-09 Thread GitBox


nic-chen opened a new issue #545:
URL: https://github.com/apache/apisix-dashboard/issues/545


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   - [ ] Bug
   - [x] Requirements
   - [x] Feature or performance improvement
   - [ ] Other
   
   ___
   ### Requirement or improvement
   
   Add code coverage for `api`
   And improve code coverage
   
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706037507


   > > I will merge this pr.
   > > so that we could move forward.
   > > we could fix other issues later.
   > > @moonming @membphis @juzhiyuan @ShiningRush
   > 
   > please create issues for them
   
   ok



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen opened a new issue #546: [refactor] license issue of refactored `api`

2020-10-09 Thread GitBox


nic-chen opened a new issue #546:
URL: https://github.com/apache/apisix-dashboard/issues/546


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   - [ ] Bug
   - [ ] Requirements
   - [ ] Feature or performance improvement
   - [x] Other
   
   
   ___
   ### Requirement or improvement
   
   need to use the right way to fix license issue because some code is copied 
from Kubernetes dashboard, and current way is not right.
   
   
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


juzhiyuan commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706039192


   Please link this PR in those issues :D



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen merged pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen merged pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706044477


   > Please link this PR in those issues :D
   
   OK



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[apisix-dashboard] branch refactor updated: feat: refactor apis for existing check and other apis (#535)

2020-10-09 Thread chenjunxu
This is an automated email from the ASF dual-hosted git repository.

chenjunxu pushed a commit to branch refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/refactor by this push:
 new caccfb7  feat: refactor apis for existing check and other apis (#535)
caccfb7 is described below

commit caccfb75c57eb2e85466b42cf5b7a4368f1e96a8
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Fri Oct 9 16:21:49 2020 +0800

feat: refactor apis for existing check and other apis (#535)

* fix code style

* fix code style

* feat support query

* feat: support query

* change: `like` to `equal`

* fix api status

* feat: upstream existing check

* feat: refactor api for upstream names

* fix: license

* test: add unit test cases

* fix: update bug

* test: add test cases for route

* fix: unified respond format

* test: remove test bug

* feat: ssl existing check

* fix bug: auto generate id

* fix: improve consumer

* fix: remove key and keys in ssl respond

* fix: when list is empty, should respond an empty array

* fix code style

* feat: plugin orchestration

* fix delete bug

* fix bug

* fix: keep the same request params and respond with the old format
---
 api/errno/error.go |  22 +-
 api/internal/core/entity/entity.go |  32 ++-
 api/internal/core/entity/query.go  | 153 +++
 api/internal/core/store/query.go   | 151 +++
 api/internal/core/store/selector.go| 144 +++
 api/internal/core/store/selector_test.go   | 285 +
 api/internal/core/store/store.go   |  38 ++-
 api/internal/core/store/storehub.go|  80 ++
 api/internal/handler/consumer/consumer.go  |  20 +-
 api/internal/handler/route/route.go| 158 +++-
 api/internal/handler/service/service.go|   4 +-
 api/internal/handler/ssl/ssl.go| 123 -
 api/internal/handler/upstream/upstream.go  |  81 +-
 .../storehub.go => utils/consts/api_error.go}  |  57 ++---
 api/main.go|  76 +-
 api/route/base_test.go |  67 +
 api/route/route_test.go| 195 ++
 17 files changed, 1468 insertions(+), 218 deletions(-)

diff --git a/api/errno/error.go b/api/errno/error.go
index effe063..0c18dec 100644
--- a/api/errno/error.go
+++ b/api/errno/error.go
@@ -23,8 +23,8 @@ import (
 
 type Message struct {
Code   string
-   Msgstring
-   Status int `json:"-"`
+   Msgstring `json:"message"`
+   Status int`json:"-"`
 }
 
 var (
@@ -128,25 +128,25 @@ func New(m Message, args ...interface{}) *ManagerError {
 
 func (e *ManagerError) Response() map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
+   "code":e.Code,
+   "message": e.Msg,
}
 }
 
 func (e *ManagerError) ItemResponse(data interface{}) map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
-   "data": data,
+   "code":e.Code,
+   "message": e.Msg,
+   "data":data,
}
 }
 
 func (e *ManagerError) ListResponse(count, list interface{}) 
map[string]interface{} {
return map[string]interface{}{
-   "code":  e.Code,
-   "msg":   e.Msg,
-   "count": count,
-   "list":  list,
+   "code":e.Code,
+   "message": e.Msg,
+   "count":   count,
+   "list":list,
}
 }
 
diff --git a/api/internal/core/entity/entity.go 
b/api/internal/core/entity/entity.go
index 0a38c82..8a2fae4 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -44,7 +44,7 @@ type Route struct {
RemoteAddrs []string`json:"remote_addrs,omitempty"`
Varsstring  `json:"vars,omitempty"`
FilterFunc  string  `json:"filter_func,omitempty"`
-   Script  string  `json:"script,omitempty"`
+   Script  interface{} `json:"script,omitempty"`
Plugins interface{} `json:"plugins,omitempty"`
UpstreamUpstream`json:"upstream,omitempty"`
ServiceID   string  `json:"service_id,omitempty"`
@@ -113,6 +113,7 @@ type HealthChecker struct {
 }
 
 type Upstream struct {
+   BaseInfo
Nodes   []Node`json:"nodes,omitempty"`
Retries int

[apisix-dashboard] branch refactor updated: feat: refactor apis for existing check and other apis (#535)

2020-10-09 Thread chenjunxu
This is an automated email from the ASF dual-hosted git repository.

chenjunxu pushed a commit to branch refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/refactor by this push:
 new caccfb7  feat: refactor apis for existing check and other apis (#535)
caccfb7 is described below

commit caccfb75c57eb2e85466b42cf5b7a4368f1e96a8
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Fri Oct 9 16:21:49 2020 +0800

feat: refactor apis for existing check and other apis (#535)

* fix code style

* fix code style

* feat support query

* feat: support query

* change: `like` to `equal`

* fix api status

* feat: upstream existing check

* feat: refactor api for upstream names

* fix: license

* test: add unit test cases

* fix: update bug

* test: add test cases for route

* fix: unified respond format

* test: remove test bug

* feat: ssl existing check

* fix bug: auto generate id

* fix: improve consumer

* fix: remove key and keys in ssl respond

* fix: when list is empty, should respond an empty array

* fix code style

* feat: plugin orchestration

* fix delete bug

* fix bug

* fix: keep the same request params and respond with the old format
---
 api/errno/error.go |  22 +-
 api/internal/core/entity/entity.go |  32 ++-
 api/internal/core/entity/query.go  | 153 +++
 api/internal/core/store/query.go   | 151 +++
 api/internal/core/store/selector.go| 144 +++
 api/internal/core/store/selector_test.go   | 285 +
 api/internal/core/store/store.go   |  38 ++-
 api/internal/core/store/storehub.go|  80 ++
 api/internal/handler/consumer/consumer.go  |  20 +-
 api/internal/handler/route/route.go| 158 +++-
 api/internal/handler/service/service.go|   4 +-
 api/internal/handler/ssl/ssl.go| 123 -
 api/internal/handler/upstream/upstream.go  |  81 +-
 .../storehub.go => utils/consts/api_error.go}  |  57 ++---
 api/main.go|  76 +-
 api/route/base_test.go |  67 +
 api/route/route_test.go| 195 ++
 17 files changed, 1468 insertions(+), 218 deletions(-)

diff --git a/api/errno/error.go b/api/errno/error.go
index effe063..0c18dec 100644
--- a/api/errno/error.go
+++ b/api/errno/error.go
@@ -23,8 +23,8 @@ import (
 
 type Message struct {
Code   string
-   Msgstring
-   Status int `json:"-"`
+   Msgstring `json:"message"`
+   Status int`json:"-"`
 }
 
 var (
@@ -128,25 +128,25 @@ func New(m Message, args ...interface{}) *ManagerError {
 
 func (e *ManagerError) Response() map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
+   "code":e.Code,
+   "message": e.Msg,
}
 }
 
 func (e *ManagerError) ItemResponse(data interface{}) map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
-   "data": data,
+   "code":e.Code,
+   "message": e.Msg,
+   "data":data,
}
 }
 
 func (e *ManagerError) ListResponse(count, list interface{}) 
map[string]interface{} {
return map[string]interface{}{
-   "code":  e.Code,
-   "msg":   e.Msg,
-   "count": count,
-   "list":  list,
+   "code":e.Code,
+   "message": e.Msg,
+   "count":   count,
+   "list":list,
}
 }
 
diff --git a/api/internal/core/entity/entity.go 
b/api/internal/core/entity/entity.go
index 0a38c82..8a2fae4 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -44,7 +44,7 @@ type Route struct {
RemoteAddrs []string`json:"remote_addrs,omitempty"`
Varsstring  `json:"vars,omitempty"`
FilterFunc  string  `json:"filter_func,omitempty"`
-   Script  string  `json:"script,omitempty"`
+   Script  interface{} `json:"script,omitempty"`
Plugins interface{} `json:"plugins,omitempty"`
UpstreamUpstream`json:"upstream,omitempty"`
ServiceID   string  `json:"service_id,omitempty"`
@@ -113,6 +113,7 @@ type HealthChecker struct {
 }
 
 type Upstream struct {
+   BaseInfo
Nodes   []Node`json:"nodes,omitempty"`
Retries int

[apisix-dashboard] branch refactor updated: feat: refactor apis for existing check and other apis (#535)

2020-10-09 Thread chenjunxu
This is an automated email from the ASF dual-hosted git repository.

chenjunxu pushed a commit to branch refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/refactor by this push:
 new caccfb7  feat: refactor apis for existing check and other apis (#535)
caccfb7 is described below

commit caccfb75c57eb2e85466b42cf5b7a4368f1e96a8
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Fri Oct 9 16:21:49 2020 +0800

feat: refactor apis for existing check and other apis (#535)

* fix code style

* fix code style

* feat support query

* feat: support query

* change: `like` to `equal`

* fix api status

* feat: upstream existing check

* feat: refactor api for upstream names

* fix: license

* test: add unit test cases

* fix: update bug

* test: add test cases for route

* fix: unified respond format

* test: remove test bug

* feat: ssl existing check

* fix bug: auto generate id

* fix: improve consumer

* fix: remove key and keys in ssl respond

* fix: when list is empty, should respond an empty array

* fix code style

* feat: plugin orchestration

* fix delete bug

* fix bug

* fix: keep the same request params and respond with the old format
---
 api/errno/error.go |  22 +-
 api/internal/core/entity/entity.go |  32 ++-
 api/internal/core/entity/query.go  | 153 +++
 api/internal/core/store/query.go   | 151 +++
 api/internal/core/store/selector.go| 144 +++
 api/internal/core/store/selector_test.go   | 285 +
 api/internal/core/store/store.go   |  38 ++-
 api/internal/core/store/storehub.go|  80 ++
 api/internal/handler/consumer/consumer.go  |  20 +-
 api/internal/handler/route/route.go| 158 +++-
 api/internal/handler/service/service.go|   4 +-
 api/internal/handler/ssl/ssl.go| 123 -
 api/internal/handler/upstream/upstream.go  |  81 +-
 .../storehub.go => utils/consts/api_error.go}  |  57 ++---
 api/main.go|  76 +-
 api/route/base_test.go |  67 +
 api/route/route_test.go| 195 ++
 17 files changed, 1468 insertions(+), 218 deletions(-)

diff --git a/api/errno/error.go b/api/errno/error.go
index effe063..0c18dec 100644
--- a/api/errno/error.go
+++ b/api/errno/error.go
@@ -23,8 +23,8 @@ import (
 
 type Message struct {
Code   string
-   Msgstring
-   Status int `json:"-"`
+   Msgstring `json:"message"`
+   Status int`json:"-"`
 }
 
 var (
@@ -128,25 +128,25 @@ func New(m Message, args ...interface{}) *ManagerError {
 
 func (e *ManagerError) Response() map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
+   "code":e.Code,
+   "message": e.Msg,
}
 }
 
 func (e *ManagerError) ItemResponse(data interface{}) map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
-   "data": data,
+   "code":e.Code,
+   "message": e.Msg,
+   "data":data,
}
 }
 
 func (e *ManagerError) ListResponse(count, list interface{}) 
map[string]interface{} {
return map[string]interface{}{
-   "code":  e.Code,
-   "msg":   e.Msg,
-   "count": count,
-   "list":  list,
+   "code":e.Code,
+   "message": e.Msg,
+   "count":   count,
+   "list":list,
}
 }
 
diff --git a/api/internal/core/entity/entity.go 
b/api/internal/core/entity/entity.go
index 0a38c82..8a2fae4 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -44,7 +44,7 @@ type Route struct {
RemoteAddrs []string`json:"remote_addrs,omitempty"`
Varsstring  `json:"vars,omitempty"`
FilterFunc  string  `json:"filter_func,omitempty"`
-   Script  string  `json:"script,omitempty"`
+   Script  interface{} `json:"script,omitempty"`
Plugins interface{} `json:"plugins,omitempty"`
UpstreamUpstream`json:"upstream,omitempty"`
ServiceID   string  `json:"service_id,omitempty"`
@@ -113,6 +113,7 @@ type HealthChecker struct {
 }
 
 type Upstream struct {
+   BaseInfo
Nodes   []Node`json:"nodes,omitempty"`
Retries int

[apisix-dashboard] branch refactor updated: feat: refactor apis for existing check and other apis (#535)

2020-10-09 Thread chenjunxu
This is an automated email from the ASF dual-hosted git repository.

chenjunxu pushed a commit to branch refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/refactor by this push:
 new caccfb7  feat: refactor apis for existing check and other apis (#535)
caccfb7 is described below

commit caccfb75c57eb2e85466b42cf5b7a4368f1e96a8
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Fri Oct 9 16:21:49 2020 +0800

feat: refactor apis for existing check and other apis (#535)

* fix code style

* fix code style

* feat support query

* feat: support query

* change: `like` to `equal`

* fix api status

* feat: upstream existing check

* feat: refactor api for upstream names

* fix: license

* test: add unit test cases

* fix: update bug

* test: add test cases for route

* fix: unified respond format

* test: remove test bug

* feat: ssl existing check

* fix bug: auto generate id

* fix: improve consumer

* fix: remove key and keys in ssl respond

* fix: when list is empty, should respond an empty array

* fix code style

* feat: plugin orchestration

* fix delete bug

* fix bug

* fix: keep the same request params and respond with the old format
---
 api/errno/error.go |  22 +-
 api/internal/core/entity/entity.go |  32 ++-
 api/internal/core/entity/query.go  | 153 +++
 api/internal/core/store/query.go   | 151 +++
 api/internal/core/store/selector.go| 144 +++
 api/internal/core/store/selector_test.go   | 285 +
 api/internal/core/store/store.go   |  38 ++-
 api/internal/core/store/storehub.go|  80 ++
 api/internal/handler/consumer/consumer.go  |  20 +-
 api/internal/handler/route/route.go| 158 +++-
 api/internal/handler/service/service.go|   4 +-
 api/internal/handler/ssl/ssl.go| 123 -
 api/internal/handler/upstream/upstream.go  |  81 +-
 .../storehub.go => utils/consts/api_error.go}  |  57 ++---
 api/main.go|  76 +-
 api/route/base_test.go |  67 +
 api/route/route_test.go| 195 ++
 17 files changed, 1468 insertions(+), 218 deletions(-)

diff --git a/api/errno/error.go b/api/errno/error.go
index effe063..0c18dec 100644
--- a/api/errno/error.go
+++ b/api/errno/error.go
@@ -23,8 +23,8 @@ import (
 
 type Message struct {
Code   string
-   Msgstring
-   Status int `json:"-"`
+   Msgstring `json:"message"`
+   Status int`json:"-"`
 }
 
 var (
@@ -128,25 +128,25 @@ func New(m Message, args ...interface{}) *ManagerError {
 
 func (e *ManagerError) Response() map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
+   "code":e.Code,
+   "message": e.Msg,
}
 }
 
 func (e *ManagerError) ItemResponse(data interface{}) map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
-   "data": data,
+   "code":e.Code,
+   "message": e.Msg,
+   "data":data,
}
 }
 
 func (e *ManagerError) ListResponse(count, list interface{}) 
map[string]interface{} {
return map[string]interface{}{
-   "code":  e.Code,
-   "msg":   e.Msg,
-   "count": count,
-   "list":  list,
+   "code":e.Code,
+   "message": e.Msg,
+   "count":   count,
+   "list":list,
}
 }
 
diff --git a/api/internal/core/entity/entity.go 
b/api/internal/core/entity/entity.go
index 0a38c82..8a2fae4 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -44,7 +44,7 @@ type Route struct {
RemoteAddrs []string`json:"remote_addrs,omitempty"`
Varsstring  `json:"vars,omitempty"`
FilterFunc  string  `json:"filter_func,omitempty"`
-   Script  string  `json:"script,omitempty"`
+   Script  interface{} `json:"script,omitempty"`
Plugins interface{} `json:"plugins,omitempty"`
UpstreamUpstream`json:"upstream,omitempty"`
ServiceID   string  `json:"service_id,omitempty"`
@@ -113,6 +113,7 @@ type HealthChecker struct {
 }
 
 type Upstream struct {
+   BaseInfo
Nodes   []Node`json:"nodes,omitempty"`
Retries int

[apisix-dashboard] branch refactor updated: feat: refactor apis for existing check and other apis (#535)

2020-10-09 Thread chenjunxu
This is an automated email from the ASF dual-hosted git repository.

chenjunxu pushed a commit to branch refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/refactor by this push:
 new caccfb7  feat: refactor apis for existing check and other apis (#535)
caccfb7 is described below

commit caccfb75c57eb2e85466b42cf5b7a4368f1e96a8
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Fri Oct 9 16:21:49 2020 +0800

feat: refactor apis for existing check and other apis (#535)

* fix code style

* fix code style

* feat support query

* feat: support query

* change: `like` to `equal`

* fix api status

* feat: upstream existing check

* feat: refactor api for upstream names

* fix: license

* test: add unit test cases

* fix: update bug

* test: add test cases for route

* fix: unified respond format

* test: remove test bug

* feat: ssl existing check

* fix bug: auto generate id

* fix: improve consumer

* fix: remove key and keys in ssl respond

* fix: when list is empty, should respond an empty array

* fix code style

* feat: plugin orchestration

* fix delete bug

* fix bug

* fix: keep the same request params and respond with the old format
---
 api/errno/error.go |  22 +-
 api/internal/core/entity/entity.go |  32 ++-
 api/internal/core/entity/query.go  | 153 +++
 api/internal/core/store/query.go   | 151 +++
 api/internal/core/store/selector.go| 144 +++
 api/internal/core/store/selector_test.go   | 285 +
 api/internal/core/store/store.go   |  38 ++-
 api/internal/core/store/storehub.go|  80 ++
 api/internal/handler/consumer/consumer.go  |  20 +-
 api/internal/handler/route/route.go| 158 +++-
 api/internal/handler/service/service.go|   4 +-
 api/internal/handler/ssl/ssl.go| 123 -
 api/internal/handler/upstream/upstream.go  |  81 +-
 .../storehub.go => utils/consts/api_error.go}  |  57 ++---
 api/main.go|  76 +-
 api/route/base_test.go |  67 +
 api/route/route_test.go| 195 ++
 17 files changed, 1468 insertions(+), 218 deletions(-)

diff --git a/api/errno/error.go b/api/errno/error.go
index effe063..0c18dec 100644
--- a/api/errno/error.go
+++ b/api/errno/error.go
@@ -23,8 +23,8 @@ import (
 
 type Message struct {
Code   string
-   Msgstring
-   Status int `json:"-"`
+   Msgstring `json:"message"`
+   Status int`json:"-"`
 }
 
 var (
@@ -128,25 +128,25 @@ func New(m Message, args ...interface{}) *ManagerError {
 
 func (e *ManagerError) Response() map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
+   "code":e.Code,
+   "message": e.Msg,
}
 }
 
 func (e *ManagerError) ItemResponse(data interface{}) map[string]interface{} {
return map[string]interface{}{
-   "code": e.Code,
-   "msg":  e.Msg,
-   "data": data,
+   "code":e.Code,
+   "message": e.Msg,
+   "data":data,
}
 }
 
 func (e *ManagerError) ListResponse(count, list interface{}) 
map[string]interface{} {
return map[string]interface{}{
-   "code":  e.Code,
-   "msg":   e.Msg,
-   "count": count,
-   "list":  list,
+   "code":e.Code,
+   "message": e.Msg,
+   "count":   count,
+   "list":list,
}
 }
 
diff --git a/api/internal/core/entity/entity.go 
b/api/internal/core/entity/entity.go
index 0a38c82..8a2fae4 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -44,7 +44,7 @@ type Route struct {
RemoteAddrs []string`json:"remote_addrs,omitempty"`
Varsstring  `json:"vars,omitempty"`
FilterFunc  string  `json:"filter_func,omitempty"`
-   Script  string  `json:"script,omitempty"`
+   Script  interface{} `json:"script,omitempty"`
Plugins interface{} `json:"plugins,omitempty"`
UpstreamUpstream`json:"upstream,omitempty"`
ServiceID   string  `json:"service_id,omitempty"`
@@ -113,6 +113,7 @@ type HealthChecker struct {
 }
 
 type Upstream struct {
+   BaseInfo
Nodes   []Node`json:"nodes,omitempty"`
Retries int

[apisix] branch master updated: feat: add new filed `meta_style`, collect the request information with `original` style. (#2364)

2020-10-09 Thread wenming
This is an automated email from the ASF dual-hosted git repository.

wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 73dfdf2  feat: add new filed `meta_style`, collect the request 
information with `original` style. (#2364)
73dfdf2 is described below

commit 73dfdf2185c52acb395c6627dd9d4294efdb3733
Author: YuanSheng Wang 
AuthorDate: Fri Oct 9 16:33:07 2020 +0800

feat: add new filed `meta_style`, collect the request information with 
`original` style. (#2364)
---
 apisix/plugins/kafka-logger.lua   |  31 +--
 apisix/utils/log-util.lua |  26 +-
 doc/plugins/kafka-logger.md   |  26 +-
 doc/zh-cn/plugins/kafka-logger.md |  33 +--
 t/plugin/kafka-logger.t   | 186 +-
 5 files changed, 280 insertions(+), 22 deletions(-)

diff --git a/apisix/plugins/kafka-logger.lua b/apisix/plugins/kafka-logger.lua
index 6377bf1..0f7e767 100644
--- a/apisix/plugins/kafka-logger.lua
+++ b/apisix/plugins/kafka-logger.lua
@@ -32,6 +32,11 @@ local buffers = {}
 local schema = {
 type = "object",
 properties = {
+meta_format = {
+type = "string",
+default = "default",
+enum = {"default", "origin"},
+},
 broker_list = {
 type = "object"
 },
@@ -93,7 +98,7 @@ local function send_kafka_data(conf, log_message)
 return nil, "failed to send data to Kafka topic" .. err
 end
 
-return true, nil
+return true
 end
 
 -- remove stale objects from the memory after timer expires
@@ -113,22 +118,24 @@ local function remove_stale_objects(premature)
 end
 
 
-function _M.log(conf)
-local entry = log_util.get_full_log(ngx, conf)
+function _M.log(conf, ctx)
+local entry
+if conf.meta_format == "origin" then
+entry = log_util.get_req_original(ctx, conf)
+-- core.log.info("origin entry: ", entry)
 
-if not entry.route_id then
-core.log.error("failed to obtain the route id for kafka logger")
-return
+else
+entry = log_util.get_full_log(ngx, conf)
+core.log.info("full log entry: ", core.json.delay_encode(entry))
 end
 
-local log_buffer = buffers[entry.route_id]
-
 if not stale_timer_running then
 -- run the timer every 30 mins if any log is present
 timer_at(1800, remove_stale_objects)
 stale_timer_running = true
 end
 
+local log_buffer = buffers[conf]
 if log_buffer then
 log_buffer:push(entry)
 return
@@ -138,7 +145,10 @@ function _M.log(conf)
 local func = function(entries, batch_max_size)
 local data, err
 if batch_max_size == 1 then
-data, err = core.json.encode(entries[1]) -- encode as single {}
+data = entries[1]
+if type(data) ~= "string" then
+data, err = core.json.encode(data) -- encode as single {}
+end
 else
 data, err = core.json.encode(entries) -- encode as array [{}]
 end
@@ -147,6 +157,7 @@ function _M.log(conf)
 return false, 'error occurred while encoding the data: ' .. err
 end
 
+core.log.info("send data to kafka: ", data)
 return send_kafka_data(conf, data)
 end
 
@@ -167,7 +178,7 @@ function _M.log(conf)
 return
 end
 
-buffers[entry.route_id] = log_buffer
+buffers[conf] = log_buffer
 log_buffer:push(entry)
 end
 
diff --git a/apisix/utils/log-util.lua b/apisix/utils/log-util.lua
index b11a435..131d9b2 100644
--- a/apisix/utils/log-util.lua
+++ b/apisix/utils/log-util.lua
@@ -14,10 +14,13 @@
 -- See the License for the specific language governing permissions and
 -- limitations under the License.
 --
-local core = require("apisix.core")
+local core = require("apisix.core")
+local ngx  = ngx
+local pairs = pairs
 
 local _M = {}
 
+
 local function get_full_log(ngx, conf)
 local ctx = ngx.ctx.api_ctx
 local var = ctx.var
@@ -71,6 +74,25 @@ local function get_full_log(ngx, conf)
 
 return log
 end
-
 _M.get_full_log = get_full_log
+
+
+function _M.get_req_original(ctx, conf)
+local headers = {
+ctx.var.request, "\r\n"
+}
+for k, v in pairs(ngx.req.get_headers()) do
+core.table.insert_tail(headers, k, ": ", v, "\r\n")
+end
+-- core.log.error("headers: ", core.table.concat(headers, ""))
+core.table.insert(headers, "\r\n")
+
+if conf.include_req_body then
+core.table.insert(headers, ctx.var.request_body)
+end
+
+return core.table.concat(headers, "")
+end
+
+
 return _M
diff --git a/doc/plugins/kafka-logger.md b/doc/plugins/kafka-logger.md
index d0b7380..9b6bb47 100644
--- a/doc/plugins/kafka-logger.md
+++ b/doc/plugins/kafka-logger.md
@@ -20,6 +20,7 @@
 - [中文](../zh-cn/plugins/kafka-logger.md)
 
 # Summary
+
 - [**Name**](#name)
 - [**Attributes**

[GitHub] [apisix] moonming merged pull request #2364: feat: add new filed `meta_style`, collect the request information with `original` style.

2020-10-09 Thread GitBox


moonming merged pull request #2364:
URL: https://github.com/apache/apisix/pull/2364


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis merged pull request #2357: bugfix: set random seed for each worker process at `init_worker` phase, only `init` phase is not enough.

2020-10-09 Thread GitBox


membphis merged pull request #2357:
URL: https://github.com/apache/apisix/pull/2357


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[apisix] branch master updated: bugfix: set random seed for each worker process at `init_worker` phase, only `init` phase is not enough. (#2357)

2020-10-09 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 251625d  bugfix: set random seed for each worker process at 
`init_worker` phase, only `init` phase is not enough. (#2357)
251625d is described below

commit 251625d8ab969b0b46d12041beff44f329e95321
Author: YuanSheng Wang 
AuthorDate: Fri Oct 9 16:39:49 2020 +0800

bugfix: set random seed for each worker process at `init_worker` phase, 
only `init` phase is not enough. (#2357)
---
 apisix/core/id.lua |  1 +
 apisix/init.lua| 25 -
 t/core/random.t| 76 ++
 t/stream-node/random.t | 76 ++
 4 files changed, 171 insertions(+), 7 deletions(-)

diff --git a/apisix/core/id.lua b/apisix/core/id.lua
index 5470f7a..d6e728d 100644
--- a/apisix/core/id.lua
+++ b/apisix/core/id.lua
@@ -65,6 +65,7 @@ function _M.init()
 return
 end
 
+uuid.seed()
 apisix_uid = uuid.generate_v4()
 log.notice("not found apisix uid, generate a new one: ", apisix_uid)
 
diff --git a/apisix/init.lua b/apisix/init.lua
index 3d9ffea..5d773ab 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -63,13 +63,6 @@ function _M.http_init(args)
  "maxrecord=8000", "sizemcode=64",
  "maxmcode=4000", "maxirconst=1000")
 
---
-local seed, err = core.utils.get_seed_from_urandom()
-if not seed then
-core.log.warn('failed to get seed from urandom: ', err)
-seed = ngx_now() * 1000 + ngx.worker.pid()
-end
-math.randomseed(seed)
 parse_args(args)
 core.id.init()
 
@@ -82,6 +75,15 @@ end
 
 
 function _M.http_init_worker()
+local seed, err = core.utils.get_seed_from_urandom()
+if not seed then
+core.log.warn('failed to get seed from urandom: ', err)
+seed = ngx_now() * 1000 + ngx.worker.pid()
+end
+math.randomseed(seed)
+-- for testing only
+core.log.info("random test in [1, 1]: ", math.random(1, 100))
+
 local we = require("resty.worker.events")
 local ok, err = we.configure({shm = "worker-events", interval = 0.1})
 if not ok then
@@ -759,6 +761,15 @@ end
 
 function _M.stream_init_worker()
 core.log.info("enter stream_init_worker")
+local seed, err = core.utils.get_seed_from_urandom()
+if not seed then
+core.log.warn('failed to get seed from urandom: ', err)
+seed = ngx_now() * 1000 + ngx.worker.pid()
+end
+math.randomseed(seed)
+-- for testing only
+core.log.info("random stream test in [1, 1]: ", math.random(1, 
100))
+
 router.stream_init_worker()
 plugin.init_worker()
 
diff --git a/t/core/random.t b/t/core/random.t
new file mode 100644
index 000..8d7d403
--- /dev/null
+++ b/t/core/random.t
@@ -0,0 +1,76 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+use t::APISIX 'no_plan';
+
+master_on();
+workers(4);
+repeat_each(1);
+no_long_string();
+no_root_location();
+log_level("info");
+
+run_tests;
+
+__DATA__
+
+=== TEST 1: generate different random number in different worker process
+--- config
+location /t {
+content_by_lua_block {
+local log_file = ngx.config.prefix() .. "logs/error.log"
+local file = io.open(log_file, "r")
+local log = file:read("*a")
+
+local it, err = ngx.re.gmatch(log, [[random test in \[1, 1\]: 
(\d+)]], "jom")
+if not it then
+ngx.log(ngx.ERR, "failed to gmatch: ", err)
+return
+end
+
+local random_nums = {}
+while true do
+local m, err = it()
+if err then
+ngx.log(ngx.ERR, "error: ", err)
+return
+end
+
+if not m then
+break
+end
+
+-- found a match
+table.insert(random_nums, m[1])
+end
+
+for i = 2, #random_nums do
+   

[GitHub] [apisix] membphis commented on pull request #2306: 1.fix generation of uuid;

2020-10-09 Thread GitBox


membphis commented on pull request #2306:
URL: https://github.com/apache/apisix/pull/2306#issuecomment-706052308


   resolve this bug by another PR: https://github.com/apache/apisix/pull/2357
   I think we can close this PR. @zlm0125 
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on issue #2366: bug: gRPC transcoding plugin how to support import other proto file?

2020-10-09 Thread GitBox


membphis commented on issue #2366:
URL: https://github.com/apache/apisix/issues/2366#issuecomment-706053507


   @nic-chen do you know how to resolve this issue?



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2340: feature: limit-count use redis cluster

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2340:
URL: https://github.com/apache/apisix/pull/2340#discussion_r502279935



##
File path: apisix/plugins/limit-count/limit-count-redis-cluster.lua
##
@@ -0,0 +1,139 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local resty_lock = require("resty.lock")
+local assert = assert
+local setmetatable = setmetatable
+local tostring = tostring
+local require = require
+local ipairs  = ipairs
+
+
+local _M = {version = 0.3}
+
+
+local mt = {
+__index = _M
+}
+
+-- https://github.com/steve0511/resty-redis-cluster
+local function new_redis_cluster(conf)
+local config = {
+dict_name = "redis_cluster_slot_locks", --shared dictionary name for 
locks
+name = "apisix-rediscluster",   --rediscluster name
+keepalive_timeout = 6,  --redis connection pool idle 
timeout
+keepalive_cons = 1000,  --redis connection pool size
+connect_timeout = 1000, --timeout while connecting
+max_redirection = 5,--maximum retry attempts for 
redirection
+max_connection_attempts = 1,--maximum retry attempts for 
connection
+read_timeout = conf.redis_timeout or 1000,
+enable_slave_read = true,
+serv_list = {},
+}
+
+for key, value in ipairs(conf.redis_serv_list) do
+if value['redis_host'] and value['redis_port'] then
+config.serv_list[key] = {ip = value['redis_host'], port = 
value['redis_port']}
+end
+end
+
+if conf.redis_password then
+config.auth = conf.redis_password --set password while setting auth
+end
+
+local redis_cluster = require "resty.rediscluster"
+local red_c = redis_cluster:new(config)

Review comment:
   I think it may fail, need to capture the error message

##
File path: apisix/plugins/limit-count/limit-count-redis-cluster.lua
##
@@ -0,0 +1,139 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local resty_lock = require("resty.lock")
+local assert = assert
+local setmetatable = setmetatable
+local tostring = tostring
+local require = require
+local ipairs  = ipairs
+
+
+local _M = {version = 0.3}
+
+
+local mt = {
+__index = _M
+}
+
+-- https://github.com/steve0511/resty-redis-cluster
+local function new_redis_cluster(conf)
+local config = {
+dict_name = "redis_cluster_slot_locks", --shared dictionary name for 
locks
+name = "apisix-rediscluster",   --rediscluster name
+keepalive_timeout = 6,  --redis connection pool idle 
timeout

Review comment:
   can we use the default value here?

##
File path: doc/plugins/limit-count.md
##
@@ -109,6 +110,41 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 
'X-API-KEY: edd1c9f034335
 }'
 ```
 
+If using redis-cluster:
+
+```shell
+curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"uri": "/index.html",
+"plugins": {
+"limit-count": {
+"count": 2,
+"time_window": 60,
+"rejected_code": 503,
+"key": "remote_addr",
+"policy": "redis-cluster",
+"redis_serv_list": [
+   {

Review comment:
   how about this style? 

[GitHub] [apisix] gy09535 commented on issue #2151: feature: Best practice for jaeger

2020-10-09 Thread GitBox


gy09535 commented on issue #2151:
URL: https://github.com/apache/apisix/issues/2151#issuecomment-706060672


   After retry I think use zipkin plugin to send v2 span can work, ref: 
https://www.jaegertracing.io/docs/1.19/getting-started/



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-helm-chart] ziyou434 opened a new issue #2: failed to fetch data from etcd

2020-10-09 Thread GitBox


ziyou434 opened a new issue #2:
URL: https://github.com/apache/apisix-helm-chart/issues/2


   `2020/10/09 09:00:27 [error] 15#15: *8 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/upstreams, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 16#16: *11 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/consumers, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 15#15: *18 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/proto, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 16#16: *10 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/proto, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 16#16: *9 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/services, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 15#15: *17 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/services, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 15#15: *16 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/global_rules, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 16#16: *5 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/routes, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 15#15: *15 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/ssl, context: 
ngx.timer
   2020/10/09 09:00:27 [error] 16#16: *7 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/global_rules, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 15#15: *14 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/routes, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 16#16: *6 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/ssl, context: 
ngx.timer
   2020/10/09 09:00:27 [error] 15#15: *20 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/consumers, 
context: ngx.timer
   2020/10/09 09:00:27 [error] 16#16: *3 [lua] config_etcd.lua:351: failed to 
fetch data from etcd: failed to read etcd dir, etcd key: /apisix/upstreams, 
context: ngx.timer
   2020/10/09 09:00:32 [error] 15#15: *19 [lua] heartbeat.lua:117: failed to 
report heartbeat information: timeout, context: ngx.timer`
   
   I try to deploy apisix using this chart, I have set “etcd.host" in 
value.yaml.   
   But I got the error log.   Where is the problem? 
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-helm-chart] membphis commented on issue #2: failed to fetch data from etcd

2020-10-09 Thread GitBox


membphis commented on issue #2:
URL: https://github.com/apache/apisix-helm-chart/issues/2#issuecomment-706074242


   it seems that the APISIX instance misses the` apisix init` step



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-helm-chart] ziyou434 commented on issue #2: failed to fetch data from etcd

2020-10-09 Thread GitBox


ziyou434 commented on issue #2:
URL: https://github.com/apache/apisix-helm-chart/issues/2#issuecomment-706075193


   那么是chart的问题还是我的问题呢,我应该如何改进他



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] nic-chen commented on issue #2366: bug: gRPC transcoding plugin how to support import other proto file?

2020-10-09 Thread GitBox


nic-chen commented on issue #2366:
URL: https://github.com/apache/apisix/issues/2366#issuecomment-706084744


   we don't support import proto yet. you can add the dependent content 
directly to the proto



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] spacewander opened a new pull request #2367: change: refactor router

2020-10-09 Thread GitBox


spacewander opened a new pull request #2367:
URL: https://github.com/apache/apisix/pull/2367


   1. rename http/router/radixtree_sni -> ssl/router/radixtree_sni
   2. extract API router out from the host/uri router so that we can hide the
   implementation details and reduce duplicate code.
   
   ### What this PR does / why we need it:
   
   
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features 
have been added?
   * [ ] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible?
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] moonming commented on issue #2157: request help: apisix 1.3 upgrade apisix 1.5,admin api occur 403

2020-10-09 Thread GitBox


moonming commented on issue #2157:
URL: https://github.com/apache/apisix/issues/2157#issuecomment-706091628


   @liuhengloveyou please take a look



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] idbeta opened a new pull request #2368: WIP: add uri fuzzing test

2020-10-09 Thread GitBox


idbeta opened a new pull request #2368:
URL: https://github.com/apache/apisix/pull/2368


   ### What this PR does / why we need it:
   
   
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features 
have been added?
   * [] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible?
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] codjust commented on issue #2151: feature: Best practice for jaeger

2020-10-09 Thread GitBox


codjust commented on issue #2151:
URL: https://github.com/apache/apisix/issues/2151#issuecomment-706106226


   
   > After retry I think use zipkin plugin to send v2 span can work, ref: 
https://www.jaegertracing.io/docs/1.19/getting-started/
   
   good!  it can work with jaeger tracing? 
   eg:  client -> apisix(zipkin plugin) -> go-process(jaeger-client) 
   then go-process can extract tracing id from apisix http request?



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] haifeng9414 opened a new issue #2369: bug: Unable to get the latest upstream node list by service discovery

2020-10-09 Thread GitBox


haifeng9414 opened a new issue #2369:
URL: https://github.com/apache/apisix/issues/2369


   ### Issue description
   I use consul as the registry center and configuration center of apisix and I 
implemented a consul service discovery through consul-template. After an 
application is redeployed, the log shows that the consul service discovery has 
obtained the latest application IP list, but accessing the application through 
apisix returns 502, the log shows that apisix uses the old application IP.
   
   I think it is caused by the cache of server_picker:
   ```
   -- apisix/balancer.lua
   local server_picker = lrucache_server_picker(key, version,
   create_server_picker, up_conf, checker)
   ```
   
   When the upstream checker is not enabled, the value of version is equal to 
`route.modifiedIndex .. "&" .. service.modifiedIndex`, the change of the 
application ip address in the registry center will not cause this value to 
change, this will cause the application to be inaccessible until the 
server_picker cache is invalidated.
   
   I use consul as service discovery instead of eureka, but I believe that 
using eureka will also have this problem. I think the version should be 
obtained when obtaining the service ip address:
   ```
   -- apisix/balancer.lua
   if up_conf.service_name then
   if not discovery then
   return nil, "discovery is uninitialized"
   end
   up_conf.nodes = discovery.nodes(up_conf.service_name)
   end
   ```
   change to:
   ```
   if up_conf.service_name then
   if not discovery then
   return nil, "discovery is uninitialized"
   end
   up_conf.nodes, up_version = discovery.nodes(up_conf.service_name)
   end
   ```
   
   ### Environment
   
   * apisix version (cmd: `apisix version`): lastest 
master(251625d8ab969b0b46d12041beff44f329e95321)
   * OS: mac os/linux
   
   ### Minimal test code / Steps to reproduce the issue
   1. Set `discovery: eureka` and `worker_processes: 1`, config eureka address 
in config.yaml.
   2. Deploy a multi-instance application and registry to eureka.
   3. Confirm that the application can be accessed through apisix.
   4. Redeploy the application and access it through apisix again.
   
   ### What's the actual result? (including assertion message & call stack if 
applicable)
   access application through apisix returns 502
   
   ### What's the expected result?
   no error



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] moonming commented on issue #546: [refactor] license issue of refactored `api`

2020-10-09 Thread GitBox


moonming commented on issue #546:
URL: 
https://github.com/apache/apisix-dashboard/issues/546#issuecomment-706176538


   ok, I will fix it



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] codjust commented on issue #2151: feature: Best practice for jaeger

2020-10-09 Thread GitBox


codjust commented on issue #2151:
URL: https://github.com/apache/apisix/issues/2151#issuecomment-706106226


   
   > After retry I think use zipkin plugin to send v2 span can work, ref: 
https://www.jaegertracing.io/docs/1.19/getting-started/
   
   good!  it can work with jaeger tracing? 
   eg:  client -> apisix(zipkin plugin) -> go-process(jaeger-client) 
   then go-process can extract tracing id from apisix http request?



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] ShiningRush commented on issue #539: bug: [refactor] test case run failed sometimes

2020-10-09 Thread GitBox


ShiningRush commented on issue #539:
URL: 
https://github.com/apache/apisix-dashboard/issues/539#issuecomment-705996014


   The iteration of map is unordered, so occasionally it will fail. I will fix 
this use case later.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2345: feat: Add lables for route/consumer/service/ssl objects

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2345:
URL: https://github.com/apache/apisix/pull/2345#discussion_r502127213



##
File path: apisix/schema_def.lua
##
@@ -555,6 +580,14 @@ _M.ssl = {
 type = "integer",
 minimum = 1588262400,  -- 2020/5/1 0:0:0
 },
+labels = {

Review comment:
   > we could use label to distinguish among dozens of SSLs according to 
their usage.
   
   Agree this. Searching by category will be helpful.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] nic-chen commented on issue #2366: bug: gRPC transcoding plugin how to support import other proto file?

2020-10-09 Thread GitBox


nic-chen commented on issue #2366:
URL: https://github.com/apache/apisix/issues/2366#issuecomment-706084744


   we don't support import proto yet. you can add the dependent content 
directly to the proto



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan closed issue #491: Process flow chart for Route module

2020-10-09 Thread GitBox


juzhiyuan closed issue #491:
URL: https://github.com/apache/apisix-dashboard/issues/491


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on pull request #2364: feat: add new filed `meta_style`, collect the request information with `original` style.

2020-10-09 Thread GitBox


membphis commented on pull request #2364:
URL: https://github.com/apache/apisix/pull/2364#issuecomment-705930508


   will add today



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on pull request #2340: feature: limit-count use redis cluster

2020-10-09 Thread GitBox


membphis commented on pull request #2340:
URL: https://github.com/apache/apisix/pull/2340#issuecomment-705425077


   pls fix the code style first: 
https://github.com/apache/apisix/runs/1224890754#step:6:117
   
   ```
   Checking apisix/plugins/limit-count/limit-count-redis-cluster.lua 6 warnings
   
   apisix/plugins/limit-count/limit-count-redis-cluster.lua:55:1: line 
contains only whitespace
   apisix/plugins/limit-count/limit-count-redis-cluster.lua:58:1: line 
contains only whitespace
   apisix/plugins/limit-count/limit-count-redis-cluster.lua:113:13: setting 
non-standard global variable ok
   apisix/plugins/limit-count/limit-count-redis-cluster.lua:114:20: 
accessing undefined variable ok
   apisix/plugins/limit-count/limit-count-redis-cluster.lua:126:9: setting 
non-standard global variable ok
   apisix/plugins/limit-count/limit-count-redis-cluster.lua:127:16: 
accessing undefined variable ok
   ```



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2340: feature: limit-count use redis cluster

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2340:
URL: https://github.com/apache/apisix/pull/2340#discussion_r501548890



##
File path: apisix/plugins/limit-count.lua
##
@@ -132,7 +132,9 @@ function _M.check_schema(conf)
 end
 
 if conf.policy == "redis-cluster" then
--- TODO
+if not conf.redis_serv_list then
+return false, "missing valid redis option serv_list"

Review comment:
   that is a wrong way, we can use JSONSchema to check this

##
File path: apisix/plugins/limit-count.lua
##
@@ -132,7 +132,9 @@ function _M.check_schema(conf)
 end
 
 if conf.policy == "redis-cluster" then
--- TODO
+if not conf.redis_serv_list then
+return false, "missing valid redis option serv_list"

Review comment:
   we can use a better way, use JSONSchema to check this

##
File path: apisix/plugins/limit-count/limit-count-redis-cluster.lua
##
@@ -0,0 +1,138 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local resty_lock = require("resty.lock")
+local assert = assert
+local setmetatable = setmetatable
+local tostring = tostring
+
+
+local _M = {version = 0.3}
+
+
+local mt = {
+__index = _M
+}
+
+-- https://github.com/steve0511/resty-redis-cluster
+local function new_redis_cluster(conf)
+local config = {
+dict_name = "redis_cluster_slot_locks", --shared dictionary name for 
locks
+name = "apisix-rediscluster",   --rediscluster name
+keepalive_timeout = 6,  --redis connection pool idle 
timeout
+keepalive_cons = 1000,  --redis connection pool size
+connect_timeout = 1000, --timeout while connecting
+max_redirection = 5,--maximum retry attempts for 
redirection
+max_connection_attempts = 1,--maximum retry attempts for 
connection
+read_timeout = conf.redis_timeout or 1000,
+enable_slave_read = true,
+serv_list = {},
+}
+
+for key, value in ipairs(conf.redis_serv_list) do
+if value['redis_host'] and value['redis_port'] then
+config.serv_list[key] = {ip = value['redis_host'], port = 
value['redis_port']}
+end
+end
+
+if conf.redis_password then
+config.auth = conf.redis_password --set password while setting auth
+end
+
+local redis_cluster = require "resty.rediscluster"
+local red_c = redis_cluster:new(config)
+
+return red_c
+end
+
+
+function _M.new(plugin_name, limit, window, conf)
+assert(limit > 0 and window > 0)
+
+_M.red_c = new_redis_cluster(conf)
+
+local self = {limit = limit, window = window, conf = conf,
+  plugin_name = plugin_name}
+return setmetatable(self, mt)
+
+end
+
+
+function _M.incoming(self, key)
+local conf = self.conf
+local red = _M.red_c
+core.log.info("ttl key: ", key, " timeout: ", conf.redis_timeout or 1000)

Review comment:
   use JSONSchema to set the default value

##
File path: apisix/plugins/limit-count/limit-count-redis-cluster.lua
##
@@ -0,0 +1,138 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local resty_lock = require("resty.lock")
+local assert = assert
+local setmetatable = setmetatable
+local tostring = tostring
+
+
+local _M = {version = 0.3}
+
+
+local m

[GitHub] [apisix] spacewander commented on a change in pull request #2357: bugfix: set random seed for each worker process at `init_worker` phase, only `init` phase is not enough.

2020-10-09 Thread GitBox


spacewander commented on a change in pull request #2357:
URL: https://github.com/apache/apisix/pull/2357#discussion_r502190093



##
File path: apisix/init.lua
##
@@ -82,6 +75,14 @@ end
 
 
 function _M.http_init_worker()
+local seed, err = core.utils.get_seed_from_urandom()
+if not seed then
+core.log.warn('failed to get seed from urandom: ', err)
+seed = ngx_now() * 1000 + ngx.worker.pid()
+end
+math.randomseed(seed)
+core.log.info("random test in [1, 1]: ", math.random(1, 100))

Review comment:
   @membphis 
   I think we should add a comment for it.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] ShiningRush edited a comment on issue #537: bug: respond status of api should keep same as `admin api` do

2020-10-09 Thread GitBox


ShiningRush edited a comment on issue #537:
URL: 
https://github.com/apache/apisix-dashboard/issues/537#issuecomment-705932393







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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan commented on issue #537: bug: respond status of api should keep same as `admin api` do

2020-10-09 Thread GitBox


juzhiyuan commented on issue #537:
URL: 
https://github.com/apache/apisix-dashboard/issues/537#issuecomment-705950739


   Please follow the RESTful way, thanks.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen merged pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen merged pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] imjoey commented on a change in pull request #2345: feat: Add lables for route/consumer/service/ssl objects

2020-10-09 Thread GitBox


imjoey commented on a change in pull request #2345:
URL: https://github.com/apache/apisix/pull/2345#discussion_r502123384



##
File path: apisix/schema_def.lua
##
@@ -555,6 +580,14 @@ _M.ssl = {
 type = "integer",
 minimum = 1588262400,  -- 2020/5/1 0:0:0
 },
+labels = {

Review comment:
   @nic-chen  IMHO, we could use label to distinguish among dozens of SSLs 
according to their usage.

##
File path: apisix/schema_def.lua
##
@@ -555,6 +580,14 @@ _M.ssl = {
 type = "integer",
 minimum = 1588262400,  -- 2020/5/1 0:0:0
 },
+labels = {

Review comment:
   @membphis  @liuxiran  any thoughts on this? 😄 

##
File path: apisix/schema_def.lua
##
@@ -555,6 +580,14 @@ _M.ssl = {
 type = "integer",
 minimum = 1588262400,  -- 2020/5/1 0:0:0
 },
+labels = {

Review comment:
   @nic-chen  thanks for response. IMHO, we could use label to distinguish 
among dozens of SSLs according to their usage.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] idbeta closed pull request #2273: test: add integration test

2020-10-09 Thread GitBox


idbeta closed pull request #2273:
URL: https://github.com/apache/apisix/pull/2273


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] liuxiran commented on a change in pull request #2345: feat: Add lables for route/consumer/service/ssl objects

2020-10-09 Thread GitBox


liuxiran commented on a change in pull request #2345:
URL: https://github.com/apache/apisix/pull/2345#discussion_r502122002



##
File path: t/admin/consumers.t
##
@@ -223,3 +223,78 @@ GET /t
 {"error_msg":"missing consumer name"}
 --- no_error_log
 [error]
+
+
+
+=== TEST 7: add consumer with labels
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/consumers',
+ngx.HTTP_PUT,
+[[{
+ "username":"jack",
+ "desc": "new consumer",
+ "labels": {
+ "build":"16",
+ "env":"production",
+ "version":"v2"
+ }
+}]],
+[[{
+"node": {
+"value": {
+"username": "jack",
+"desc": "new consumer",
+"labels": {

Review comment:
   node does not support `labels`, so here may need to remove `labels`?

##
File path: apisix/schema_def.lua
##
@@ -555,6 +580,14 @@ _M.ssl = {
 type = "integer",
 minimum = 1588262400,  -- 2020/5/1 0:0:0
 },
+labels = {

Review comment:
   > we could use label to distinguish among dozens of SSLs according to 
their usage
   
   agree +1





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] idbeta commented on pull request #2273: test: add integration test

2020-10-09 Thread GitBox


idbeta commented on pull request #2273:
URL: https://github.com/apache/apisix/pull/2273#issuecomment-705995882


   There are too many questions about this pr, close it, let me create another 
pr,thank u all.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] gy09535 commented on issue #2151: feature: Best practice for jaeger

2020-10-09 Thread GitBox


gy09535 commented on issue #2151:
URL: https://github.com/apache/apisix/issues/2151#issuecomment-706060672


   After retry I think use zipkin plugin to send v2 span can work, ref: 
https://www.jaegertracing.io/docs/1.19/getting-started/



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] moonming closed issue #2361: perf: use `table.isarray` which is can be JIT compiled

2020-10-09 Thread GitBox


moonming closed issue #2361:
URL: https://github.com/apache/apisix/issues/2361


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis merged pull request #2357: bugfix: set random seed for each worker process at `init_worker` phase, only `init` phase is not enough.

2020-10-09 Thread GitBox


membphis merged pull request #2357:
URL: https://github.com/apache/apisix/pull/2357


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] moonming merged pull request #2364: feat: add new filed `meta_style`, collect the request information with `original` style.

2020-10-09 Thread GitBox


moonming merged pull request #2364:
URL: https://github.com/apache/apisix/pull/2364


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] moonming commented on issue #2157: request help: apisix 1.3 upgrade apisix 1.5,admin api occur 403

2020-10-09 Thread GitBox


moonming commented on issue #2157:
URL: https://github.com/apache/apisix/issues/2157#issuecomment-706091628


   @liuhengloveyou please take a look



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on pull request #2306: 1.fix generation of uuid;

2020-10-09 Thread GitBox


membphis commented on pull request #2306:
URL: https://github.com/apache/apisix/pull/2306#issuecomment-706052308


   resolve this bug by another PR: https://github.com/apache/apisix/pull/2357
   I think we can close this PR. @zlm0125 
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan commented on issue #540: feature: [refactor] support json schema check

2020-10-09 Thread GitBox


juzhiyuan commented on issue #540:
URL: 
https://github.com/apache/apisix-dashboard/issues/540#issuecomment-705994003


   May I ask if this issue would be resolved in 1.6?



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-helm-chart] membphis commented on issue #2: failed to fetch data from etcd

2020-10-09 Thread GitBox


membphis commented on issue #2:
URL: https://github.com/apache/apisix-helm-chart/issues/2#issuecomment-706074242







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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] liuhengloveyou commented on a change in pull request #2339: feature: breaker request by api

2020-10-09 Thread GitBox


liuhengloveyou commented on a change in pull request #2339:
URL: https://github.com/apache/apisix/pull/2339#discussion_r501516429



##
File path: conf/config-default-dev.yaml
##
@@ -0,0 +1,203 @@
+#

Review comment:
   How do I resolve the CI error?

##
File path: conf/config-default-dev.yaml
##
@@ -0,0 +1,203 @@
+#

Review comment:
   How do I resolve the CI error?
   
![image](https://user-images.githubusercontent.com/5400196/95430301-2e2a8580-097e-11eb-8f97-18bb356c12df.png)
   

##
File path: doc/zh-cn/plugins/api-blocker.md
##
@@ -0,0 +1,102 @@
+
+
+- [English](../../plugins/api-blocker.md)
+
+# 目录
+
+- [**定义**](#定义)
+- [**属性列表**](#属性列表)
+- [**启用方式**](#启用方式)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 定义
+
+该插件实现API熔断功能,帮助我们保护上游业务服务。

Review comment:
   OK,update to 5 minutes.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] nic-chen commented on a change in pull request #2364: feat: add new filed `meta_style`, collect the request information with `original` style.

2020-10-09 Thread GitBox


nic-chen commented on a change in pull request #2364:
URL: https://github.com/apache/apisix/pull/2364#discussion_r502171779



##
File path: apisix/plugins/kafka-logger.lua
##
@@ -32,6 +32,11 @@ local buffers = {}
 local schema = {
 type = "object",
 properties = {
+meta_style = {

Review comment:
   yes, `meta_format` is better





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan commented on issue #466: bug: a related to route basic-auth consumer should not be deleted

2020-10-09 Thread GitBox


juzhiyuan commented on issue #466:
URL: 
https://github.com/apache/apisix-dashboard/issues/466#issuecomment-705929758


   so this issue has been resolved? @ShiningRush 



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[apisix-dashboard] branch refactor updated: fix: append sort for list and using sync.Map instead of map

2020-10-09 Thread vinci
This is an automated email from the ASF dual-hosted git repository.

vinci pushed a commit to branch refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/refactor by this push:
 new e7c00d2  fix: append sort for list and using sync.Map instead of map
e7c00d2 is described below

commit e7c00d2f07ef9949b9c943c0040c8bb179ba44ba
Author: ShiningRush <277040...@qq.com>
AuthorDate: Fri Oct 9 21:55:46 2020 +0800

fix: append sort for list and using sync.Map instead of map
---
 api/internal/core/store/store.go  |  64 +++---
 api/internal/core/store/store_test.go | 223 +++---
 2 files changed, 169 insertions(+), 118 deletions(-)

diff --git a/api/internal/core/store/store.go b/api/internal/core/store/store.go
index 263a49f..a82089f 100644
--- a/api/internal/core/store/store.go
+++ b/api/internal/core/store/store.go
@@ -23,6 +23,8 @@ import (
"fmt"
"log"
"reflect"
+   "sort"
+   "sync"
"time"
 
"github.com/shiningrush/droplet/data"
@@ -43,7 +45,7 @@ type Interface interface {
 type GenericStore struct {
Stg storage.Interface
 
-   cache map[string]interface{}
+   cache sync.Map
opt   GenericStoreOption
 
cancel context.CancelFunc
@@ -75,8 +77,7 @@ func NewGenericStore(opt GenericStoreOption) (*GenericStore, 
error) {
return nil, fmt.Errorf("obj type is invalid")
}
s := &GenericStore{
-   opt:   opt,
-   cache: make(map[string]interface{}),
+   opt: opt,
}
s.Stg = &storage.EtcdV3Storage{}
 
@@ -95,7 +96,7 @@ func (s *GenericStore) Init() error {
if err != nil {
return err
}
-   s.cache[s.opt.KeyFunc(objPtr)] = objPtr
+   s.cache.Store(s.opt.KeyFunc(objPtr), objPtr)
}
 
c, cancel := context.WithCancel(context.TODO())
@@ -114,9 +115,9 @@ func (s *GenericStore) Init() error {
log.Println("value convert to 
obj failed", err)
continue
}
-   
s.cache[event.Events[i].Key[len(s.opt.BasePath)+1:]] = objPtr
+   
s.cache.Store(event.Events[i].Key[len(s.opt.BasePath)+1:], objPtr)
case storage.EventTypeDelete:
-   delete(s.cache, 
event.Events[i].Key[len(s.opt.BasePath)+1:])
+   
s.cache.Delete(event.Events[i].Key[len(s.opt.BasePath)+1:])
}
}
}
@@ -126,7 +127,7 @@ func (s *GenericStore) Init() error {
 }
 
 func (s *GenericStore) Get(key string) (interface{}, error) {
-   ret, ok := s.cache[key]
+   ret, ok := s.cache.Load(key)
if !ok {
return nil, data.ErrNotFound
}
@@ -138,6 +139,7 @@ type ListInput struct {
PageSize  int
// start from 1
PageNumber int
+   Less   func(i, j interface{}) bool
 }
 
 type ListOutput struct {
@@ -145,14 +147,27 @@ type ListOutput struct {
TotalSize int   `json:"total_size"`
 }
 
+var defLessFunc = func(i, j interface{}) bool {
+   iBase := i.(entity.BaseInfoGetter).GetBaseInfo()
+   jBase := j.(entity.BaseInfoGetter).GetBaseInfo()
+   if iBase.CreateTime != jBase.CreateTime {
+   return iBase.CreateTime < jBase.CreateTime
+   }
+   if iBase.UpdateTime != jBase.UpdateTime {
+   return iBase.UpdateTime < jBase.UpdateTime
+   }
+   return iBase.ID < jBase.ID
+}
+
 func (s *GenericStore) List(input ListInput) (*ListOutput, error) {
var ret []interface{}
-   for k := range s.cache {
-   if input.Predicate != nil && !input.Predicate(s.cache[k]) {
-   continue
+   s.cache.Range(func(key, value interface{}) bool {
+   if input.Predicate != nil && !input.Predicate(value) {
+   return true
}
-   ret = append(ret, s.cache[k])
-   }
+   ret = append(ret, value)
+   return true
+   })
 
//should return an empty array not a null for client
if ret == nil {
@@ -163,6 +178,14 @@ func (s *GenericStore) List(input ListInput) (*ListOutput, 
error) {
Rows:  ret,
TotalSize: len(ret),
}
+   if input.Less == nil {
+   input.Less = defLessFunc
+   }
+
+   sort.Slice(output.Rows, func(i, j int) bool {
+   return input.Less(output.Rows[i], output.Rows[j])
+   })
+
if input.PageSize > 0 && input.PageNumber > 0 {
skipCount := (input.PageNumber - 1) * input.PageSize

[GitHub] [apisix] membphis commented on issue #2366: bug: gRPC transcoding plugin how to support import other proto file?

2020-10-09 Thread GitBox


membphis commented on issue #2366:
URL: https://github.com/apache/apisix/issues/2366#issuecomment-706053507


   @nic-chen do you know how to resolve this issue?



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2339: feature: breaker request by api

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2339:
URL: https://github.com/apache/apisix/pull/2339#discussion_r501548363



##
File path: conf/config-default-dev.yaml
##
@@ -0,0 +1,203 @@
+#

Review comment:
   I do not think we need `conf/config-default-dev.yaml` for CI.
   
https://github.com/apache/apisix/pull/2339/checks?check_run_id=1223679517#step:6:310
   
   it seems that you only need to fix the test case `t/admin/plugins.t` .
   
   ```
   Test Summary Report
   ---
   t/admin/plugins.t   (Wstat: 256 Tests: 15 Failed: 1)
 Failed test:  2
 Non-zero exit status: 1

##
File path: doc/plugins/api-blocker.md
##
@@ -0,0 +1,102 @@
+
+
+- [中文](../zh-cn/plugins/api-blocker.md)
+
+# Summary
+
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**How To Enable**](#how-to-enable)
+- [**Test Plugin**](#test-plugin)
+- [**Disable Plugin**](#disable-plugin)
+
+## Name
+
+The plugin implements API fuse functionality to help us protect our upstream 
business services.
+
+## Attributes
+
+| Name  | Type  | Requirement | Default | Valid  | 
Description |
+| - | - | --- | --- | -- | 
--- |
+| unhealthy_response_code   | integer | required |  | [200, 
..., 600] | return error code when unhealthy |
+| unhealthy.http_statuses | array[integer] | required | {500}  | [500, 
..., 599] | Status codes when unhealthy |
+| unhealthy.failures  | integer| required | 1  | >=1   
  | Number of consecutive error requests that triggered an unhealthy state |
+| healthy.http_statuses   | array[integer] | required | {200, 206} | [200, 
..., 499] | Status codes when healthy |

Review comment:
   doc is wrong. It is not a "required" field, it should be an "optional" 
field. Please fix other similar issues.
   
   
https://github.com/apache/apisix/pull/2339/files#diff-a3aa73270ae0e95e30630eb2b5d825b1R73

##
File path: doc/zh-cn/plugins/api-blocker.md
##
@@ -0,0 +1,102 @@
+
+
+- [English](../../plugins/api-blocker.md)
+
+# 目录
+
+- [**定义**](#定义)
+- [**属性列表**](#属性列表)
+- [**启用方式**](#启用方式)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 定义
+
+该插件实现API熔断功能,帮助我们保护上游业务服务。

Review comment:
   need one space between Chinese and English.

##
File path: apisix/plugins/api-breaker.lua
##
@@ -0,0 +1,212 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local plugin_name = "api-breaker"
+local ngx = ngx
+local math = math
+local ipairs = ipairs
+local error = error
+local core = require("apisix.core")
+
+local DEFAULT_EXPTIME = 600
+
+local shared_buffer = ngx.shared['plugin-'.. plugin_name]
+if not shared_buffer then
+error("get ngx.shared dict error.")
+end
+
+
+local schema = {
+type = "object",
+properties = {
+unhealthy_response_code = {
+type = "integer",
+minimum = 200,
+maximum = 599,
+},
+unhealthy = {
+type = "object",
+properties = {
+http_statuses = {
+type = "array",
+minItems = 1,
+items = {
+type = "integer",
+minimum = 500,
+maximum = 599,
+},
+uniqueItems = true,
+default = {500}
+},
+failures = {
+type = "integer",
+minimum = 1,
+default = 1,
+}
+}
+},
+healthy = {
+type = "object",
+properties = {
+http_statuses = {
+type = "array",
+minItems = 1,
+items = {
+type = "integer",
+minimum = 200,
+maximum = 499,
+},
+uniqueItems = true,
+default = {200

[GitHub] [apisix] nic-chen commented on a change in pull request #2345: feat: Add lables for route/consumer/service/ssl objects

2020-10-09 Thread GitBox


nic-chen commented on a change in pull request #2345:
URL: https://github.com/apache/apisix/pull/2345#discussion_r502129503



##
File path: apisix/schema_def.lua
##
@@ -555,6 +580,14 @@ _M.ssl = {
 type = "integer",
 minimum = 1588262400,  -- 2020/5/1 0:0:0
 },
+labels = {

Review comment:
   OK, I think it could work with SNI.But for management, labels is helpful 
for it.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


juzhiyuan commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-706039192


   Please link this PR in those issues :D



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] moonming commented on a change in pull request #2339: feature: breaker request by api

2020-10-09 Thread GitBox


moonming commented on a change in pull request #2339:
URL: https://github.com/apache/apisix/pull/2339#discussion_r502186636



##
File path: doc/plugins/api-blocker.md
##
@@ -0,0 +1,102 @@
+
+
+- [中文](../zh-cn/plugins/api-blocker.md)

Review comment:
   `blocker` or `breaker`?





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] moonming merged pull request #2365: optimize: use table.isarray to check whether table is an array.

2020-10-09 Thread GitBox


moonming merged pull request #2365:
URL: https://github.com/apache/apisix/pull/2365


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan commented on issue #542: feature: [refactor] embedding static files into Go binaries

2020-10-09 Thread GitBox


juzhiyuan commented on issue #542:
URL: 
https://github.com/apache/apisix-dashboard/issues/542#issuecomment-705993245


   @bzp2010 is working on this issue, please let @nic-chen know whenever there 
have any blocker issues.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan merged pull request #543: feat: refactor consumer

2020-10-09 Thread GitBox


juzhiyuan merged pull request #543:
URL: https://github.com/apache/apisix-dashboard/pull/543


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen commented on issue #537: bug: respond status of api should keep same as `admin api` do

2020-10-09 Thread GitBox


nic-chen commented on issue #537:
URL: 
https://github.com/apache/apisix-dashboard/issues/537#issuecomment-705945254


   As far as I know, some users have already used `http status` in their 
system, if we do not maintain the original `http status `, they will have to 
modify the code. 
   
   Moreover, the response status code of the admin api complies with `resful` 
specifications. 
   
   The workload of front-end changes need @juzhiyuan  to take a look
   
   
   
   
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] moonming commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


moonming commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-705999345







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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] juzhiyuan commented on issue #539: bug: [refactor] test case run failed sometimes

2020-10-09 Thread GitBox


juzhiyuan commented on issue #539:
URL: 
https://github.com/apache/apisix-dashboard/issues/539#issuecomment-705994464


   not sure what happened, cc @ShiningRush 



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-helm-chart] ziyou434 commented on issue #2: failed to fetch data from etcd

2020-10-09 Thread GitBox


ziyou434 commented on issue #2:
URL: https://github.com/apache/apisix-helm-chart/issues/2#issuecomment-706075193


   那么是chart的问题还是我的问题呢,我应该如何改进他



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] nic-chen commented on pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


nic-chen commented on pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#issuecomment-705931099







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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2364: feat: add new filed `meta_style`, collect the request information with `original` style.

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2364:
URL: https://github.com/apache/apisix/pull/2364#discussion_r502162916



##
File path: apisix/plugins/kafka-logger.lua
##
@@ -32,6 +32,11 @@ local buffers = {}
 local schema = {
 type = "object",
 properties = {
+meta_style = {

Review comment:
   `meta_format` maybe a better name.
   
   any suggestion?





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] moonming commented on issue #546: [refactor] license issue of refactored `api`

2020-10-09 Thread GitBox


moonming commented on issue #546:
URL: 
https://github.com/apache/apisix-dashboard/issues/546#issuecomment-706176538


   ok, I will fix it



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] liuxiran merged pull request #2345: feat: Add lables for route/consumer/service/ssl objects

2020-10-09 Thread GitBox


liuxiran merged pull request #2345:
URL: https://github.com/apache/apisix/pull/2345


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] ShiningRush commented on issue #537: bug: respond status of api should keep same as `admin api` do

2020-10-09 Thread GitBox


ShiningRush commented on issue #537:
URL: 
https://github.com/apache/apisix-dashboard/issues/537#issuecomment-705932393







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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix-dashboard] membphis commented on a change in pull request #535: feat: refactor apis for existing check and other apis

2020-10-09 Thread GitBox


membphis commented on a change in pull request #535:
URL: https://github.com/apache/apisix-dashboard/pull/535#discussion_r502209694



##
File path: api/internal/handler/ssl/ssl.go
##
@@ -54,14 +57,16 @@ func (h *Handler) ApplyRoute(r *gin.Engine) {
wrapper.InputType(reflect.TypeOf(ListInput{}
r.POST("/apisix/admin/ssl", wgin.Wraps(h.Create,
wrapper.InputType(reflect.TypeOf(entity.SSL{}
-   r.POST("/apisix/admin/check_ssl_cert", wgin.Wraps(h.Validate,
-   wrapper.InputType(reflect.TypeOf(entity.SSL{}
r.PUT("/apisix/admin/ssl/:id", wgin.Wraps(h.Update,
wrapper.InputType(reflect.TypeOf(UpdateInput{}
r.PATCH("/apisix/admin/ssl/:id", wgin.Wraps(h.Patch,
wrapper.InputType(reflect.TypeOf(UpdateInput{}
-   r.DELETE("/apisix/admin/ssl", wgin.Wraps(h.BatchDelete,
+   r.DELETE("/apisix/admin/ssl/:ids", wgin.Wraps(h.BatchDelete,

Review comment:
   why we use `ids` here? I think it should be `id`, the singular should be 
used here.

##
File path: api/internal/core/entity/query.go
##
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

Review comment:
   ping @nic-chen 

##
File path: api/internal/core/store/query.go
##
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Copyright 2017 The Kubernetes Authors.

Review comment:
   ping @moonming 





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] tokers commented on issue #2361: perf: use `table.isarray` which is can be JIT compiled

2020-10-09 Thread GitBox


tokers commented on issue #2361:
URL: https://github.com/apache/apisix/issues/2361#issuecomment-705933840


   I have committed a PR to optimize it: 
https://github.com/apache/apisix/pull/2365 :).



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on pull request #2367: change: refactor router

2020-10-09 Thread GitBox


membphis commented on pull request #2367:
URL: https://github.com/apache/apisix/pull/2367#issuecomment-706179659


   nice PR ^_^



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] liuhengloveyou commented on a change in pull request #2340: feature: limit-count use redis cluster

2020-10-09 Thread GitBox


liuhengloveyou commented on a change in pull request #2340:
URL: https://github.com/apache/apisix/pull/2340#discussion_r502481627



##
File path: doc/plugins/limit-count.md
##
@@ -109,6 +110,41 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 
'X-API-KEY: edd1c9f034335
 }'
 ```
 
+If using redis-cluster:
+
+```shell
+curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"uri": "/index.html",
+"plugins": {
+"limit-count": {
+"count": 2,
+"time_window": 60,
+"rejected_code": 503,
+"key": "remote_addr",
+"policy": "redis-cluster",
+"redis_serv_list": [
+   {

Review comment:
   In the old version of the configuration, redis_host and redis_port were 
used.
   





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2339: feature: breaker request by api

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2339:
URL: https://github.com/apache/apisix/pull/2339#discussion_r502259561



##
File path: apisix/plugins/api-breaker.lua
##
@@ -0,0 +1,214 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local plugin_name = "api-breaker"
+local ngx = ngx
+local math = math
+local ipairs = ipairs
+local error = error
+local core = require("apisix.core")
+
+local DEFAULT_EXPTIME = 300
+
+local shared_buffer = ngx.shared['plugin-'.. plugin_name]
+if not shared_buffer then
+error("failed to get ngx.shared dict when load plugin " .. plugin_name)
+end
+
+
+local schema = {
+type = "object",
+properties = {
+unhealthy_response_code = {
+type = "integer",
+minimum = 200,
+maximum = 599,
+},
+unhealthy = {
+type = "object",
+properties = {
+http_statuses = {
+type = "array",
+minItems = 1,
+items = {
+type = "integer",
+minimum = 500,
+maximum = 599,
+},
+uniqueItems = true,
+default = {500}
+},
+failures = {
+type = "integer",
+minimum = 1,
+default = 1,
+}
+}
+},
+healthy = {
+type = "object",
+properties = {
+http_statuses = {
+type = "array",
+minItems = 1,
+items = {
+type = "integer",
+minimum = 200,
+maximum = 499,
+},
+uniqueItems = true,
+default = {200, 206}
+},
+successes = {
+type = "integer",
+minimum = 1,
+default = 1,
+}
+}
+}
+},
+required = {"unhealthy_response_code", "unhealthy", "healthy"},
+}
+
+
+local function is_unhealthy(unhealthy_status, upstream_statu)
+for _, unhealthy in ipairs(unhealthy_status) do
+if unhealthy == upstream_statu then
+return true
+end
+end
+
+return false
+end
+
+
+local function is_healthy(healthy_status, upstream_statu)
+for _, healthy in ipairs(healthy_status) do
+if healthy == upstream_statu then
+return true
+end
+end
+
+return false
+end
+
+
+local function healthy_cache_key(ctx)
+return "healthy-" .. core.request.get_host(ctx) .. ctx.var.uri
+end
+
+
+local function unhealthy_cache_key(ctx)
+return "unhealthy-" .. core.request.get_host(ctx) .. ctx.var.uri
+end
+
+
+local function unhealthy_lastime_cache_key(ctx)
+return "unhealthy-lastime" .. core.request.get_host(ctx) .. ctx.var.uri
+end
+
+
+local _M = {
+version = 0.1,
+name = plugin_name,
+priority = 1005,
+schema = schema,
+}
+
+
+function _M.check_schema(conf)
+local ok, err = core.schema.check(schema, conf)
+if not ok then
+return false, err
+end
+
+return true
+end
+
+
+function _M.access(conf, ctx)
+local unhealthy_val, err = shared_buffer:get(unhealthy_cache_key(ctx))
+if err then
+core.log.error("failed to get unhealthy_cache_key in ngx.shared:", err)
+end
+
+local unhealthy_lastime, err = 
shared_buffer:get(unhealthy_lastime_cache_key(ctx))
+if err then
+core.log.error("failed to get unhealthy_lastime_cache_key in 
ngx.shared: ", err)
+end
+
+if unhealthy_val and unhealthy_lastime then
+local ride = math.ceil(unhealthy_val / conf.unhealthy.failures)
+if ride < 1 then
+ride = 1
+end
+
+-- The maximum intercept request is 5 minutes(DEFAULT_EXPTIME),
+-- and then the upstream service will be retry.
+if unhealthy_lastime + 2^ride >= ngx.time() then
+return conf.unhealthy_response_code
+end
+end
+end
+
+
+function _M.header_filter(conf, ctx)

Review 

[GitHub] [apisix] MrLightSpeed0 commented on issue #2280: Route traffic through company proxy / firewall

2020-10-09 Thread GitBox


MrLightSpeed0 commented on issue #2280:
URL: https://github.com/apache/apisix/issues/2280#issuecomment-706275290


   @spacewander and @liuhengloveyou
   exactly, first to answer your question, the forward proxy (if this term 
means different to you. I am sorry for the confusion) is a plain http proxy. 
Then second, I do have this set up as a global policy in my development 
environment as below:
   http_proxy = http://myCompany:port
   https_proxy = http://myCompany:port
   no_proxy = 127.0.0.1, localhost, etc...
   the use case is pretty simple, I am trying to make the example you have in 
your document work (also mentioned in posts above). and since i am trying this 
on a company machine. it needs to go thru the above mentioned proxy (it is the 
only way out for all our egress traffic. i believe all companies have this 
implemented. so it is very common set up). Please advise.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] tzssangglass commented on issue #1195: feature: support multiple ports like stream listen in http and https listen port.

2020-10-09 Thread GitBox


tzssangglass commented on issue #1195:
URL: https://github.com/apache/apisix/issues/1195#issuecomment-706298454


   I want to solve this issues. This is my first time to participate in apisix.
   Can I choose @membphis  as a mentor.
   The deadline I gave is October 18.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2339: feature: breaker request by api

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2339:
URL: https://github.com/apache/apisix/pull/2339#discussion_r502718278



##
File path: doc/plugins/api-breaker.md
##
@@ -0,0 +1,102 @@
+
+
+- [中文](../zh-cn/plugins/api-blocker.md)
+
+# Summary
+
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**How To Enable**](#how-to-enable)
+- [**Test Plugin**](#test-plugin)
+- [**Disable Plugin**](#disable-plugin)
+
+## Name
+
+The plugin implements API fuse functionality to help us protect our upstream 
business services.
+
+## Attributes
+
+| Name  | Type  | Requirement | Default | Valid  | 
Description |
+| - | - | --- | --- | -- | 
--- |
+| unhealthy_response_code   | integer | required |  | [200, 
..., 600] | return error code when unhealthy |
+| unhealthy.http_statuses | array[integer] | optional | {500}  | [500, 
..., 599] | Status codes when unhealthy |
+| unhealthy.failures  | integer| optional | 1  | >=1   
  | Number of consecutive error requests that triggered an unhealthy state |
+| healthy.http_statuses   | array[integer] | optional | {200, 206} | [200, 
..., 499] | Status codes when healthy |
+| successes.successes | integer| optional | 1  | >=1   
  | Number of consecutive normal requests that trigger health status |
+
+## How To Enable
+
+Here's an example, enable the `api-breaker` plugin on the specified route:
+
+```shell
+curl "http://127.0.0.1:9080/apisix/admin/routes/5"; -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+   {
+  "plugins": {
+  "api-breaker": {
+  "unhealthy_response_code": 502,
+  "unhealthy": {
+  "http_statuses": [500, 503],
+  "failures": 3
+  },
+  "healthy": {
+  "http_statuses": [200],
+  "successes": 1
+  }
+  }
+  },
+ "uri": "/get",

Review comment:
   bad indentation

##
File path: doc/plugins/api-breaker.md
##
@@ -0,0 +1,102 @@
+
+
+- [中文](../zh-cn/plugins/api-blocker.md)
+
+# Summary
+
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**How To Enable**](#how-to-enable)
+- [**Test Plugin**](#test-plugin)
+- [**Disable Plugin**](#disable-plugin)
+
+## Name
+
+The plugin implements API fuse functionality to help us protect our upstream 
business services.
+
+## Attributes
+
+| Name  | Type  | Requirement | Default | Valid  | 
Description |
+| - | - | --- | --- | -- | 
--- |
+| unhealthy_response_code   | integer | required |  | [200, 
..., 600] | return error code when unhealthy |
+| unhealthy.http_statuses | array[integer] | optional | {500}  | [500, 
..., 599] | Status codes when unhealthy |
+| unhealthy.failures  | integer| optional | 1  | >=1   
  | Number of consecutive error requests that triggered an unhealthy state |
+| healthy.http_statuses   | array[integer] | optional | {200, 206} | [200, 
..., 499] | Status codes when healthy |
+| successes.successes | integer| optional | 1  | >=1   
  | Number of consecutive normal requests that trigger health status |
+
+## How To Enable
+
+Here's an example, enable the `api-breaker` plugin on the specified route:
+
+```shell
+curl "http://127.0.0.1:9080/apisix/admin/routes/5"; -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+   {
+  "plugins": {
+  "api-breaker": {
+  "unhealthy_response_code": 502,
+  "unhealthy": {
+  "http_statuses": [500, 503],
+  "failures": 3
+  },
+  "healthy": {
+  "http_statuses": [200],
+  "successes": 1
+  }
+  }
+  },
+ "uri": "/get",
+  "host": "127.0.0.1",
+  "upstream_id": 50
+  }'
+```
+
+## Test Plugin
+
+```shell

Review comment:
   we should provide two examples, a healthy response and an unhealthy 
response.

##
File path: apisix/plugins/api-breaker.lua
##
@@ -0,0 +1,214 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/

[GitHub] [apisix] membphis commented on pull request #2339: feature: breaker request by api

2020-10-09 Thread GitBox


membphis commented on pull request #2339:
URL: https://github.com/apache/apisix/pull/2339#issuecomment-706452466


   @liuhengloveyou 
   
   
![image](https://user-images.githubusercontent.com/6814606/95640793-17487800-0ad1-11eb-9872-d350f63ab1c3.png)
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on issue #1195: feature: support multiple ports like stream listen in http and https listen port.

2020-10-09 Thread GitBox


membphis commented on issue #1195:
URL: https://github.com/apache/apisix/issues/1195#issuecomment-706452917


   @tzssangglass no problem. I have assigned this issue to you. If you have any 
questions, please feel free to talk to me.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis commented on a change in pull request #2340: feature: limit-count use redis cluster

2020-10-09 Thread GitBox


membphis commented on a change in pull request #2340:
URL: https://github.com/apache/apisix/pull/2340#discussion_r502721349



##
File path: apisix/plugins/limit-count/limit-count-redis-cluster.lua
##
@@ -0,0 +1,139 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local resty_lock = require("resty.lock")
+local assert = assert
+local setmetatable = setmetatable
+local tostring = tostring
+local require = require
+local ipairs  = ipairs
+
+
+local _M = {version = 0.3}
+
+
+local mt = {
+__index = _M
+}
+
+-- https://github.com/steve0511/resty-redis-cluster
+local function new_redis_cluster(conf)
+local config = {
+dict_name = "redis_cluster_slot_locks", --shared dictionary name for 
locks
+name = "apisix-rediscluster",   --rediscluster name
+keepalive_timeout = 6,  --redis connection pool idle 
timeout

Review comment:
   ping  @liuhengloveyou 





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] liuhengloveyou commented on a change in pull request #2340: feature: limit-count use redis cluster

2020-10-09 Thread GitBox


liuhengloveyou commented on a change in pull request #2340:
URL: https://github.com/apache/apisix/pull/2340#discussion_r502726826



##
File path: rockspec/apisix-master-0.rockspec
##
@@ -54,6 +54,7 @@ dependencies = {
 "skywalking-nginx-lua-plugin = 1.0-0",
 "base64 = 1.5-2",
 "dkjson = 2.5-2",
+"lua-resty-redis-cluster = 1.1-0",

Review comment:
   updated

##
File path: apisix/plugins/limit-count.lua
##
@@ -132,7 +132,9 @@ function _M.check_schema(conf)
 end
 
 if conf.policy == "redis-cluster" then
--- TODO
+if not conf.redis_serv_list then
+return false, "missing valid redis option serv_list"

Review comment:
   updated





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] liuhengloveyou commented on a change in pull request #2340: feature: limit-count use redis cluster

2020-10-09 Thread GitBox


liuhengloveyou commented on a change in pull request #2340:
URL: https://github.com/apache/apisix/pull/2340#discussion_r502726892



##
File path: apisix/plugins/limit-count/limit-count-redis-cluster.lua
##
@@ -0,0 +1,139 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local resty_lock = require("resty.lock")
+local assert = assert
+local setmetatable = setmetatable
+local tostring = tostring
+local require = require
+local ipairs  = ipairs
+
+
+local _M = {version = 0.3}
+
+
+local mt = {
+__index = _M
+}
+
+-- https://github.com/steve0511/resty-redis-cluster
+local function new_redis_cluster(conf)
+local config = {
+dict_name = "redis_cluster_slot_locks", --shared dictionary name for 
locks
+name = "apisix-rediscluster",   --rediscluster name
+keepalive_timeout = 6,  --redis connection pool idle 
timeout
+keepalive_cons = 1000,  --redis connection pool size
+connect_timeout = 1000, --timeout while connecting
+max_redirection = 5,--maximum retry attempts for 
redirection
+max_connection_attempts = 1,--maximum retry attempts for 
connection
+read_timeout = conf.redis_timeout or 1000,
+enable_slave_read = true,
+serv_list = {},
+}
+
+for key, value in ipairs(conf.redis_serv_list) do
+if value['redis_host'] and value['redis_port'] then
+config.serv_list[key] = {ip = value['redis_host'], port = 
value['redis_port']}
+end
+end
+
+if conf.redis_password then
+config.auth = conf.redis_password --set password while setting auth
+end
+
+local redis_cluster = require "resty.rediscluster"
+local red_c = redis_cluster:new(config)

Review comment:
   fixed





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] tzssangglass commented on issue #1195: feature: support multiple ports like stream listen in http and https listen port.

2020-10-09 Thread GitBox


tzssangglass commented on issue #1195:
URL: https://github.com/apache/apisix/issues/1195#issuecomment-706462218


   > @tzssangglass no problem. I have assigned this issue to you. If you have 
any questions, please feel free to talk to me.
   
   ok



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [apisix] membphis opened a new issue #2370: chore: remove folder `logs` in root

2020-10-09 Thread GitBox


membphis opened a new issue #2370:
URL: https://github.com/apache/apisix/issues/2370


   We can delete the "logs" folder from the "root" directory.
   
   https://github.com/apache/apisix/tree/master/logs
   
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[apisix] branch membphis-patch-1 created (now 251625d)

2020-10-09 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch membphis-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


  at 251625d  bugfix: set random seed for each worker process at 
`init_worker` phase, only `init` phase is not enough. (#2357)

No new revisions were added by this update.



[GitHub] [apisix] membphis opened a new pull request #2371: chore: upload apisix logo image

2020-10-09 Thread GitBox


membphis opened a new pull request #2371:
URL: https://github.com/apache/apisix/pull/2371


   ### What this PR does / why we need it:
   
   
   as title.
   
   ### Pre-submission checklist:
   
   * [ ] Did you explain what problem does this PR solve? Or what new features 
have been added?
   * [ ] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible?
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




  1   2   >