checkutil

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package checkutil implements helpers for the check package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEnumPairRuleHandler

func NewEnumPairRuleHandler(
	f func(
		ctx context.Context,
		responseWriter check.ResponseWriter,
		request check.Request,
		enumDescriptor protoreflect.EnumDescriptor,
		againstEnumDescriptor protoreflect.EnumDescriptor,
	) error,
	options ...IteratorOption,
) check.RuleHandler

NewEnumPairRuleHandler returns a new RuleHandler that will call f for every enum pair within the check.Request's FileDescriptors() and AgainstFileDescriptors().

The enums will be paired up by fully-qualified name. Enums that cannot be paired up are skipped.

This is typically used for breaking change Rules.

func NewEnumRuleHandler

NewEnumRuleHandler returns a new RuleHandler that will call f for every enum within the check.Request's FileDescriptors().

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewEnumValueRuleHandler

NewEnumValueRuleHandler returns a new RuleHandler that will call f for every value in every enum within the check.Request's FileDescriptors().

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewFieldPairRuleHandler

func NewFieldPairRuleHandler(
	f func(
		ctx context.Context,
		responseWriter check.ResponseWriter,
		request check.Request,
		fieldDescriptor protoreflect.FieldDescriptor,
		againstFieldDescriptor protoreflect.FieldDescriptor,
	) error,
	options ...IteratorOption,
) check.RuleHandler

NewFieldPairRuleHandler returns a new RuleHandler that will call f for every field pair within the check.Request's FileDescriptors() and AgainstFileDescriptors().

The fields will be paired up by the fully-qualified name of the message, and the field number. Fields that cannot be paired up are skipped.

This includes extensions.

This is typically used for breaking change Rules.

func NewFieldRuleHandler

NewFieldRuleHandler returns a new RuleHandler that will call f for every field in every message within the check.Request's FileDescriptors().

This includes extensions.

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewFileImportRuleHandler

func NewFileImportRuleHandler(
	f func(context.Context, check.ResponseWriter, check.Request, protoreflect.FileImport) error,
	options ...IteratorOption,
) check.RuleHandler

NewFileImportRuleHandler returns a new RuleHandler that will call f for every "import" statement within the check.Request's FileDescriptors().

Note that terms are overloaded here: descriptor.FileDescriptor.IsImport denotes whether the FileDescriptor is an import itself, while this iterates over the protoreflect.FileImports within each FileDescriptor. The option WithoutImports() is a separate concern - NewFileImportRuleHandler(f, WithoutImports()) will iterate over all the FileImports for the non-import FileDescriptors.

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewFilePairRuleHandler

func NewFilePairRuleHandler(
	f func(
		ctx context.Context,
		responseWriter check.ResponseWriter,
		request check.Request,
		fileDescriptor descriptor.FileDescriptor,
		againstFileDescriptor descriptor.FileDescriptor,
	) error,
	options ...IteratorOption,
) check.RuleHandler

NewFilePairRuleHandler returns a new RuleHandler that will call f for every file pair within the check.Request's FileDescriptors() and AgainstFileDescriptors().

The FileDescriptors will be paired up by name. FileDescriptors that cannot be paired up are skipped.

This is typically used for breaking change Rules.

func NewFileRuleHandler

NewFileRuleHandler returns a new RuleHandler that will call f for every file within the check.Request's FileDescriptors().

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewMessagePairRuleHandler

func NewMessagePairRuleHandler(
	f func(
		ctx context.Context,
		responseWriter check.ResponseWriter,
		request check.Request,
		messageDescriptor protoreflect.MessageDescriptor,
		againstMessageDescriptor protoreflect.MessageDescriptor,
	) error,
	options ...IteratorOption,
) check.RuleHandler

NewMessagePairRuleHandler returns a new RuleHandler that will call f for every message pair within the check.Request's FileDescriptors() and AgainstFileDescriptors().

The messages will be paired up by fully-qualified name. Messages that cannot be paired up are skipped.

This is typically used for breaking change Rules.

func NewMessageRuleHandler

NewMessageRuleHandler returns a new RuleHandler that will call f for every message within the check.Request's FileDescriptors().

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewMethodPairRuleHandler

func NewMethodPairRuleHandler(
	f func(
		ctx context.Context,
		responseWriter check.ResponseWriter,
		request check.Request,
		methodDescriptor protoreflect.MethodDescriptor,
		againstMethodDescriptor protoreflect.MethodDescriptor,
	) error,
	options ...IteratorOption,
) check.RuleHandler

NewMethodPairRuleHandler returns a new RuleHandler that will call f for every method pair within the check.Request's FileDescriptors() and AgainstFileDescriptors().

The services will be paired up by fully-qualified name of the service, and name of the method. Methods that cannot be paired up are skipped.

This is typically used for breaking change Rules.

func NewMethodRuleHandler

NewMethodRuleHandler returns a new RuleHandler that will call f for every method in every service within the check.Request's FileDescriptors().

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewOneofRuleHandler

NewOneofRuleHandler returns a new RuleHandler that will call f for every oneof in every message within the check.Request's FileDescriptors().

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

func NewServicePairRuleHandler

func NewServicePairRuleHandler(
	f func(
		ctx context.Context,
		responseWriter check.ResponseWriter,
		request check.Request,
		serviceDescriptor protoreflect.ServiceDescriptor,
		againstServiceDescriptor protoreflect.ServiceDescriptor,
	) error,
	options ...IteratorOption,
) check.RuleHandler

NewServicePairRuleHandler returns a new RuleHandler that will call f for every service pair within the check.Request's FileDescriptors() and AgainstFileDescriptors().

The services will be paired up by fully-qualified name. Services that cannot be paired up are skipped.

This is typically used for breaking change Rules.

func NewServiceRuleHandler

NewServiceRuleHandler returns a new RuleHandler that will call f for every service within the check.Request's FileDescriptors().

This is typically used for lint Rules. Most callers will use the WithoutImports() options.

Types

type IteratorOption

type IteratorOption func(*iteratorOptions)

IteratorOption is an option for any of the New.*RuleHandler functions in this package.

func WithoutImports

func WithoutImports() IteratorOption

WithoutImports returns a new IteratorOption that will not call the provided function for any imports.

For lint RuleHandlers, this is generally an option you will want to pass. For breaking RuleHandlers, you generally want to consider imports as part of breaking changes.

The default is to call the provided function for all imports.

Jump to

Keyboard shortcuts

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