proto

package
v0.0.0-...-90a5f25 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCast = errors.New("not able to convert to desired type")
View Source
var ErrNotFound = errors.New("not found")
View Source
var (
	Rules = []Rule{
		NewRule(
			"FILE_NO_BREAKING_CHANGE",
			"Ensures file does not have breaking changes from previous version, eg: No change in syntax, package name or removal of file",
			checkFileNoBreakingChange,
		),
		NewRule(
			"MESSAGE_NO_DELETE",
			"Ensures no message is deleted from previous version",
			checkMessageNoDelete,
		),
		NewRule(
			"FIELD_NO_BREAKING_CHANGE",
			"Ensures field does not have breaking changes from previous version, eg: No change in type, number, json name, label, field name or removal of field",
			checkFieldNoBreakingChange,
		),
		NewRule(
			"ENUM_NO_BREAKING_CHANGE",
			"Ensures enum does not have breaking changes from previous version, eg: No change in name and number or removal of enum",
			checkEnumNoBreakingChange,
		),
	}
)

Functions

func Compare

func Compare(current, prev []byte, rulesToSkip []string) error

func NewRule

func NewRule(id, description string, check CheckFunc) *rule

Types

type CheckFunc

type CheckFunc func(current, prev *protoregistry.Files) error

CheckFunc rule entry point

type ProtobufDBFile

type ProtobufDBFile struct {
	ID         int64
	SearchData *SearchData
	Data       []byte
}

ProtobufDBFile structure to store for each file info in DB

func ToProtobufDBFile

func ToProtobufDBFile(file protoreflect.FileDescriptor) *ProtobufDBFile

ToProtobufDBFile converts protoreflect.FileDescriptor type ProtobufDBFile

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository DB access layer

func NewProtoRepository

func NewProtoRepository(db *store.DB) *Repository

NewProtoRepository create instance repo

func (*Repository) Get

func (r *Repository) Get(ctx context.Context, snapshot *snapshot.Snapshot, names []string) ([][]byte, error)

Get Fullycontained descriptorset file given list of fully qualified message names. If message names are empty then whole fileDescriptorSet data returned

func (*Repository) Put

func (r *Repository) Put(ctx context.Context, snapshot *snapshot.Snapshot, dbFiles []*ProtobufDBFile) error

Put inserts fileDescriptorset information in DB

type Rule

type Rule interface {
	ID() string
	Check(*protoregistry.Files, *protoregistry.Files) error
}

Rule interface

type SearchData

type SearchData struct {
	Path         string   `json:"path"`
	Messages     []string `json:"messages"`
	Dependencies []string `json:"dependencies"`
}

SearchData contains searchable field information

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles proto CRUD operations

func NewService

func NewService(r *Repository, sr *snapshot.Repository) *Service

NewService creates new instance of proto service

func (*Service) Get

func (s *Service) Get(ctx context.Context, snapshot *snapshot.Snapshot, names []string) (data []byte, err error)

Get returns proto schema details from DB

func (*Service) Insert

func (s *Service) Insert(ctx context.Context, snapshot *snapshot.Snapshot, data []byte) error

Insert stores proto schema details in DB after backward compatible check succeeds

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, cs *snapshot.Snapshot, data []byte, rulesToSkip []string) error

Validate checks if current data is backward compatible against previous stable data

type Snapshot

type Snapshot struct {
	ID        int64
	Namespace string
	Name      string
	Version   string
	Latest    bool
}

Snapshot represents specific version of protodescriptorset

Jump to

Keyboard shortcuts

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