Skip to content

Commit f1b340c

Browse files
committed
chore:添加枚举值配置项 --story=125661369
1 parent 4a9a4d5 commit f1b340c

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/common/definitions.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package common
1818

1919
import (
20+
"fmt"
2021
"math"
2122
"time"
2223
)
@@ -1559,12 +1560,24 @@ const (
15591560
AttributeUnitMaxLength = 20
15601561
// AttributeOptionValueMaxLength TODO
15611562
AttributeOptionValueMaxLength = 128
1562-
// AttributeOptionArrayMaxLength TODO
1563-
AttributeOptionArrayMaxLength = 200
15641563
// ServiceCategoryMaxLength TODO
15651564
ServiceCategoryMaxLength = 128
15661565
)
15671566

1567+
var (
1568+
// AttributeOptionArrayMaxLength TODO
1569+
AttributeOptionArrayMaxLength = 200
1570+
)
1571+
1572+
// SetEnumLimit set AttributeOptionArrayMaxLength value,range:1~1000,default:200
1573+
func SetEnumLimit(limit int) error {
1574+
if limit <= 0 || limit > 1000 {
1575+
return fmt.Errorf("invalid enum limit:%d", limit)
1576+
}
1577+
AttributeOptionArrayMaxLength = limit
1578+
return nil
1579+
}
1580+
15681581
const (
15691582
// NameFieldMaxLength TODO
15701583
NameFieldMaxLength = 256

src/source_controller/coreservice/app/server.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func Run(ctx context.Context, cancel context.CancelFunc, op *options.ServerOptio
6363
input := &backbone.BackboneParameter{
6464
ConfigUpdate: coreSvr.onCoreServiceConfigUpdate,
6565
ConfigPath: op.ServConf.ExConfig,
66-
SrvRegdiscv: backbone.SrvRegdiscv{Zk: op.ServConf.Zk},
67-
SrvInfo: svrInfo,
66+
SrvRegdiscv: backbone.SrvRegdiscv{Zk: op.ServConf.Zk},
67+
SrvInfo: svrInfo,
6868
}
6969

7070
engine, err := backbone.NewBackbone(ctx, input)
@@ -111,7 +111,17 @@ func Run(ctx context.Context, cancel context.CancelFunc, op *options.ServerOptio
111111
}
112112

113113
func initResource(coreSvr *CoreServer, op *options.ServerOption) error {
114-
var err error
114+
enumLimit, err := cc.Int("objAttDes.enum.limit")
115+
if err != nil {
116+
blog.Errorf("can't find the value of objAttDes.enum.limit settings, "+
117+
"set the default value: %d", common.AttributeOptionArrayMaxLength)
118+
enumLimit = common.AttributeOptionArrayMaxLength
119+
}
120+
err = common.SetEnumLimit(enumLimit)
121+
if err != nil {
122+
return err
123+
}
124+
115125
coreSvr.Config.Mongo, err = coreSvr.Core.WithMongo()
116126
if err != nil {
117127
return err

0 commit comments

Comments
 (0)