Documentation
¶
Overview ¶
Package render reads every input of one run and returns every output, in memory, so a caller writes nothing when any input has a problem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Targets = []Target{ {Name: "envoy", Config: "envoy.yaml", Generate: envoy.Generate}, {Name: "nginx", Config: "nginx.conf", Generate: nginx.Generate}, {Name: "haproxy", Config: "haproxy.cfg", Generate: haproxy.Generate}, }
Targets are the proxies with a generator: the one list render picks a generator from, which cli reads too to accept a --target. format.Targets declares each one's support of every key and cannot hold the generators itself: every generator depends on format, through origins and rpc, so format importing one would be an import cycle.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct{ Proxyfile, Out, RPCMethods, RPCTable, Target string }
Request is the files and the target of one run. RPCMethods and RPCTable are "" when not given, and a Target of "" is envoy.
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run is the inputs of one render, read without a problem and ready to generate.
func Read ¶
Read reads every input of req and returns them ready to generate, or every problem it finds.
The target is looked up before any file is read, in Targets for its generator and in format.Targets for the keys it refuses, and one that either list lacks is refused, so no caller gets another proxy's file. The proxyfile is read first, because every other input is read against it, and a key the target refuses ends the run there, because no other input can make the target carry it. Then the origins file, when the proxyfile names one instead of writing the origins, the RPC methods and the rpc-entry rule run together, so one run names the problems of all three, the keys the target refuses in the origins file and in the methods among them, whether a methods file or .proto options give them. The methods are the proxyfile's rpc.methods when it writes them, those of the .proto files under the roots of rpc.proto when it writes that, and the --rpc-methods file otherwise; giving the flag as well is a problem, because one list would be ignored. A relative origins path or root is read from the proxyfile's own directory, and an absolute one as written (tree.Beside says why).
func (*Run) Files ¶
Files returns every output, in memory and in this order: each file the target's generator returns, then RPCTable. The configuration, the file with no name, goes at Out, and a file the configuration loads goes beside it under its own name, because the configuration names it by that name. A name that holds a folder, or is . or .., would put the file outside the folder of Out, so it is refused as the bug in proxyfile it is. A value the generator refuses as it writes it (generator.Refused) is reported as a refusal at the value.
func (*Run) HasMethods ¶
HasMethods reports whether the run was given RPC methods, by rpc.methods, rpc.proto or --rpc-methods, also when they hold no method, so a caller can refuse an RPC table that no methods were given for.
func (*Run) Inputs ¶
Inputs returns the path of every file the run read: the proxyfile, the files its includes name, the origins file when it names one, and the methods file when --rpc-methods gave one or every .proto file rpc.proto read, in the order its roots were walked. An included name that no file answers is listed too, because the next run would read a file written there.
type Target ¶ added in v2.2.0
type Target struct {
Name string
Config string
Generate func(generator.Input) ([]generator.File, error)
}
Target is a proxy with a generator: its --target name, the name the examples commit its configuration under, and its generator.
func TargetNamed ¶ added in v2.2.0
TargetNamed returns the target whose Name is name. It reads Targets at each call, so a test may declare its own.