Documentation
¶
Overview ¶
Package server is partner-emulator: the stand's trading partner that receives the documents the gateway sends and answers them the way a real partner does.
Input: POST /as2 with an X12 interchange (an 855, a 856 or the 997 of the gateway) and the headers AS2-From (the gateway), AS2-To (this partner) and Message-Id. Output: the MDN as JSON, and later, asynchronously, a 997 posted to the gateway's /edi/inbound with the token of this partner. Every transmission is parsed with the strict parser of the gateway (internal/edi/x12) and written to mock_partner.received, also a repeat with the same ISA13: a test counts the different ISA13 values to see how many documents the partner really got.
Several gateway processes may share one emulator (the slots of the benchmark). A process names itself in the header Edigate-Reply-To of /as2; its 997 goes to that address with the token of "<address> <partner id>" in the tokens file (else "<partner id>"). Without the header the 997 goes to GATEWAY_URL.
The emulator is also the mail service of the stand: POST /email takes a letter as a template id, an address and an order number, makes the text itself and writes a row with kind = 'email' (once per external_id); GET /email?external_id= says whether it is there.
The behaviour is set by knobs that tests and the stand change at run time with POST /control (only from the stand's own addresses: loopback and private networks): the delay and the verdict of the 997 (A, E, R, P with mixed verdicts, none), the delay of the MDN and the share of transmissions that get no MDN.
Index ¶
Constants ¶
const ReplyToHeader = "Edigate-Reply-To"
ReplyToHeader is the stand header in which a gateway process says where its 997 must be posted: its own public address. Without it the 997 goes to GATEWAY_URL. Several processes of the gateway (the slots of the benchmark) share this emulator, and each gets its own.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Knobs
GatewayURL string // where the 997 goes: <GatewayURL>/edi/inbound
TokensFile string // JSON {"<partner id>": "<token>"}, read again at every send
Log *slog.Logger
}
Config is what the emulator needs to start.
type Knobs ¶
type Knobs struct {
AckDelayMS int `json:"ack_delay_ms"` // PARTNER_ACK_DELAY_MS
AckStatus string `json:"ack_status"` // PARTNER_ACK_STATUS: A, E, R, P or none
MDNDelayMS int `json:"mdn_delay_ms"` // PARTNER_MDN_DELAY_MS
MDNDropRate float64 `json:"mdn_drop"` // PARTNER_MDN_DROP: share of transmissions without an MDN, 0 to 1
}
Knobs are the settings that change the behaviour. The JSON names are those of POST /control.