appproto

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package appproto 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 NewRunFunc added in v0.19.0

func NewRunFunc(handler Handler) func(context.Context, app.Container) error

NewRunFunc returns a new RunFunc for app.Main and app.Run.

Types

type Executor added in v0.23.0

type Executor interface {
	Execute(
		ctx context.Context,
		container app.EnvStderrContainer,
		readWriteBucket storage.ReadWriteBucket,
		request *pluginpb.CodeGeneratorRequest,
	) error
}

Executor executes the Handler using protoc's plugin execution logic.

This invokes a Handler and writes out the response to a Bucket, additionally accounting for insertion point logic.

func NewExecutor added in v0.23.0

func NewExecutor(
	logger *zap.Logger,
	handler Handler,
) Executor

NewExecutor returns a new Executor.

type Handler added in v0.19.0

type Handler interface {
	// Handle handles the plugin.
	//
	// This function can assume the request is valid.
	Handle(
		ctx context.Context,
		container app.EnvStderrContainer,
		responseWriter ResponseWriter,
		request *pluginpb.CodeGeneratorRequest,
	) error
}

Handler is a protoc plugin handler

type HandlerFunc added in v0.19.0

HandlerFunc is a handler function.

func (HandlerFunc) Handle added in v0.19.0

func (h HandlerFunc) Handle(
	ctx context.Context,
	container app.EnvStderrContainer,
	responseWriter ResponseWriter,
	request *pluginpb.CodeGeneratorRequest,
) error

Handle implements Handler.

type ResponseWriter

type ResponseWriter interface {
	// Add adds the file to the response.
	//
	// Returns error if nil, the name is empty, or the name is already added.
	Add(*pluginpb.CodeGeneratorResponse_File) error
	// AddError adds the error message to the response.
	//
	// If there is an existing error message, this will be concatenated with a newline.
	AddError(message string) error
	// SetFeatureProto3Optional sets the proto3 optional feature.
	SetFeatureProto3Optional()
}

ResponseWriter handles CodeGeneratorResponses.

Directories

Path Synopsis
Package appprotoexec provides protoc plugin handling and execution.
Package appprotoexec provides protoc plugin handling and execution.
cmd/protoc-gen-proxy
Package main defines protoc-gen-proxy, which is a testing protoc plugin that proxies to other plugins or to protoc.
Package main defines protoc-gen-proxy, which is a testing protoc plugin that proxies to other plugins or to protoc.

Jump to

Keyboard shortcuts

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