github.com/yandex/pandora@v0.5.32/components/providers/http/ammo/ammo.go (about)

     1  package ammo
     2  
     3  import (
     4  	"net/http"
     5  
     6  	phttp "github.com/yandex/pandora/components/guns/http"
     7  	"github.com/yandex/pandora/core/aggregator/netsample"
     8  )
     9  
    10  type Request interface {
    11  	http.Request
    12  }
    13  
    14  var _ phttp.Ammo = (*GunAmmo)(nil)
    15  
    16  type GunAmmo struct {
    17  	req       *http.Request
    18  	id        uint64
    19  	tag       string
    20  	isInvalid bool
    21  }
    22  
    23  func (g GunAmmo) Request() (*http.Request, *netsample.Sample) {
    24  	sample := netsample.Acquire(g.tag)
    25  	sample.SetID(g.id)
    26  	return g.req, sample
    27  }
    28  
    29  func (g GunAmmo) ID() uint64 {
    30  	return g.id
    31  }
    32  
    33  func (g GunAmmo) IsInvalid() bool {
    34  	return g.isInvalid
    35  }
    36  
    37  func NewGunAmmo(req *http.Request, tag string, id uint64) GunAmmo {
    38  	return GunAmmo{
    39  		req: req,
    40  		id:  id,
    41  		tag: tag,
    42  	}
    43  }