Skip to content

Commit 2e03e6c

Browse files
committed
Refactoring. Move fpm config parser to pkg
1 parent b0572de commit 2e03e6c

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

fpmConfig/fpmConfig.go renamed to pkg/phpfpm/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fpmConfig
1+
package phpfpm
22

33
import (
44
"fmt"
@@ -21,7 +21,7 @@ type Pool struct {
2121
StatusPath string
2222
}
2323

24-
func Parse(fpmConfigPath string) (Config, error) {
24+
func ParseConfig(fpmConfigPath string) (Config, error) {
2525
c := Config{}
2626
cfg := ini.Empty()
2727
err := cfg.Append(fpmConfigPath)

fpmConfig/fpmConfig_test.go renamed to pkg/phpfpm/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fpmConfig
1+
package phpfpm
22

33
import (
44
"testing"
@@ -7,7 +7,7 @@ import (
77
)
88

99
func TestParse(t *testing.T) {
10-
c, err := Parse("testData/php-fpm.conf")
10+
c, err := ParseConfig("testData/php-fpm.conf")
1111
assert.Nil(t, err)
1212
assert.Equal(t, "testData/php-fpm.d/*.conf", c.Include)
1313

pkg/phpfpm/prometeus.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ import (
77
"time"
88

99
"github.com/prometheus/client_golang/prometheus"
10-
11-
"github.com/code-tool/docker-fpm-wrapper/fpmConfig"
1210
)
1311

1412
const namespace = "phpfpm"
1513

1614
type stat struct {
1715
mu *sync.Mutex
1816
statuses []Status
19-
pools []fpmConfig.Pool
17+
pools []Pool
2018
}
2119

2220
func RegisterPrometheus(fpmConfigPath string, update time.Duration) error {
23-
cfg, err := fpmConfig.Parse(fpmConfigPath)
21+
cfg, err := ParseConfig(fpmConfigPath)
2422
if err != nil {
2523
return err
2624
}
@@ -99,7 +97,7 @@ type FPMPoolStatus struct {
9997
slowRequests *prometheus.GaugeVec
10098
}
10199

102-
func NewFPMPoolStatus(pools []fpmConfig.Pool) *FPMPoolStatus {
100+
func NewFPMPoolStatus(pools []Pool) *FPMPoolStatus {
103101
poolLabelNames := []string{"pool_name"}
104102

105103
return &FPMPoolStatus{

0 commit comments

Comments
 (0)