Documentation
¶
Overview ¶
Package compile compiles a FileDescriptorSet into the schema engines read gRPC messages with (design 0013 §5.1, §5.2): the operator runs it on a policy's descriptor set, so that engines never parse descriptors.
Index ¶
Constants ¶
const ( MaxSourceBytes = 1 << 20 MaxGunzipBytes = 8 << 20 // MaxFiles and MaxImports bound a set's files and their imports. MaxFiles = 4096 MaxImports = 65536 // MaxImportPaths bounds the import paths protodesc walks: through // public imports, a file sees what its imports publicly import, and so // on, and protodesc walks every path, which a chain of files each // publicly importing all earlier ones makes exponential (30 files of // 6.5 KB took 28 s). Real sets have a handful of public imports. MaxImportPaths = 100000 // MaxName bounds each name in a set (a package, a message, field, // enum, service or method name, a type a field, an extension or a // method names) and MaxNameParts the dot-separated parts of a package // or a type named: protodesc resolves a name by its scopes, which a // long package makes quadratic. Real names are a fraction of these. MaxName = grpcschema.MaxFullName MaxNameParts = 32 // MaxSetFields bounds the fields and extensions declared in a set, // those the methods don't read too. MaxSetFields = 4 * grpcschema.MaxFields )
Bounds of the source (design 0013 §5.4): a ConfigMap holds at most 1 MiB, and a gzipped set decompresses to at most 8 MiB.
Variables ¶
var ErrBusy = errors.New("another descriptor set is still being checked past its timeout; tried again later")
ErrBusy is a set not compiled because another set's check still runs past its Timeout: it is tried again on the next build, not cached.
var Timeout = 10 * time.Second
Timeout is how long protodesc may take on a set (a backstop past the bounds above): a set it doesn't finish in time is refused, not cached.
Functions ¶
func Compile ¶
func Compile(data []byte, source string) (*bundlev1.GRPCSchema, error)
Compile compiles data, a serialized FileDescriptorSet, raw or gzipped, into a schema whose source is source ("namespace/configmap/key"). The set must include its imports and describe at least one service. An error says what failed, naming the file or type where there is one.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache compiles each distinct descriptor set once (design 0013 §5.1): by the SHA-256 of the ConfigMap value, errors too. It is safe for concurrent use.