Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat:新增配置控制是否允许自动创建服务 #1285

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions release/conf/polaris-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ naming:
waitTime: 32ms
maxBatchCount: 128
concurrency: 128
# Whether to allow automatic creation of service
autoCreate: true
# Configuration of health check
healthcheck:
# Whether to open the health check function module
Expand Down
2 changes: 2 additions & 0 deletions release/standalone/docker-compose/server/polaris-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ naming:
waitTime: 32ms
maxBatchCount: 32
concurrency: 64
# Whether to allow automatic creation of service
autoCreate: true
# 健康检查的配置
healthcheck:
open: true
Expand Down
5 changes: 3 additions & 2 deletions service/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ var (

// Config 核心逻辑层配置
type Config struct {
L5Open bool `yaml:"l5Open"`
Batch map[string]interface{} `yaml:"batch"`
L5Open bool `yaml:"l5Open"`
AutoCreate bool `yaml:"autoCreate"`
Batch map[string]interface{} `yaml:"batch"`
}

// Initialize 初始化
Expand Down
4 changes: 4 additions & 0 deletions service/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,10 @@ func (s *Server) createServiceIfAbsent(
if svc != nil {
return svc.ID, nil
}
// if auto_create_service config is false, return service not found
if !s.allowAutoCreate() {
return "", api.NewResponse(apimodel.Code_NotFoundService)
}
simpleService := &apiservice.Service{
Name: utils.NewStringValue(svcName),
Namespace: utils.NewStringValue(namespace),
Expand Down
4 changes: 4 additions & 0 deletions service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func (s *Server) isSupportL5() bool {
return s.config.L5Open
}

func (s *Server) allowAutoCreate() bool {
return s.config.AutoCreate
}

// HealthServer 健康检查Server
func (s *Server) HealthServer() *healthcheck.Server {
return s.healthServer
Expand Down
Loading