-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
278 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* Tencent is pleased to support the open source community by making Polaris available. | ||
* | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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. | ||
*/ | ||
|
||
package httpserver | ||
|
||
import ( | ||
"github.com/emicklei/go-restful/v3" | ||
restfulspec "github.com/polarismesh/go-restful-openapi/v2" | ||
|
||
api "github.com/polarismesh/polaris/common/api/v1" | ||
"github.com/polarismesh/polaris/maintain" | ||
) | ||
|
||
var ( | ||
maintainApiTags = []string{"Maintain"} | ||
) | ||
|
||
func enrichGetServerConnectionsApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("获取服务端连接数"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Param(restful.QueryParameter("protocol", "查看指定协议").DataType("string").Required(true)). | ||
Param(restful.QueryParameter("host", "查看指定host").DataType("string").Required(false)). | ||
Notes(enrichGetServerConnectionsApiNotes) | ||
} | ||
|
||
func enrichGetServerConnStatsApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("获取服务端连接统计信息"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Param(restful.QueryParameter("protocol", "查看指定协议").DataType("string").Required(true)). | ||
Param(restful.QueryParameter("host", "查看指定host").DataType("string").Required(false)). | ||
Param(restful.QueryParameter("amount", "总数").DataType("integer").Required(false)). | ||
Notes(enrichGetServerConnStatsApiNotes) | ||
} | ||
|
||
func enrichCloseConnectionsApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("关闭指定client ip的连接"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Reads([]maintain.ConnReq{}). | ||
Notes(enrichCloseConnectionsApiNotes) | ||
} | ||
|
||
func enrichFreeOSMemoryApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("释放系统内存"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Notes(enrichFreeOSMemoryApiNotes) | ||
} | ||
|
||
func enrichCleanInstanceApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("彻底清理flag=1的实例"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Reads(api.Instance{}). | ||
Notes(enrichCleanInstanceApiNotes) | ||
} | ||
|
||
func enrichGetLastHeartbeatApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("获取上一次心跳的时间"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Param(restful.QueryParameter("id", "实例ID 如果存在则其它参数可不填").DataType("string").Required(false)). | ||
Param(restful.QueryParameter("service", "服务名").DataType("string").Required(false)). | ||
Param(restful.QueryParameter("namespace", "命名空间").DataType("string").Required(false)). | ||
Param(restful.QueryParameter("host", "主机名").DataType("string").Required(false)). | ||
Param(restful.QueryParameter("port", "端口").DataType("integer").Required(false)). | ||
Param(restful.QueryParameter("vpv_id", "VPC ID").DataType("string").Required(false)). | ||
Notes(enrichGetLastHeartbeatApiNotes) | ||
} | ||
|
||
func enrichGetLogOutputLevelApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("获取日志输出级别"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Notes(enrichGetLogOutputLevelApiNotes) | ||
} | ||
|
||
func enrichSetLogOutputLevelApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { | ||
return r. | ||
Doc("设置日志输出级别"). | ||
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags). | ||
Notes(enrichSetLogOutputLevelApiNotes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/** | ||
* Tencent is pleased to support the open source community by making Polaris available. | ||
* | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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. | ||
*/ | ||
|
||
package httpserver | ||
|
||
const ( | ||
enrichGetServerConnectionsApiNotes = ` | ||
请求示例: | ||
~~~ | ||
GET /maintain/v1/apiserver/conn?protocol=xxx&host=xxx | ||
Header X-Polaris-Token: {访问凭据} | ||
~~~ | ||
| 参数名 | 类型 | 描述 | 是否必填 | | ||
|----------|--------|---------------------|----------| | ||
| protocol | string | 查看指定协议 server | 是 | | ||
| host | string | 查看指定host | 否 | | ||
应答示例: | ||
~~~json | ||
~~~ | ||
` | ||
enrichGetServerConnStatsApiNotes = ` | ||
请求示例: | ||
~~~ | ||
GET /maintain/v1/apiserver/conn/stats?protocol=xxx&host=xxx | ||
Header X-Polaris-Token: {访问凭据} | ||
~~~ | ||
| 参数名 | 类型 | 描述 | 是否必填 | | ||
|---------- |-------- |--------------------- |---------- | | ||
| protocol | string | 查看指定协议 server | 是 | | ||
| host | string | 查看指定host | 否 | | ||
| amount | integer | 总量 | 否 | | ||
` | ||
enrichCloseConnectionsApiNotes = ` | ||
请求示例: | ||
~~~ | ||
POST /maintain/v1/apiserver/conn?protocol=xxx&host=xxx | ||
Header X-Polaris-Token: {访问凭据} | ||
Header Content-Type: application/json | ||
[ | ||
{ | ||
"protocol": "someProtocol", | ||
"host": "someHost", | ||
"amount": "someAmount", | ||
"port": "port", | ||
} | ||
] | ||
~~~ | ||
` | ||
enrichFreeOSMemoryApiNotes = ` | ||
请求示例: | ||
~~~ | ||
POST /maintain/v1/memory/free | ||
Header X-Polaris-Token: {访问凭据} | ||
Header Content-Type: application/json | ||
~~~ | ||
` | ||
enrichCleanInstanceApiNotes = ` | ||
请求示例: | ||
~~~ | ||
POST /maintain/v1/instance/clean | ||
Header X-Polaris-Token: {访问凭据} | ||
Header Content-Type: application/json | ||
{ | ||
"service": "tdsql-ops-server", | ||
"namespace": "default", | ||
"host": "127.0.0.1", | ||
"port": 8080, | ||
"location": { | ||
"region": "ap-guangzhou", | ||
"zone": "ap-guangzhou-3", | ||
"campus": "" | ||
}, | ||
"enable_health_check": true, | ||
"health_check": { | ||
"type": 1, | ||
"heartbeat": { | ||
"ttl": 10 | ||
} | ||
}, | ||
"metadata": { | ||
"env": "pre" | ||
} | ||
} | ||
~~~ | ||
` | ||
enrichGetLastHeartbeatApiNotes = ` | ||
请求示例: | ||
~~~ | ||
GET /maintain/v1//instance/heartbeat?id=xxx | ||
Header X-Polaris-Token: {访问凭据} | ||
~~~ | ||
请求参数: | ||
| 参数名 | 类型 | 描述 | 是否必填 | | ||
| ------------------- | ------------------ | ----------------------------------------------------------------- | -------- | | ||
| id | string | 实例id 如果存在id,后面参数可以不填名 | 否 | | ||
| service | string | 服务名 | 否 | | ||
| namespace | string | 命名空间 | 否 | | ||
| host | string | 实例的IP | 否 | | ||
| port | string | 实例的端口 | 否 | | ||
| vpc_id | string | VPC ID | 否 | | ||
` | ||
enrichGetLogOutputLevelApiNotes = ` | ||
请求示例: | ||
~~~ | ||
GET /maintain/v1/log/outputlevel | ||
Header X-Polaris-Token: {访问凭据} | ||
~~~ | ||
返回示例: | ||
~~~ | ||
{ | ||
"apiserver": "info", | ||
"auth": "info", | ||
"cache": "info", | ||
"config": "info", | ||
"default": "info", | ||
"healthcheck": "info", | ||
"naming": "info", | ||
"store": "info", | ||
"xdsv3": "info" | ||
} | ||
~~~ | ||
` | ||
enrichSetLogOutputLevelApiNotes = ` | ||
请求示例: | ||
~~~ | ||
POST /maintain/v1/log/outputlevel | ||
Header X-Polaris-Token: {访问凭据} | ||
{ | ||
"scope": "apiserver", | ||
"level": "info" | ||
} | ||
` | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters