Skip to content

Commit

Permalink
refactor for updating
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Jul 5, 2022
1 parent 7751945 commit 6cca5ae
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 37 deletions.
17 changes: 16 additions & 1 deletion 3rdmocks/ServerStream.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ grpc:
./rpc/gen/core.proto

deps:
env GO111MODULE=on go mod download
env GO111MODULE=on go mod vendor
go mod vendor

binary:
CGO_ENABLED=0 go build -ldflags "$(GO_LDFLAGS)" -gcflags=all=-G=3 -o eru-core
Expand Down
17 changes: 16 additions & 1 deletion cluster/mocks/Cluster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion engine/docker/mocks/APIClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion engine/mocks/API.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion lock/mocks/DistributedLock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ func (m *Metrics) SendMetrics(metrics ...*resources.Metrics) {
log.Errorf(nil, "[SendMetrics] Collector not found: %s", metric.Name) //nolint
continue
}
switch collector.(type) { // nolint: gocritic
switch collector.(type) { // nolint
case *prometheus.GaugeVec:
value, err := strconv.ParseFloat(metric.Value, 64)
if err != nil {
log.Errorf(nil, "[SendMetrics] Error occurred while parsing %v value %v: %v", metric.Name, metric.Value, err) //nolint
}
collector.(*prometheus.GaugeVec).WithLabelValues(metric.Labels...).Set(value)
collector.(*prometheus.GaugeVec).WithLabelValues(metric.Labels...).Set(value) // nolint
if err := m.gauge(metric.Key, value); err != nil {
log.Errorf(nil, "[SendMetrics] Error occurred while sending %v data to statsd: %v", metric.Name, err) //nolint
}
case *prometheus.CounterVec:
value, err := strconv.ParseInt(metric.Value, 10, 32)
value, err := strconv.ParseInt(metric.Value, 10, 32) // nolint
if err != nil {
log.Errorf(nil, "[SendMetrics] Error occurred while parsing %v value %v: %v", metric.Name, metric.Value, err) //nolint
}
collector.(*prometheus.CounterVec).WithLabelValues(metric.Labels...).Add(float64(value))
collector.(*prometheus.CounterVec).WithLabelValues(metric.Labels...).Add(float64(value)) // nolint
if err := m.count(metric.Key, int(value), 1.0); err != nil {
log.Errorf(nil, "[SendMetrics] Error occurred while sending %v data to statsd: %v", metric.Name, err) //nolint
}
Expand Down
14 changes: 0 additions & 14 deletions resources/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func NewPluginManager(config types.Config) (*PluginManager, error) {
config: config,
plugins: []Plugin{},
}

return pm, nil
}

Expand Down Expand Up @@ -56,19 +55,6 @@ func (pm *PluginManager) GetPlugins() []Plugin {
return pm.plugins
}

func (pm *PluginManager) callPlugins(plugins []Plugin, f func(Plugin)) {
wg := &sync.WaitGroup{}
wg.Add(len(plugins))

for _, plugin := range plugins {
go func(p Plugin) {
defer wg.Done()
f(p)
}(plugin)
}
wg.Wait()
}

func callPlugins[T any](ctx context.Context, plugins []Plugin, f func(Plugin) (T, error)) (map[Plugin]T, error) {
resMap := sync.Map{}
combinedErr := types.NewCombinedErr()
Expand Down
17 changes: 16 additions & 1 deletion resources/mocks/Plugin.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion rpc/mocks/CoreRPC_RunAndWaitServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion source/mocks/Source.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion store/etcdv3/meta/mocks/ETCDClientV3.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion store/etcdv3/meta/mocks/KV.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion store/etcdv3/meta/mocks/Txn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion store/mocks/Store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ func ListAllExecutableFiles(basedir string) ([]string, error) {
return nil
})

if err != nil {
return nil, err
}
return files, nil
return files, err
}

func isExecutable(perm fs.FileMode) bool {
Expand Down
Loading

0 comments on commit 6cca5ae

Please sign in to comment.