file

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWalkTimeout time.Duration = 3 * time.Second

DefaultWalkTimeout is the default walk timeout.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProtoFile

type ProtoFile struct {
	// The path to the .proto file.
	// Must be absolute.
	// Must be cleaned.
	Path string
	// The path to display in output.
	// This will be relative to the working directory, or the absolute path
	// if the file was outside the working directory.
	DisplayPath string
}

ProtoFile represents a .proto file.

type ProtoSet

type ProtoSet struct {
	// The working directory path.
	// Must be absolute.
	// Must be cleaned.
	WorkDirPath string
	// The given directory path.
	// This will be the same as WorkDirPath if files were given.
	// Must be absolute.
	// Must be cleaned.
	DirPath string
	// The directory path to slice of .proto files.
	// All paths must be absolute.
	// Must be cleaned.
	DirPathToFiles map[string][]*ProtoFile
	// The associated Config.
	// Must be valid.
	// The DirPath on the config may differ from the DirPath
	// on the ProtoSet.
	Config settings.Config
}

ProtoSet represents a set of .proto files and an associated config.

ProtoSets will be validated if returned from this package.

type ProtoSetProvider

type ProtoSetProvider interface {
	// GetForDir gets the ProtoSets for the given dirPath.
	// Each ProtoSet will have the config assocated with all files associated with
	// the ProtoSet.
	//
	// This will return all .proto files in the directory of the associated config file
	// and all it's subdirectories, or the given directory and its subdirectories
	// if there is no config file.
	//
	// Configs will be searched for starting at the directory of each .proto file
	// and going up a directory until hitting root.
	GetForDir(workDirPath string, dirPath string) ([]*ProtoSet, error)

	// GetForFiles gets the ProtoSets for the given filePaths.
	// Each ProtoSet will have the config assocated with all files associated with
	// the ProtoSet.
	//
	// Configs will be searched for starting at the directory of each .proto file
	// and going up a directory until hitting root.
	//
	// This ignores excludes, all files given will be included.
	GetForFiles(workDirPath string, filePaths ...string) ([]*ProtoSet, error)
}

ProtoSetProvider provides ProtoSets.

func NewProtoSetProvider

func NewProtoSetProvider(options ...ProtoSetProviderOption) ProtoSetProvider

NewProtoSetProvider returns a new ProtoSetProvider.

type ProtoSetProviderOption

type ProtoSetProviderOption func(*protoSetProvider)

ProtoSetProviderOption is an option for a new ProtoSetProvider.

func ProtoSetProviderWithLogger

func ProtoSetProviderWithLogger(logger *zap.Logger) ProtoSetProviderOption

ProtoSetProviderWithLogger returns a ProtoSetProviderOption that uses the given logger.

The default is to use zap.NewNop().

func ProtoSetProviderWithWalkTimeout

func ProtoSetProviderWithWalkTimeout(walkTimeout time.Duration) ProtoSetProviderOption

ProtoSetProviderWithWalkTimeout returns a ProtoSetProviderOption will timeout after walking a directory structure when searching for Protobuf files after the given amount of time.

The default is to timeout after DefaultTimeoutDuration. Set to 0 for no timeout.

Jump to

Keyboard shortcuts

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