44 "github.com/pkg/errors"
55 "github.com/yandex/pandora/components/answ/filter"
66 "github.com/yandex/pandora/components/answ/sampler"
7+ "github.com/yandex/pandora/core"
78 "github.com/yandex/pandora/lib/answlog"
89)
910
@@ -26,6 +27,19 @@ func NewHTTP1Gun(cfg GunConfig, answLog *answlog.Logger) *BaseGun {
2627 return NewBaseGun (HTTP1ClientConstructor , cfg , answLog )
2728}
2829
30+ func NewHTTP1GunFactory (conf GunConfig ) func () core.Gun {
31+ targetResolved , _ := PreResolveTargetAddr (& conf .Client , conf .Target )
32+ conf .TargetResolved = targetResolved
33+ answLog := answlog .Init (
34+ conf .AnswLog .Path ,
35+ conf .AnswLog .Enabled ,
36+ answlog .WithFilter (filter .NewHTTPStatusCodeFilter (conf .AnswLog .Filter )),
37+ answlog .WithSampler (sampler .NewStatusCodeSampler (conf .AnswLog .Sampling .Pattern , 600 ), conf .AnswLog .Sampling .Enabled ),
38+ answlog .WithMasker (conf .AnswLog .Masking ),
39+ )
40+ return func () core.Gun { return WrapGun (NewHTTP1Gun (conf , answLog )) }
41+ }
42+
2943func HTTP1ClientConstructor (clientConfig ClientConfig , target string ) Client {
3044 transport := NewTransport (clientConfig .Transport , NewDialer (clientConfig .Dialer ).DialContext , target )
3145 client := NewRedirectingClient (transport , clientConfig .Redirect )
@@ -43,6 +57,22 @@ func NewHTTP2Gun(cfg GunConfig, answLog *answlog.Logger) (*BaseGun, error) {
4357 return NewBaseGun (HTTP2ClientConstructor , cfg , answLog ), nil
4458}
4559
60+ func NewHTTP2GunFactory (conf GunConfig ) func () (core.Gun , error ) {
61+ targetResolved , _ := PreResolveTargetAddr (& conf .Client , conf .Target )
62+ conf .TargetResolved = targetResolved
63+ answLog := answlog .Init (
64+ conf .AnswLog .Path ,
65+ conf .AnswLog .Enabled ,
66+ answlog .WithFilter (filter .NewHTTPStatusCodeFilter (conf .AnswLog .Filter )),
67+ answlog .WithSampler (sampler .NewStatusCodeSampler (conf .AnswLog .Sampling .Pattern , 600 ), conf .AnswLog .Sampling .Enabled ),
68+ answlog .WithMasker (conf .AnswLog .Masking ),
69+ )
70+ return func () (core.Gun , error ) {
71+ gun , err := NewHTTP2Gun (conf , answLog )
72+ return WrapGun (gun ), err
73+ }
74+ }
75+
4676func HTTP2ClientConstructor (clientConfig ClientConfig , target string ) Client {
4777 transport := NewHTTP2Transport (clientConfig .Transport , NewDialer (clientConfig .Dialer ).DialContext , target )
4878 client := NewRedirectingClient (transport , clientConfig .Redirect )
@@ -71,6 +101,7 @@ func DefaultHTTPGunConfig() GunConfig {
71101 Factor : 10 ,
72102 },
73103 },
104+ Masking : & answlog.PassAllMasker {},
74105 },
75106 HTTPTrace : HTTPTraceConfig {
76107 DumpEnabled : false ,
@@ -97,6 +128,7 @@ func DefaultHTTP2GunConfig() GunConfig {
97128 Factor : 10 ,
98129 },
99130 },
131+ Masking : & answlog.PassAllMasker {},
100132 },
101133 HTTPTrace : HTTPTraceConfig {
102134 DumpEnabled : false ,
0 commit comments