Skip to content

Commit 1c30db0

Browse files
committed
fix:调整目录结构和命名
1 parent 19a8bb3 commit 1c30db0

File tree

12 files changed

+125
-57
lines changed

12 files changed

+125
-57
lines changed

pkg/flow/configuration/config_flow.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/polarismesh/polaris-go/pkg/model"
3232
"github.com/polarismesh/polaris-go/pkg/plugin/configconnector"
3333
"github.com/polarismesh/polaris-go/pkg/plugin/configfilter"
34-
"github.com/polarismesh/polaris-go/pkg/plugin/event"
34+
"github.com/polarismesh/polaris-go/pkg/plugin/events"
3535
)
3636

3737
// ConfigFileFlow 配置中心核心服务门面类
@@ -52,12 +52,12 @@ type ConfigFileFlow struct {
5252

5353
startLongPollingTaskOnce sync.Once
5454

55-
eventReporterChain []event.EventReporter
55+
eventReporterChain []events.EventReporter
5656
}
5757

5858
// NewConfigFileFlow 创建配置中心服务
5959
func NewConfigFileFlow(connector configconnector.ConfigConnector, chain configfilter.Chain,
60-
conf config.Configuration, eventReporterChain []event.EventReporter) (*ConfigFileFlow, error) {
60+
conf config.Configuration, eventReporterChain []events.EventReporter) (*ConfigFileFlow, error) {
6161
persistHandler, err := NewCachePersistHandler(
6262
conf.GetConfigFile().GetLocalCache().GetPersistDir(),
6363
conf.GetConfigFile().GetLocalCache().GetPersistMaxWriteRetry(),

pkg/flow/configuration/file_repo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/polarismesh/polaris-go/pkg/model"
3232
"github.com/polarismesh/polaris-go/pkg/plugin/configconnector"
3333
"github.com/polarismesh/polaris-go/pkg/plugin/configfilter"
34-
"github.com/polarismesh/polaris-go/pkg/plugin/event"
34+
"github.com/polarismesh/polaris-go/pkg/plugin/events"
3535
)
3636

3737
const (
@@ -64,7 +64,7 @@ type ConfigFileRepo struct {
6464

6565
fallbackToLocalCache bool
6666

67-
eventReporterChain []event.EventReporter
67+
eventReporterChain []events.EventReporter
6868
}
6969

7070
// ConfigFileRepoChangeListener 远程配置文件发布监听器
@@ -76,7 +76,7 @@ func newConfigFileRepo(metadata model.ConfigFileMetadata,
7676
chain configfilter.Chain,
7777
conf config.Configuration,
7878
persistHandler *CachePersistHandler,
79-
eventChain []event.EventReporter) (*ConfigFileRepo, error) {
79+
eventChain []events.EventReporter) (*ConfigFileRepo, error) {
8080
repo := &ConfigFileRepo{
8181
connector: connector,
8282
chain: chain,

pkg/flow/configuration/flow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/polarismesh/polaris-go/pkg/config"
2222
"github.com/polarismesh/polaris-go/pkg/plugin/configconnector"
2323
"github.com/polarismesh/polaris-go/pkg/plugin/configfilter"
24-
"github.com/polarismesh/polaris-go/pkg/plugin/event"
24+
"github.com/polarismesh/polaris-go/pkg/plugin/events"
2525
)
2626

2727
type ConfigFlow struct {
@@ -31,7 +31,7 @@ type ConfigFlow struct {
3131

3232
// NewConfigFlow 创建配置中心服务
3333
func NewConfigFlow(connector configconnector.ConfigConnector, chain configfilter.Chain,
34-
configuration config.Configuration, eventChain []event.EventReporter) (*ConfigFlow, error) {
34+
configuration config.Configuration, eventChain []events.EventReporter) (*ConfigFlow, error) {
3535
fileFlow, err := NewConfigFileFlow(connector, chain, configuration, eventChain)
3636
if err != nil {
3737
return nil, err

pkg/flow/data/util.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/polarismesh/polaris-go/pkg/plugin/common"
3131
"github.com/polarismesh/polaris-go/pkg/plugin/configconnector"
3232
"github.com/polarismesh/polaris-go/pkg/plugin/configfilter"
33-
"github.com/polarismesh/polaris-go/pkg/plugin/event"
33+
"github.com/polarismesh/polaris-go/pkg/plugin/events"
3434
"github.com/polarismesh/polaris-go/pkg/plugin/healthcheck"
3535
"github.com/polarismesh/polaris-go/pkg/plugin/loadbalancer"
3636
"github.com/polarismesh/polaris-go/pkg/plugin/localregistry"
@@ -159,20 +159,20 @@ func GetStatReporterChain(cfg config.Configuration, supplier plugin.Supplier) ([
159159
}
160160

161161
// GetEventReporterChain 获取事件上报插件
162-
func GetEventReporterChain(cfg config.Configuration, supplier plugin.Supplier) ([]event.EventReporter, error) {
162+
func GetEventReporterChain(cfg config.Configuration, supplier plugin.Supplier) ([]events.EventReporter, error) {
163163
if !cfg.GetGlobal().GetEventReporter().IsEnable() {
164-
return make([]event.EventReporter, 0), nil
164+
return make([]events.EventReporter, 0), nil
165165
}
166166

167167
reporterNames := cfg.GetGlobal().GetEventReporter().GetChain()
168-
reporterChain := make([]event.EventReporter, 0, len(reporterNames))
168+
reporterChain := make([]events.EventReporter, 0, len(reporterNames))
169169
if len(reporterNames) > 0 {
170170
for _, reporter := range reporterNames {
171171
targetPlugin, err := supplier.GetPlugin(common.TypeEventReporter, reporter)
172172
if err != nil {
173173
return nil, err
174174
}
175-
reporterChain = append(reporterChain, targetPlugin.(event.EventReporter))
175+
reporterChain = append(reporterChain, targetPlugin.(events.EventReporter))
176176
}
177177
}
178178
return reporterChain, nil

pkg/flow/impl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"github.com/polarismesh/polaris-go/pkg/plugin/common"
3939
"github.com/polarismesh/polaris-go/pkg/plugin/configconnector"
4040
"github.com/polarismesh/polaris-go/pkg/plugin/configfilter"
41-
"github.com/polarismesh/polaris-go/pkg/plugin/event"
41+
"github.com/polarismesh/polaris-go/pkg/plugin/events"
4242
"github.com/polarismesh/polaris-go/pkg/plugin/loadbalancer"
4343
"github.com/polarismesh/polaris-go/pkg/plugin/localregistry"
4444
"github.com/polarismesh/polaris-go/pkg/plugin/location"
@@ -64,7 +64,7 @@ type Engine struct {
6464
// 上报插件链
6565
reporterChain []statreporter.StatReporter
6666
// 事件插件链
67-
eventChain []event.EventReporter
67+
eventChain []events.EventReporter
6868
// 负载均衡器
6969
loadbalancer loadbalancer.LoadBalancer
7070
// 限流处理协助辅助类

pkg/plugin/event/eventReporter.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

pkg/plugin/event/proxy.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

pkg/plugin/events/eventReporter.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making polaris-go available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package events
19+
20+
import (
21+
"github.com/polarismesh/polaris-go/pkg/model"
22+
"github.com/polarismesh/polaris-go/pkg/plugin"
23+
"github.com/polarismesh/polaris-go/pkg/plugin/common"
24+
)
25+
26+
type EventReporter interface {
27+
plugin.Plugin
28+
29+
ReportEvent(e model.BaseEvent) error
30+
}
31+
32+
func init() {
33+
plugin.RegisterPluginInterface(common.TypeEventReporter, new(EventReporter))
34+
}

pkg/plugin/events/proxy.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making polaris-go available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package events
19+
20+
import (
21+
"github.com/polarismesh/polaris-go/pkg/model"
22+
"github.com/polarismesh/polaris-go/pkg/plugin"
23+
"github.com/polarismesh/polaris-go/pkg/plugin/common"
24+
)
25+
26+
type Proxy struct {
27+
EventReporter
28+
engine model.Engine
29+
}
30+
31+
func (p *Proxy) SetRealPlugin(plug plugin.Plugin, engine model.Engine) {
32+
p.EventReporter = plug.(EventReporter)
33+
p.engine = engine
34+
}
35+
36+
func init() {
37+
plugin.RegisterPluginProxy(common.TypeEventReporter, &Proxy{})
38+
}

pkg/plugin/register/plugins.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
_ "github.com/polarismesh/polaris-go/pkg/plugin/circuitbreaker"
2222
_ "github.com/polarismesh/polaris-go/pkg/plugin/configconnector"
2323
_ "github.com/polarismesh/polaris-go/pkg/plugin/configfilter"
24-
_ "github.com/polarismesh/polaris-go/pkg/plugin/event"
24+
_ "github.com/polarismesh/polaris-go/pkg/plugin/events"
2525
_ "github.com/polarismesh/polaris-go/pkg/plugin/healthcheck"
2626
_ "github.com/polarismesh/polaris-go/pkg/plugin/loadbalancer"
2727
_ "github.com/polarismesh/polaris-go/pkg/plugin/localregistry"
@@ -35,7 +35,7 @@ import (
3535
_ "github.com/polarismesh/polaris-go/plugin/configconnector/polaris"
3636
_ "github.com/polarismesh/polaris-go/plugin/configfilter/crypto"
3737
_ "github.com/polarismesh/polaris-go/plugin/configfilter/crypto/aes"
38-
_ "github.com/polarismesh/polaris-go/plugin/event/pushgateway"
38+
_ "github.com/polarismesh/polaris-go/plugin/events/pushgateway"
3939
_ "github.com/polarismesh/polaris-go/plugin/healthcheck/http"
4040
_ "github.com/polarismesh/polaris-go/plugin/healthcheck/tcp"
4141
_ "github.com/polarismesh/polaris-go/plugin/healthcheck/udp"

0 commit comments

Comments
 (0)