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