Documentation
¶
Overview ¶
Package comparison compares paired unary RPC responses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
type Comparator struct {
// contains filtered or unexported fields
}
Comparator shares one immutable script program across response comparisons. Only schema-plan replacement is synchronized; each payload owns its evaluator.
func (*Comparator) Compare ¶
func (c *Comparator) Compare( ctx context.Context, requestMethod string, requestPath string, requestContentType string, reference Response, candidate Response, ) (result Result)
Compare compares one response pair without exposing response values in its result. requestPath must be escaped, as endpoints match it the way ServeMux does.
func (*Comparator) Configure ¶
func (c *Comparator) Configure(ctx context.Context, set *descriptorpb.FileDescriptorSet) error
Configure activates the comparator against a descriptor set.
func (*Comparator) MaxResponseBytes ¶
func (c *Comparator) MaxResponseBytes() int
MaxResponseBytes returns the per-backend response capture limit.
type Config ¶
type Config struct {
// ScriptsDir holds the normaliser scripts, which are all loaded as one set.
ScriptsDir string `` /* 129-byte string literal not displayed */
// ComparisonTimeout limits one response comparison.
ComparisonTimeout time.Duration `default:"1s" help:"Maximum duration of one response comparison."`
// ComparisonMaxResponseBytes limits each captured backend response body.
ComparisonMaxResponseBytes int `default:"1048576" help:"Maximum captured response bytes per backend."`
}
Config contains the command-line configuration for response comparison.
type Outcome ¶
type Outcome string
Outcome describes whether a response pair could be compared and matched.
const ( // Equivalent means the supported response pair matched. Equivalent Outcome = "equivalent" // Divergent means the supported response pair did not match. Divergent Outcome = "divergent" // Skipped means the request is outside the supported protocol scope. Skipped Outcome = "skipped" // Unable means a supported request could not be compared safely. Unable Outcome = "unable" )
type Response ¶
type Response struct {
// StatusCode is the backend's HTTP status before RPC-level status handling.
StatusCode int
// Header includes response trailers promoted by the HTTP transport.
Header http.Header
// Body contains at most the configured capture limit.
Body []byte
// Overflow reports that Body is truncated and must not be compared.
Overflow bool
}
Response is the captured result from one backend.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is the value-safe result of comparing two responses.
func NewDifferenceResult ¶
NewDifferenceResult constructs a divergent result without exposing response values.
func (Result) Differences ¶
Differences returns a copy of the divergent JSON paths.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package javascript evaluates Spectre payload normaliser scripts.
|
Package javascript evaluates Spectre payload normaliser scripts. |