mirror of
https://github.com/retailcrm/mg-transport-core.git
synced 2024-11-25 06:36:03 +03:00
lint fixes
This commit is contained in:
parent
b110224cfe
commit
0f7c6c6669
@ -13,6 +13,7 @@ type AtomicCounterTest struct {
|
||||
}
|
||||
|
||||
func TestAtomicCounter(t *testing.T) {
|
||||
t.Parallel()
|
||||
suite.Run(t, new(AtomicCounterTest))
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,9 @@ type Storage interface {
|
||||
Process(processor Processor)
|
||||
}
|
||||
|
||||
// Counter will count successful and failed requests. Its contents can be used to judge if specific entity (e.g. Connection / Account)
|
||||
// is not working properly (invalid credentials, too many failed requests, etc) and take further action based on the result.
|
||||
// Counter will count successful and failed requests. Its contents can be used
|
||||
// to judge if specific entity (e.g. Connection / Account) is not working properly
|
||||
// (invalid credentials, too many failed requests, etc) and take further action based on the result.
|
||||
// Implementation should be goroutine-safe.
|
||||
type Counter interface {
|
||||
// Name can be used as a more friendly identifier for the counter.
|
||||
@ -77,7 +78,8 @@ type NotifyMessageLocalizer interface {
|
||||
// It will send the notification to system admins.
|
||||
type NotifyFunc func(apiURL, apiKey, msg string) error
|
||||
|
||||
// CounterConstructor is used to create counters. This way you can implement your own counter and still use default CounterStorage.
|
||||
// CounterConstructor is used to create counters.
|
||||
// This way you can implement your own counter and still use default CounterStorage.
|
||||
type CounterConstructor func(name string) Counter
|
||||
|
||||
// ConnectionDataProvider should return the connection credentials and language by counter ID.
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDefaultNotifyFunc(t *testing.T) {
|
||||
t.Parallel()
|
||||
apiURL := "https://test.retailcrm.pro"
|
||||
apiKey := "key"
|
||||
msg := "Notification"
|
||||
@ -37,6 +38,7 @@ func TestDefaultNotifyFunc(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDefaultNotifyFunc_Error(t *testing.T) {
|
||||
t.Parallel()
|
||||
apiURL := "https://test.retailcrm.pro"
|
||||
apiKey := "key"
|
||||
msg := "Notification"
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultMinRequests is a default minimal threshold of total requests. If Counter has less than this amount of requests
|
||||
// total, it will be skipped because it can trigger false alerts otherwise.
|
||||
// DefaultMinRequests is a default minimal threshold of total requests. If Counter has less than
|
||||
// this amount of requests total, it will be skipped because it can trigger false alerts otherwise.
|
||||
DefaultMinRequests = 10
|
||||
|
||||
// DefaultFailureThreshold is a default value of successful requests that should be passed in order to suppress any
|
||||
@ -26,7 +26,7 @@ type CounterProcessor struct {
|
||||
Debug bool
|
||||
}
|
||||
|
||||
func (c CounterProcessor) Process(id int, counter Counter) bool {
|
||||
func (c CounterProcessor) Process(id int, counter Counter) bool { // nolint:varnamelen
|
||||
if counter.IsFailed() {
|
||||
if counter.IsFailureProcessed() {
|
||||
c.debugLog("skipping counter id=%d because its failure is already processed", id)
|
||||
|
@ -19,6 +19,7 @@ type CounterProcessorTest struct {
|
||||
}
|
||||
|
||||
func TestCounterProcessor(t *testing.T) {
|
||||
t.Parallel()
|
||||
suite.Run(t, new(CounterProcessorTest))
|
||||
}
|
||||
|
||||
@ -349,10 +350,10 @@ func (cm *counterMock) FlushCounters() {
|
||||
}
|
||||
|
||||
type notifierMock struct {
|
||||
err error
|
||||
apiURL string
|
||||
apiKey string
|
||||
message string
|
||||
err error
|
||||
}
|
||||
|
||||
func (n *notifierMock) Notify(apiURL, apiKey, msg string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user