1
0
Fork 0

chore: move the parser to a dedicated package.

This commit is contained in:
Ludovic Fernandez 2020-08-17 18:04:03 +02:00 committed by GitHub
parent eecc2f4dd7
commit 1502d20def
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
90 changed files with 191 additions and 14278 deletions

View file

@ -18,6 +18,7 @@ import (
"github.com/containous/traefik/v2/pkg/log"
"github.com/containous/traefik/v2/pkg/types"
"github.com/sirupsen/logrus"
ptypes "github.com/traefik/paerser/types"
)
type key string
@ -369,7 +370,7 @@ func (h *Handler) keepAccessLog(statusCode, retryAttempts int, duration time.Dur
return true
}
if h.config.Filters.MinDuration > 0 && (types.Duration(duration) > h.config.Filters.MinDuration) {
if h.config.Filters.MinDuration > 0 && (ptypes.Duration(duration) > h.config.Filters.MinDuration) {
return true
}

View file

@ -18,6 +18,7 @@ import (
"github.com/containous/traefik/v2/pkg/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ptypes "github.com/traefik/paerser/types"
)
var (
@ -527,7 +528,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) {
FilePath: "",
Format: CommonFormat,
Filters: &types.AccessLogFilters{
MinDuration: types.Duration(1 * time.Hour),
MinDuration: ptypes.Duration(1 * time.Hour),
},
},
expectedLog: ``,
@ -538,7 +539,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) {
FilePath: "",
Format: CommonFormat,
Filters: &types.AccessLogFilters{
MinDuration: types.Duration(1 * time.Millisecond),
MinDuration: ptypes.Duration(1 * time.Millisecond),
},
},
expectedLog: `TestHost - TestUser [13/Apr/2016:07:14:19 -0700] "POST testpath HTTP/0.0" 123 12 "testReferer" "testUserAgent" 23 "testRouter" "http://127.0.0.1/testService" 1ms`,

View file

@ -10,9 +10,9 @@ import (
"github.com/containous/traefik/v2/pkg/config/dynamic"
"github.com/containous/traefik/v2/pkg/testhelpers"
"github.com/containous/traefik/v2/pkg/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ptypes "github.com/traefik/paerser/types"
"github.com/vulcand/oxy/utils"
)
@ -37,7 +37,7 @@ func TestNewRateLimiter(t *testing.T) {
desc: "maxDelay computation, low rate regime",
config: dynamic.RateLimit{
Average: 2,
Period: types.Duration(10 * time.Second),
Period: ptypes.Duration(10 * time.Second),
Burst: 10,
},
expectedMaxDelay: 500 * time.Millisecond,
@ -183,7 +183,7 @@ func TestRateLimit(t *testing.T) {
desc: "lower than 1/s",
config: dynamic.RateLimit{
Average: 5,
Period: types.Duration(10 * time.Second),
Period: ptypes.Duration(10 * time.Second),
},
loadDuration: 2 * time.Second,
incomingLoad: 100,
@ -193,7 +193,7 @@ func TestRateLimit(t *testing.T) {
desc: "lower than 1/s, longer",
config: dynamic.RateLimit{
Average: 5,
Period: types.Duration(10 * time.Second),
Period: ptypes.Duration(10 * time.Second),
},
loadDuration: time.Minute,
incomingLoad: 100,
@ -203,7 +203,7 @@ func TestRateLimit(t *testing.T) {
desc: "lower than 1/s, longer, harsher",
config: dynamic.RateLimit{
Average: 1,
Period: types.Duration(time.Minute),
Period: ptypes.Duration(time.Minute),
},
loadDuration: time.Minute,
incomingLoad: 100,
@ -213,7 +213,7 @@ func TestRateLimit(t *testing.T) {
desc: "period below 1 second",
config: dynamic.RateLimit{
Average: 50,
Period: types.Duration(500 * time.Millisecond),
Period: ptypes.Duration(500 * time.Millisecond),
},
loadDuration: 2 * time.Second,
incomingLoad: 300,