Skip to content

Commit

Permalink
Fix golint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dongxuny committed Sep 9, 2021
1 parent 091cbfe commit d7ce809
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
32 changes: 16 additions & 16 deletions metrics_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ func (set *MetricsSet) GetCounterWithValues(name string, values ...string) prome
// ignore err
counter, _ := counterVec.GetMetricWithLabelValues(values...)
return counter
} else {
return nil
}

return nil
}

// GetCounterWithLabels is thread safe
Expand All @@ -449,9 +449,9 @@ func (set *MetricsSet) GetCounterWithLabels(name string, labels prometheus.Label
counter, _ := counterVec.GetMetricWith(labels)

return counter
} else {
return nil
}

return nil
}

// GetGaugeWithValues is thread safe
Expand All @@ -470,9 +470,9 @@ func (set *MetricsSet) GetGaugeWithValues(name string, values ...string) prometh
gauge, _ := gaugeVec.GetMetricWithLabelValues(values...)

return gauge
} else {
return nil
}

return nil
}

// GetGaugeWithLabels is thread safe
Expand All @@ -490,9 +490,9 @@ func (set *MetricsSet) GetGaugeWithLabels(name string, labels prometheus.Labels)
gauge, _ := gaugeVec.GetMetricWith(labels)

return gauge
} else {
return nil
}

return nil
}

// GetSummaryWithValues is thread safe
Expand All @@ -511,9 +511,9 @@ func (set *MetricsSet) GetSummaryWithValues(name string, values ...string) prome
observer, _ := summaryVec.GetMetricWithLabelValues(values...)

return observer
} else {
return nil
}

return nil
}

// GetSummaryWithLabels is thread safe
Expand All @@ -532,9 +532,9 @@ func (set *MetricsSet) GetSummaryWithLabels(name string, labels prometheus.Label
observer, _ := summaryVec.GetMetricWith(labels)

return observer
} else {
return nil
}

return nil
}

// GetHistogramWithValues is thread safe
Expand All @@ -553,9 +553,9 @@ func (set *MetricsSet) GetHistogramWithValues(name string, values ...string) pro
observer, _ := hisVec.GetMetricWithLabelValues(values...)

return observer
} else {
return nil
}

return nil
}

// GetHistogramWithLabels is thread safe
Expand All @@ -574,9 +574,9 @@ func (set *MetricsSet) GetHistogramWithLabels(name string, labels prometheus.Lab
observer, _ := hisVec.GetMetricWith(labels)

return observer
} else {
return nil
}

return nil
}

// Construct key with format of namespace::subSystem::name
Expand Down
7 changes: 5 additions & 2 deletions prom_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ var (
)

const (
// PromEntryNameDefault default entry name
PromEntryNameDefault = "PromDefault"
PromEntryType = "PromEntry"
// PromEntryType default entry type
PromEntryType = "PromEntry"
// PromEntryDescription default entry description
PromEntryDescription = "Internal RK entry which implements prometheus client."
)

Expand Down Expand Up @@ -115,7 +118,7 @@ func WithName(name string) PromEntryOption {
}
}

// WithName provides entry description
// WithDescription provides entry description
func WithDescription(description string) PromEntryOption {
return func(entry *PromEntry) {
entry.EntryDescription = description
Expand Down
2 changes: 1 addition & 1 deletion pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func WithEventLoggerEntryPusher(eventLoggerEntry *rkentry.EventLoggerEntry) Push
}
}

