Documentation
¶
Index ¶
- Constants
- func FormatSeconds(millis int64) string
- func ParseAgent(text string) (address string, port int64, ok bool)
- func ParsePercent(text string) (percent int, ok bool)
- func ParseSize(text string) (bytes int64, ok bool)
- func ParseTime(text string) (millis int64, ok bool)
- func Reason(err error) string
- func SortProblems(ps []Problem)
- type Auth
- type Count
- type Envoy
- type Gateway
- type Header
- type Limits
- type Log
- type MatchKind
- type Port
- type Pos
- type Problem
- type Problems
- type Protocol
- type RPC
- type RPCTarget
- type RequestHeaders
- type Route
- type Sample
- type SampleRule
- type Service
- type ServicePort
- type Size
- type Tag
- type Text
- type Time
- type Timeouts
- type Tracing
- type XRay
Constants ¶
const ( SizePattern = `^[1-9][0-9]*(KiB|MiB|GiB)$` TimePattern = `^` + timeFragment + `$` TimeOrNonePattern = `^(none|` + timeFragment + `)$` PercentPattern = `^(100|[1-9]?[0-9])%$` AgentPattern = `^[0-9]{1,3}(\.[0-9]{1,3}){3}:[1-9][0-9]{0,4}$` )
ParseSize, ParseTime, ParsePercent and ParseAgent compile SizePattern, TimeOrNonePattern, PercentPattern and AgentPattern, the same text the schema's "pattern" carries, so the schema and the parser accept the same forms. They differ in three places. No parser compiles TimePattern, and ParseTime accepts "none", so a field whose schema uses TimePattern relies on the schema check alone to refuse "none". A value can match its pattern yet overflow an int64, which only the parser refuses. And an agent can match its pattern, which takes digits and dots, and still hold an octet above 255, an octet with a leading zero or a port above 65535, which only ParseAgent refuses. The two time patterns share timeFragment so their digits and units cannot drift apart.
Variables ¶
This section is empty.
Functions ¶
func FormatSeconds ¶
FormatSeconds writes a duration the way Envoy reads it: the ProtoJSON form of google.protobuf.Duration, which accepts any number of fractional digits down to nanoseconds, so trailing zeros are dropped. Integer arithmetic keeps the text exact, because a float64 cannot hold every int64 millisecond count. Go's / and % truncate toward zero, so for a negative count both parts carry the sign; it is written once in front and the parts are made positive. The parts are negated rather than millis itself, because -math.MinInt64 does not fit in an int64.
func ParseAgent ¶
ParseAgent returns the IPv4 address and the UDP port of an agent written as address:port. The pattern refuses a port of 0 or one with a leading zero, which netip.ParseAddrPort would take; netip refuses what the pattern cannot, an octet above 255 or with a leading zero and a port above 65535.
func ParsePercent ¶
func ParseSize ¶
ParseSize returns the size in bytes. It refuses a size whose byte count does not fit in an int64 instead of letting it wrap to a wrong or negative limit.
func ParseTime ¶
ParseTime returns the time in milliseconds. "none" is 0: the caller decides what "none" means for the field it fills.
func Reason ¶
Reason is why a file or directory cannot be read, as a problem words it. The message it goes in names the path already, so the path an os error holds is left out rather than written twice.
func SortProblems ¶
func SortProblems(ps []Problem)
SortProblems orders problems by file, line, column, key path and message. The message is the last key so that two problems at the same position still come out in the same order on every run. A YAML problem has no key path, so YAML problems keep the order they had before the key path existed.
Types ¶
type Envoy ¶
type Envoy struct {
Namespace string // "proxyfile" when not written
Heap *Size // nil when not written
Tracing *Tracing // nil when not written
ConnectBridge bool // true when not written
}
Envoy is the envoy block: what only the Envoy generator reads.
type Gateway ¶
type Gateway struct {
Listen Port
Admin *Port
Limits Limits
Timeouts Timeouts
Services []Service // written order
ServicesPos Pos // the `services` key
Auth *Auth
RemoveFromClients []Header
Origins Text // the origins file as written, absolute or relative to the proxyfile's directory; "" when the proxyfile writes the origins
Routes []Route // written order
RoutesPos Pos // the `routes` key
Log *Log
Envoy Envoy
}
Gateway is one proxyfile after reading: every default filled in and every rule checked. Each value a rule or a later stage may name in a problem keeps the position it was written at; a default that was not written has no position, and nothing refuses a default.
type Limits ¶
type Limits struct {
Connections *Count
RequestHeaders *RequestHeaders
}
type Pos ¶
type Pos struct {
File string
Line, Column int
Path string // the key path, where the syntax gives no line: services.api.http, routes[1].to
}
Pos is where a problem was found. Line and Column count from 1, so 0 is free to mean "not known". Path places a value whose syntax gives it no line, which is every value of a HOCON file: the HOCON library keeps no position for a value, only for a syntax error.
type Problem ¶
func CannotRead ¶
CannotRead is the problem of a file that cannot be read. Every reader of every form reports it with this one text, so a missing file reads the same whichever reader met it.
func FileProblem ¶
FileProblem is a problem with the file as a whole, which names no line. It returns a list because every caller returns it alone, as all the problems of its stage.
type Problems ¶
type Problems struct {
// contains filtered or unexported fields
}
Problems collects the problems of one stage. A stage goes on after a problem, so one run names every problem of it.
type RequestHeaders ¶
type Route ¶
type Route struct {
Pos Pos
RPC *RPC // the `- rpc:` entry; the other fields are empty then
Name Text
Match MatchKind
Value Text // the prefix, path or pattern
Method string
To Text
Rewrite *Text
AuthOff *Text // the `auth: off` value, kept for its position
Retries int64
}
Route is one entry of `routes`: the `- rpc:` entry when RPC is set, else a plain route.
type Sample ¶
type Sample struct {
Default SampleRule
Rules []SampleRule // written order
}
Sample is what the sampling manifest holds. The default rule matches every request, so its Host, Method and Path are empty.
type SampleRule ¶
type Service ¶
type Service struct {
Name string
Pos Pos // the service's name
Address Text // "127.0.0.1" when not written
HostHeader string
Ports []ServicePort // written order
}
type ServicePort ¶
type Tag ¶
type Tag struct {
Name, Env, Header string
Default string // "" when not written; the check refuses an empty one
}
Tag is one custom tag: exactly one of Env and Header is set.
type XRay ¶
type XRay struct {
Address string // the agent's IPv4 address; 127.0.0.1 when not written
Port int64 // the agent's UDP port; 2000 when not written
Segment string
Sample *Sample // nil when not written: no manifest, and Envoy's own rule applies
}
XRay is envoy.tracing.provider.xray, the one provider of 1.2.