Skip to content

Commit 7294bf6

Browse files
authored
refactor: maintain rename to admin (polarismesh#1063)
1 parent a60a708 commit 7294bf6

29 files changed

+80
-80
lines changed

maintain/api.go admin/api.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

2020
import (
2121
"context"
@@ -47,8 +47,8 @@ type ConnStatsResp struct {
4747
Stats []*connlimit.HostConnStat
4848
}
4949

50-
// MaintainOperateServer Maintain related operation
51-
type MaintainOperateServer interface {
50+
// AdminOperateServer Maintain related operation
51+
type AdminOperateServer interface {
5252
// GetServerConnections Get connection count
5353
GetServerConnections(ctx context.Context, req *ConnReq) (*ConnCountResp, error)
5454
// GetServerConnStats 获取连接缓存里面的统计信息

maintain/config.go admin/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

20-
import "github.com/polarismesh/polaris/maintain/job"
20+
import "github.com/polarismesh/polaris/admin/job"
2121

2222
// Config maintain configuration
2323
type Config struct {

maintain/default.go admin/default.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

2020
import (
2121
"context"
2222
"errors"
2323

24+
"github.com/polarismesh/polaris/admin/job"
2425
"github.com/polarismesh/polaris/auth"
2526
"github.com/polarismesh/polaris/cache"
26-
"github.com/polarismesh/polaris/maintain/job"
2727
"github.com/polarismesh/polaris/service"
2828
"github.com/polarismesh/polaris/service/healthcheck"
2929
"github.com/polarismesh/polaris/store"
3030
)
3131

3232
var (
33-
server MaintainOperateServer
33+
server AdminOperateServer
3434
maintainServer = &Server{}
3535
finishInit bool
3636
)
@@ -75,9 +75,9 @@ func initialize(_ context.Context, cfg *Config, namingService service.DiscoverSe
7575
}
7676

7777
// GetServer 获取已经初始化好的Server
78-
func GetServer() (MaintainOperateServer, error) {
78+
func GetServer() (AdminOperateServer, error) {
7979
if !finishInit {
80-
return nil, errors.New("MaintainOperateServer has not done Initialize")
80+
return nil, errors.New("AdminOperateServer has not done Initialize")
8181
}
8282

8383
return server, nil
@@ -86,7 +86,7 @@ func GetServer() (MaintainOperateServer, error) {
8686
// GetOriginServer 获取已经初始化好的Server
8787
func GetOriginServer() (*Server, error) {
8888
if !finishInit {
89-
return nil, errors.New("MaintainOperateServer has not done Initialize")
89+
return nil, errors.New("AdminOperateServer has not done Initialize")
9090
}
9191

9292
return maintainServer, nil
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

maintain/log.go admin/log.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

2020
import (
2121
commonlog "github.com/polarismesh/polaris/common/log"

maintain/maintain.go admin/maintain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

2020
import (
2121
"context"

maintain/maintain_authability.go admin/maintain_authability.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

2020
import (
2121
"context"
@@ -27,7 +27,7 @@ import (
2727
"github.com/polarismesh/polaris/common/utils"
2828
)
2929

30-
var _ MaintainOperateServer = (*serverAuthAbility)(nil)
30+
var _ AdminOperateServer = (*serverAuthAbility)(nil)
3131

3232
func (svr *serverAuthAbility) GetServerConnections(ctx context.Context, req *ConnReq) (*ConnCountResp, error) {
3333
authCtx := svr.collectMaintainAuthContext(ctx, model.Read, "GetServerConnections")

maintain/server.go admin/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

2020
import (
2121
"sync"
@@ -26,7 +26,7 @@ import (
2626
"github.com/polarismesh/polaris/store"
2727
)
2828

29-
var _ MaintainOperateServer = (*Server)(nil)
29+
var _ AdminOperateServer = (*Server)(nil)
3030

3131
type Server struct {
3232
mu sync.Mutex

maintain/server_authability.go admin/server_authability.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* specific language governing permissions and limitations under the License.
1616
*/
1717

18-
package maintain
18+
package admin
1919

2020
import (
2121
"context"
@@ -34,7 +34,7 @@ type serverAuthAbility struct {
3434
authMgn auth.AuthChecker
3535
}
3636

37-
func newServerAuthAbility(targetServer *Server, authSvr auth.AuthServer) MaintainOperateServer {
37+
func newServerAuthAbility(targetServer *Server, authSvr auth.AuthServer) AdminOperateServer {
3838
proxy := &serverAuthAbility{
3939
targetServer: targetServer,
4040
authSvr: authSvr,

apiserver/httpserver/admin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"github.com/emicklei/go-restful/v3"
2222
)
2323

24-
// GetAdminServer get admin server
25-
func (h *HTTPServer) GetAdminServer() *restful.WebService {
24+
// GetIndexServer get index server
25+
func (h *HTTPServer) GetIndexServer() *restful.WebService {
2626
ws := new(restful.WebService)
2727

2828
ws.Route(ws.GET("/").To(h.index))

apiserver/httpserver/maintain_access.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ import (
2727
apimodel "github.com/polarismesh/specification/source/go/api/v1/model"
2828
apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage"
2929

30+
"github.com/polarismesh/polaris/admin"
3031
httpcommon "github.com/polarismesh/polaris/apiserver/httpserver/http"
3132
api "github.com/polarismesh/polaris/common/api/v1"
3233
"github.com/polarismesh/polaris/common/model"
3334
"github.com/polarismesh/polaris/common/utils"
34-
"github.com/polarismesh/polaris/maintain"
3535
)
3636

3737
// GetMaintainAccessServer 运维接口
38-
func (h *HTTPServer) GetMaintainAccessServer() *restful.WebService {
38+
func (h *HTTPServer) GetAdminAccessServer() *restful.WebService {
3939
ws := new(restful.WebService)
4040
ws.Path("/maintain/v1").Consumes(restful.MIME_JSON).Produces(restful.MIME_JSON)
4141

@@ -62,7 +62,7 @@ func (h *HTTPServer) GetMaintainAccessServer() *restful.WebService {
6262
func (h *HTTPServer) GetServerConnections(req *restful.Request, rsp *restful.Response) {
6363
ctx := initContext(req)
6464
params := httpcommon.ParseQueryParams(req)
65-
connReq := maintain.ConnReq{
65+
connReq := admin.ConnReq{
6666
Protocol: params["protocol"],
6767
Host: params["host"],
6868
}
@@ -87,7 +87,7 @@ func (h *HTTPServer) GetServerConnStats(req *restful.Request, rsp *restful.Respo
8787
}
8888
}
8989

90-
connReq := maintain.ConnReq{
90+
connReq := admin.ConnReq{
9191
Protocol: params["protocol"],
9292
Host: params["host"],
9393
Amount: amount,
@@ -105,7 +105,7 @@ func (h *HTTPServer) GetServerConnStats(req *restful.Request, rsp *restful.Respo
105105
func (h *HTTPServer) CloseConnections(req *restful.Request, rsp *restful.Response) {
106106
log.Info("[MAINTAIN] Start doing close connections")
107107
ctx := initContext(req)
108-
var connReqs []maintain.ConnReq
108+
var connReqs []admin.ConnReq
109109
decoder := json.NewDecoder(req.Request.Body)
110110
if err := decoder.Decode(&connReqs); err != nil {
111111
log.Errorf("[MAINTAIN] close connection decode body err: %s", err.Error())

apiserver/httpserver/maintain_apidoc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
restfulspec "github.com/polarismesh/go-restful-openapi/v2"
2323
apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage"
2424

25-
"github.com/polarismesh/polaris/maintain"
25+
"github.com/polarismesh/polaris/admin"
2626
)
2727

2828
var (
@@ -52,7 +52,7 @@ func enrichCloseConnectionsApiDocs(r *restful.RouteBuilder) *restful.RouteBuilde
5252
return r.
5353
Doc("关闭指定client ip的连接").
5454
Metadata(restfulspec.KeyOpenAPITags, maintainApiTags).
55-
Reads([]maintain.ConnReq{}).
55+
Reads([]admin.ConnReq{}).
5656
Notes(enrichCloseConnectionsApiNotes)
5757
}
5858

apiserver/httpserver/server.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/pkg/errors"
3131
"go.uber.org/zap"
3232

33+
"github.com/polarismesh/polaris/admin"
3334
"github.com/polarismesh/polaris/apiserver"
3435
httpcommon "github.com/polarismesh/polaris/apiserver/httpserver/http"
3536
v1 "github.com/polarismesh/polaris/apiserver/httpserver/v1"
@@ -42,7 +43,6 @@ import (
4243
"github.com/polarismesh/polaris/common/secure"
4344
"github.com/polarismesh/polaris/common/utils"
4445
"github.com/polarismesh/polaris/config"
45-
"github.com/polarismesh/polaris/maintain"
4646
"github.com/polarismesh/polaris/namespace"
4747
"github.com/polarismesh/polaris/plugin"
4848
"github.com/polarismesh/polaris/service"
@@ -65,7 +65,7 @@ type HTTPServer struct {
6565
enableSwagger bool
6666

6767
server *http.Server
68-
maintainServer maintain.MaintainOperateServer
68+
maintainServer admin.AdminOperateServer
6969
namespaceServer namespace.NamespaceOperateServer
7070
namingServer service.DiscoverServer
7171
configServer config.ConfigCenterServer
@@ -151,7 +151,7 @@ func (h *HTTPServer) Run(errCh chan error) {
151151

152152
var err error
153153

154-
h.maintainServer, err = maintain.GetServer()
154+
h.maintainServer, err = admin.GetServer()
155155
if err != nil {
156156
log.Errorf("%v", err)
157157
errCh <- err
@@ -327,8 +327,8 @@ func (h *HTTPServer) createRestfulContainer() (*restful.Container, error) {
327327
switch name {
328328
case "admin":
329329
if apiConfig.Enable {
330-
wsContainer.Add(h.GetAdminServer())
331-
wsContainer.Add(h.GetMaintainAccessServer())
330+
wsContainer.Add(h.GetIndexServer())
331+
wsContainer.Add(h.GetAdminAccessServer())
332332
}
333333
case "console":
334334
if apiConfig.Enable {

bootstrap/config/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import (
2525

2626
"gopkg.in/yaml.v2"
2727

28+
"github.com/polarismesh/polaris/admin"
2829
"github.com/polarismesh/polaris/apiserver"
2930
"github.com/polarismesh/polaris/auth"
3031
"github.com/polarismesh/polaris/cache"
3132
"github.com/polarismesh/polaris/common/log"
3233
"github.com/polarismesh/polaris/config"
33-
"github.com/polarismesh/polaris/maintain"
3434
"github.com/polarismesh/polaris/namespace"
3535
"github.com/polarismesh/polaris/plugin"
3636
"github.com/polarismesh/polaris/service"
@@ -47,7 +47,7 @@ type Config struct {
4747
Naming service.Config `yaml:"naming"`
4848
Config config.Config `yaml:"config"`
4949
HealthChecks healthcheck.Config `yaml:"healthcheck"`
50-
Maintain maintain.Config `yaml:"maintain"`
50+
Maintain admin.Config `yaml:"maintain"`
5151
Store store.Config `yaml:"store"`
5252
Auth auth.Config `yaml:"auth"`
5353
Plugin plugin.Config `yaml:"plugin"`

bootstrap/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"go.uber.org/zap"
3131
"gopkg.in/yaml.v2"
3232

33+
"github.com/polarismesh/polaris/admin"
3334
"github.com/polarismesh/polaris/apiserver"
3435
"github.com/polarismesh/polaris/auth"
3536
boot_config "github.com/polarismesh/polaris/bootstrap/config"
@@ -42,7 +43,6 @@ import (
4243
"github.com/polarismesh/polaris/common/utils"
4344
"github.com/polarismesh/polaris/common/version"
4445
config_center "github.com/polarismesh/polaris/config"
45-
"github.com/polarismesh/polaris/maintain"
4646
"github.com/polarismesh/polaris/namespace"
4747
"github.com/polarismesh/polaris/plugin"
4848
"github.com/polarismesh/polaris/service"
@@ -197,7 +197,7 @@ func StartComponents(ctx context.Context, cfg *boot_config.Config) error {
197197
}
198198

199199
// 初始化运维操作模块
200-
if err := maintain.Initialize(ctx, &cfg.Maintain, namingSvr, healthCheckServer, cacheMgn, s); err != nil {
200+
if err := admin.Initialize(ctx, &cfg.Maintain, namingSvr, healthCheckServer, cacheMgn, s); err != nil {
201201
return err
202202
}
203203

store/maintain_api.go store/admin_api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828
ElectionKeyMaintainJobPrefix = "MaintainJob."
2929
)
3030

31-
type MaintainStore interface {
31+
type AdminStore interface {
3232
// StartLeaderElection start leader election
3333
StartLeaderElection(key string) error
3434

store/api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ type Store interface {
5252
// ClientStore Client the central module storage interface
5353
ClientStore
5454

55-
// MaintainStore Maintain inteface
56-
MaintainStore
55+
// AdminStore Maintain inteface
56+
AdminStore
5757
}
5858

5959
// NamespaceStore Namespace storage interface

0 commit comments

Comments
 (0)