// WithEventLoggerEntryPusher provides EventLoggerEntry
// WithCertStorePusher provides EventLoggerEntry
func WithCertStorePusher(certStore *rkentry.CertStore) PushGatewayPusherOption {
return func(pusher *PushGatewayPusher) {
pusher.CertStore = certStore
Expand Down
40 changes: 20 additions & 20 deletions pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
intervalMS = 200 * time.Millisecond
intervalMs = 200 * time.Millisecond
remoteAddr = "localhost:1608"
jobName = "rk-prom-job"
basicAuth = "user:pass"
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestNewPushGatewayPusher_WithNegativeIntervalMS(t *testing.T) {

func TestNewPushGatewayPusher_WithEmptyURL(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(""),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -68,7 +68,7 @@ func TestNewPushGatewayPusher_WithEmptyURL(t *testing.T) {

func TestNewPushGatewayPusher_WithEmptyJobName(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(""),
WithBasicAuthPusher(basicAuth),
Expand All @@ -81,7 +81,7 @@ func TestNewPushGatewayPusher_WithEmptyJobName(t *testing.T) {

func TestNewPushGatewayPusher_WithNilLZapLoggerEntry(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -94,7 +94,7 @@ func TestNewPushGatewayPusher_WithNilLZapLoggerEntry(t *testing.T) {

func TestNewPushGatewayPusher_WithNilLEventLoggerEntry(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -107,7 +107,7 @@ func TestNewPushGatewayPusher_WithNilLEventLoggerEntry(t *testing.T) {

func TestNewPushGatewayPusher_WithEmptyBasicAuth(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(""),
Expand All @@ -120,7 +120,7 @@ func TestNewPushGatewayPusher_WithEmptyBasicAuth(t *testing.T) {

func TestNewPushGatewayPusher_WithInvalidBasicAuth(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher("user:pass:pass"),
Expand Down Expand Up @@ -168,7 +168,7 @@ KPZKMmICqoFF8oquZRgLMKOvCr5g+3Ni+A==

pusher, err := NewPushGatewayPusher(
WithCertStorePusher(certStore),
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -178,7 +178,7 @@ KPZKMmICqoFF8oquZRgLMKOvCr5g+3Ni+A==
assert.NotNil(t, pusher, "pusher should not be nil")
assert.Nil(t, err, "error should be nil")

assert.Equal(t, intervalMS, pusher.IntervalMs)
assert.Equal(t, intervalMs, pusher.IntervalMs)
assert.NotNil(t, pusher.Pusher, "pusher should not be nil")
assert.Equal(t, jobName, pusher.JobName)
assert.Equal(t, basicAuth, pusher.Credential)
Expand All @@ -198,7 +198,7 @@ func TestNewPushGatewayPusher_WithInvalidCert(t *testing.T) {

pusher, err := NewPushGatewayPusher(
WithCertStorePusher(certStore),
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -208,7 +208,7 @@ func TestNewPushGatewayPusher_WithInvalidCert(t *testing.T) {
assert.NotNil(t, pusher, "pusher should not be nil")
assert.Nil(t, err, "error should be nil")

assert.Equal(t, intervalMS, pusher.IntervalMs)
assert.Equal(t, intervalMs, pusher.IntervalMs)
assert.NotNil(t, pusher.Pusher, "pusher should not be nil")
assert.Equal(t, jobName, pusher.JobName)
assert.Equal(t, basicAuth, pusher.Credential)
Expand All @@ -219,7 +219,7 @@ func TestNewPushGatewayPusher_WithInvalidCert(t *testing.T) {

func TestNewPushGatewayPusher_HappyCase(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -229,7 +229,7 @@ func TestNewPushGatewayPusher_HappyCase(t *testing.T) {
assert.NotNil(t, pusher, "pusher should not be nil")
assert.Nil(t, err, "error should be nil")

assert.Equal(t, intervalMS, pusher.IntervalMs)
assert.Equal(t, intervalMs, pusher.IntervalMs)
assert.NotNil(t, pusher.Pusher, "pusher should not be nil")
assert.Equal(t, jobName, pusher.JobName)
assert.Equal(t, basicAuth, pusher.Credential)
Expand All @@ -239,7 +239,7 @@ func TestNewPushGatewayPusher_HappyCase(t *testing.T) {

func TestPushGatewayPusher_Start_WithDuplicateStartCalls(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestPushGatewayPusher_Start_WithDuplicateStartCalls(t *testing.T) {

func TestPushGatewayPusher_Start_HappyCase(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand Down Expand Up @@ -297,7 +297,7 @@ func TestPushGatewayPusher_Start_HappyCase(t *testing.T) {

func TestPushGatewayPusher_push(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -323,7 +323,7 @@ func TestPushGatewayPusher_push(t *testing.T) {

func TestPushGatewayPusher_IsRunning_ExpectFalse(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -343,7 +343,7 @@ func TestPushGatewayPusher_IsRunning_ExpectFalse(t *testing.T) {

func TestPushGatewayPusher_IsRunning_ExpectTrue(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -363,7 +363,7 @@ func TestPushGatewayPusher_IsRunning_ExpectTrue(t *testing.T) {

func TestPushGatewayPusher_Stop(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand All @@ -382,7 +382,7 @@ func TestPushGatewayPusher_Stop(t *testing.T) {

func TestPushGatewayPusher_GetPusher(t *testing.T) {
pusher, err := NewPushGatewayPusher(
WithIntervalMSPusher(intervalMS),
WithIntervalMSPusher(intervalMs),
WithRemoteAddressPusher(remoteAddr),
WithJobNamePusher(jobName),
WithBasicAuthPusher(basicAuth),
Expand Down

0 comments on commit d7ce809

Please sign in to comment.