Documentation
¶
Overview ¶
Package bufprotoplugin contains helper functionality for protoc plugins.
Note this is currently implicitly tested through buf's protoc command. If this were split out into a separate package, testing would need to be moved to this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidatePluginResponses ¶
func ValidatePluginResponses(pluginResponses []*PluginResponse) error
ValidatePluginResponses validates that each file is only defined by a single *PluginResponse.
Types ¶
type Generator ¶
type Generator interface { // Generate generates a CodeGeneratorResponse for the given CodeGeneratorRequests. // // A new ResponseBuilder is constructed for every invocation of Generate and is // used to consolidate all of the CodeGeneratorResponse_Files returned from a single // plugin into a single CodeGeneratorResponse. Generate( ctx context.Context, container app.EnvStderrContainer, requests []*pluginpb.CodeGeneratorRequest, ) (*pluginpb.CodeGeneratorResponse, error) }
Generator executes the Handler using protoc's plugin execution logic.
If multiple requests are specified, these are executed in parallel and the result is combined into one response that is written.
func NewGenerator ¶
func NewGenerator( logger *slog.Logger, handler protoplugin.Handler, ) Generator
NewGenerator returns a new Generator.
type PluginResponse ¶
type PluginResponse struct { Response *pluginpb.CodeGeneratorResponse PluginName string PluginOut string }
PluginResponse encapsulates a CodeGeneratorResponse, along with the name of the plugin that created it.
func NewPluginResponse ¶
func NewPluginResponse( response *pluginpb.CodeGeneratorResponse, pluginName string, pluginOut string, ) *PluginResponse
NewPluginResponse returns a new *PluginResponse.
type ResponseWriter ¶
type ResponseWriter interface { // WriteResponse writes to the bucket with the given response. In practice, the // WriteBucket is most often an in-memory bucket. // // CodeGeneratorResponses are consolidated into the bucket, and insertion points // are applied in-place so that they can only access the files created in a single // generation invocation (just like protoc). WriteResponse( ctx context.Context, writeBucket storage.WriteBucket, response *pluginpb.CodeGeneratorResponse, options ...WriteResponseOption, ) error }
ResponseWriter handles the response and writes it to the given storage.WriteBucket without executing any plugins and handles insertion points as needed.
func NewResponseWriter ¶
func NewResponseWriter(logger *slog.Logger) ResponseWriter
NewResponseWriter returns a new ResponseWriter.
type WriteResponseOption ¶
type WriteResponseOption func(*writeResponseOptions)
WriteResponseOption is an option for WriteResponse.
func WriteResponseWithInsertionPointReadBucket ¶
func WriteResponseWithInsertionPointReadBucket( insertionPointReadBucket storage.ReadBucket, ) WriteResponseOption
WriteResponseWithInsertionPointReadBucket returns a new WriteResponseOption that uses the given ReadBucket to read from for insertion points.
If this is not specified, insertion points are not supported.
Directories
¶
Path | Synopsis |
---|---|
Package bufprotopluginos does OS-specific generation.
|
Package bufprotopluginos does OS-specific generation. |