compile

package
v0.7.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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.

View Source
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.

func NewCache

func NewCache() *Cache

NewCache returns an empty cache.

func (*Cache) Compile

func (c *Cache) Compile(data []byte, source string) (*bundlev1.GRPCSchema, [sha256.Size]byte, error)

Compile is Compile, cached; the schema returned is the caller's. It returns the key the value is cached under, for Retain.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of entries.

func (*Cache) Retain

func (c *Cache) Retain(used map[[sha256.Size]byte]bool)

Retain drops the entries whose keys used doesn't hold: those no policy named in the latest build.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL