Documentation
¶
Overview ¶
Package server is mock-1c: a small HTTP service that behaves like the HTTP service of a 1C installation for sales orders, for the test stand.
Input: POST /hs/orders (a new order) and GET /hs/orders?external_id= (a lookup). Output: JSON. It writes only to its own schema mock_onec in the stand's database, so that a benchmark can count effects with a query.
A request with an external_id that is already there changes nothing and answers 200 with the stored order (an idempotent receiver). A request without an external_id always makes a new order: this is how a client without keys, like the baseline configuration C0 of the benchmark, behaves.
Fault knobs (set from the environment by cmd, or by tests): the share of requests that commit the order and then answer 500; a fixed delay; a prefix of the business reference that gets a permanent refusal (422). POST /control sets the same three knobs for one tenant (package mocks/control), so that slots of the benchmark do not disturb each other.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
FailAfterCommitRate float64 // MOCK_FAIL_AFTER_COMMIT_RATE: 0 to 1
Latency time.Duration // MOCK_LATENCY_MS
RejectRefPrefix string // MOCK_REJECT_REF_PREFIX; "" rejects nothing
FailCancel bool // MOCK_FAIL_CANCEL: every cancel answers 500 (the test of a failed compensation)
}
Config holds the fault knobs.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP handler of the mock.
func (*Server) SetFailAfterCommitRate ¶
SetFailAfterCommitRate changes the share of requests that commit and then fail.
func (*Server) SetFailCancel ¶
SetFailCancel makes every cancel answer 500 (or stops doing so).
func (*Server) SetRejectRefPrefix ¶
SetRejectRefPrefix changes the prefix of business references that get a 422.