Documentation
¶
Overview ¶
Package rpc reads the RPC methods, from the proxyfile's rpc.methods or from a methods file, gives each method the service the proxyfile's rpc entry maps it to, and writes the RPC table: the routes as JSON, one object per line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Table ¶
Table writes the routes, in the order given, as a JSON array with one object per line, so a diff of two tables shows one line for each route that changed. Resolve sorts the routes by path, so the table's order does not depend on the order the methods are written in.
Each string is written by quote.JSON, whose result equals what Jackson's writeValueAsString writes for any text with no control character and no U+2028 or U+2029: Go escapes those two always and writes \u00XX in lower case, Jackson leaves the two as they are and writes upper case. Both write <, > and & as they are.
Types ¶
type Method ¶
type Method struct {
Service, Method, Action string // Action is "" when not written
Reports []string // nil when not written, and when written as []
Pos model.Pos // the entry's mapping
}
Method is one entry of the methods, as written in either place.
func MethodsOf ¶ added in v1.1.0
MethodsOf reads a list of methods the format check accepted, from a methods file or from the proxyfile's rpc.methods, in written order. It returns nil for an empty list.
func ReadMethods ¶
ReadMethods reads the methods file at path, which is JSON read as YAML so that a problem names its line. It returns the problems of the first step that finds any: reading the file, its syntax, then the format check. Every rule of the methods is Resolve's, the two that need no proxyfile included (a report holding a comma, a method listed twice), so one run names the problems of both kinds.
type Route ¶
type Route struct {
Method
Target *model.Service
Cluster string // Target.Cluster(model.GRPC)
Name string // the target's RouteName
}
Route is a method with the service it goes to.
func Resolve ¶
Resolve gives each method one target: an exact service name first, else the matching pattern with the longest text, else "*". Ranking exact names first settles the one tie length alone cannot (a.b.C against a.b.*); two different patterns that both match a service never have the same length, so the written order never matters.
g is a gateway read.Proxyfile returned, whose rules have made every target name a declared service with a gRPC port. Resolve returns either the routes, sorted by path, or every problem it finds, sorted.