Documentation ¶
Index ¶
Constants ¶
const VERSION = "1.0.0"
VERSION is the version of protoc-gen-ratelimit being used.
Variables ¶
var SupportedFeatures = uint64(plugin_go.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
SupportedFeatures describes a flag setting for supported features.
Functions ¶
func GenerateLuaBucketer ¶
GenerateLuaBucketer generates the Lua bucketer
Types ¶
type Config ¶
type Config struct { Domain string `yaml:"domain"` Descriptors []string `yaml:"descriptors"` DefaultLimits []Limit `yaml:"default_limits"` Delimiter string `yaml:"delimiter"` }
Config is the configuration of the plugin
type Limit ¶
type Limit struct { Key string Value *YamlRateLimit }
Limit is the limit applied to specific descriptors
type Plugin ¶
type Plugin struct{}
Plugin describes a protoc code generate plugin. It's an implementation of Plugin from github.com/pseudomuto/protokit
func (*Plugin) Generate ¶
func (p *Plugin) Generate(r *plugin_go.CodeGeneratorRequest) (*plugin_go.CodeGeneratorResponse, error)
Generate compiles the documentation and generates the CodeGeneratorResponse to send back to protoc. It does this by rendering a template based on the options parsed from the CodeGeneratorRequest.
type PluginOptions ¶
type PluginOptions struct {
ConfigFile string
}
PluginOptions encapsulates options for the plugin. The type of renderer, template file, and the name of the output file are included.
func ParseOptions ¶
func ParseOptions(req *plugin_go.CodeGeneratorRequest) (*PluginOptions, error)
ParseOptions parses plugin options from a CodeGeneratorRequest. It does this by splitting the `Parameter` field from the request object and parsing out the type of renderer to use and the name of the file to be generated.
The parameter (`--doc_opt`) must be of the format <TYPE|TEMPLATE_FILE>,<OUTPUT_FILE>[,default|source_relative]:<EXCLUDE_PATTERN>,<EXCLUDE_PATTERN>*. The file will be written to the directory specified with the `--doc_out` argument to protoc.
type YamlDescriptor ¶
type YamlDescriptor struct { Key string Value string `yaml:"value,omitempty"` RateLimit *YamlRateLimit `yaml:"rate_limit,omitempty"` Descriptors []*YamlDescriptor `yaml:"descriptors,omitempty"` }
YamlDescriptor is the description of a rate limiting tuple
type YamlRateLimit ¶
type YamlRateLimit struct { RequestsPerUnit uint32 `yaml:"requests_per_unit,omitempty"` Unit string `yaml:"unit,omitempty"` Unlimited bool `yaml:"unlimited,omitempty"` }
YamlRateLimit is the rate limit being applied to a descriptor
type YamlRoot ¶
type YamlRoot struct { Domain string Descriptors []*YamlDescriptor }
YamlRoot is the root of the YAML document
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
protoc-gen-ratelimit
protoc-gen-ratelimit is used to generate supporting files for https://github.com/envoyproxy/ratelimit.
|
protoc-gen-ratelimit is used to generate supporting files for https://github.com/envoyproxy/ratelimit. |
extensions
|
|
s12
|
|