@@ -20,6 +20,7 @@ package polaris
2020import (
2121 "github.com/polarismesh/polaris-go/api"
2222 "github.com/polarismesh/polaris-go/pkg/config"
23+ "github.com/polarismesh/polaris-go/pkg/model"
2324)
2425
2526type configAPI struct {
@@ -91,3 +92,57 @@ func (c *configAPI) PublishConfigFile(namespace, fileGroup, fileName string) err
9192func (c * configAPI ) SDKContext () api.SDKContext {
9293 return c .rawAPI .SDKContext ()
9394}
95+
96+ type configGroupAPI struct {
97+ rawAPI api.ConfigGroupAPI
98+ }
99+
100+ // NewConfigGroupAPI 获取配置中心 API
101+ func NewConfigGroupAPI () (ConfigGroupAPI , error ) {
102+ rawAPI , err := api .NewConfigGroupAPI ()
103+ if err != nil {
104+ return nil , err
105+ }
106+ return & configGroupAPI {
107+ rawAPI : rawAPI ,
108+ }, nil
109+ }
110+
111+ // NewConfigAPIByConfig 通过配置对象获取配置中心 API
112+ func NewConfigGroupAPIByConfig (cfg config.Configuration ) (ConfigGroupAPI , error ) {
113+ rawAPI , err := api .NewConfigGroupAPIByConfig (cfg )
114+ if err != nil {
115+ return nil , err
116+ }
117+ return & configGroupAPI {
118+ rawAPI : rawAPI ,
119+ }, nil
120+ }
121+
122+ // NewConfigAPIByFile 通过配置文件获取配置中心 API
123+ func NewConfigGroupAPIByFile (path string ) (ConfigGroupAPI , error ) {
124+ rawAPI , err := api .NewConfigGroupAPIByFile (path )
125+ if err != nil {
126+ return nil , err
127+ }
128+ return & configGroupAPI {
129+ rawAPI : rawAPI ,
130+ }, nil
131+ }
132+
133+ // NewConfigAPIByContext 通过上下文对象获取配置中心 API
134+ func NewConfigGroupAPIByContext (context api.SDKContext ) ConfigGroupAPI {
135+ rawAPI := api .NewConfigGroupAPIBySDKContext (context )
136+ return & configGroupAPI {
137+ rawAPI : rawAPI ,
138+ }
139+ }
140+
141+ func (c * configGroupAPI ) GetConfigGroup (namesapce , group string ) (model.ConfigFileGroup , error ) {
142+ return c .rawAPI .GetConfigGroup (namesapce , group )
143+ }
144+
145+ // SDKContext 获取SDK上下文
146+ func (c * configGroupAPI ) SDKContext () api.SDKContext {
147+ return c .rawAPI .SDKContext ()
148+ }
0 commit comments