internal/conformance/proxy.go
internal/conformance · 89 lines · 7 declarations · source
Declarations
type Recorded
type Recorded struct {
Method string
Path string
Body []byte
}
Recorded is one request the adapter made through the proxy.
type proxy
type proxy struct {
server *httptest.Server
mu sync.Mutex
faults Faults
context *ContextAnswer
log []Recorded
}
proxy stands between the driver and the deployment. It forwards everything, records what the adapter sent, and refuses the operations a case's faults name with 503, which is what a deployment behind a load balancer answers when it is down: the same status an adapter has to treat as "memory unavailable" in production.
func newProxy
func newProxy(target string) (*proxy, error)
method proxy.URL
func (p *proxy) URL() string
method proxy.Close
func (p *proxy) Close()
method proxy.begin
func (p *proxy) begin(faults Faults, answer *ContextAnswer)
begin arms the faults and the stated context for one case and clears the log.
method proxy.recorded
func (p *proxy) recorded() []Recorded