Documentation ¶
Overview ¶
Package graph defines a storage format for a simple package dependency graph. Nodes in the graph are named packages, and edges record direct forward dependencies between nodes.
Index ¶
- Variables
- type Graph
- func (g *Graph) Add(ctx context.Context, repo *deps.Repo, pkg *deps.Package) error
- func (g *Graph) AddAll(ctx context.Context, repo *deps.Repo) error
- func (g *Graph) EncodeToQuads(ctx context.Context, f func(quad.Quad) error) (err error)
- func (g *Graph) List(ctx context.Context, start string, f func(string) error) error
- func (g *Graph) MatchImporters(ctx context.Context, match func(string) bool, f func(tpkg, ipkg string)) error
- func (g *Graph) Remove(ctx context.Context, pkg string) error
- func (g *Graph) Row(ctx context.Context, pkg string) (*Row, error)
- func (g *Graph) Scan(ctx context.Context, start string, f func(*Row) error) error
- func (g *Graph) ScanUpdate(ctx context.Context, prefix string, f func(*Row) bool) error
- func (g *Graph) WriteQuads(ctx context.Context, w io.Writer) error
- type Row
- func (*Row) Descriptor() ([]byte, []int)deprecated
- func (x *Row) GetDirects() []string
- func (x *Row) GetImportPath() string
- func (x *Row) GetName() string
- func (x *Row) GetRanking() float64
- func (x *Row) GetRepository() string
- func (x *Row) GetSourceFiles() []*Row_File
- func (x *Row) GetType() Row_Type
- func (r *Row) MarshalJSON() ([]byte, error)
- func (*Row) ProtoMessage()
- func (x *Row) ProtoReflect() protoreflect.Message
- func (x *Row) Reset()
- func (x *Row) String() string
- func (r *Row) UnmarshalJSON(data []byte) error
- type Row_File
- type Row_Type
Constants ¶
This section is empty.
Variables ¶
var ( Row_Type_name = map[int32]string{ 0: "UNKNOWN", 1: "STDLIB", 2: "LIBRARY", 3: "PROGRAM", } Row_Type_value = map[string]int32{ "UNKNOWN": 0, "STDLIB": 1, "LIBRARY": 2, "PROGRAM": 3, } )
Enum value maps for Row_Type.
var File_graph_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
A Graph is an interface to a package dependency graph.
func (*Graph) Add ¶
Add adds the specified package to the graph. If an entry already exists for the specified package, it is replaced.
func (*Graph) EncodeToQuads ¶
EncodeToQuads converts g to RDF 1.1 N-quads and calls f for each. If f reports an error the conversion is terminated and the error is returned to the caller of EncodeToQuads.
func (*Graph) List ¶
List calls f with each key in the graph lexicographically greater than or equal to start. If f reports an error, scanning terminates. If the error is storage.ErrStopScan, List returns nil. Otherwise, List returns the error from f.
func (*Graph) MatchImporters ¶
func (g *Graph) MatchImporters(ctx context.Context, match func(string) bool, f func(tpkg, ipkg string)) error
MatchImporters calls f(q, p) for each package p that directly depends on any package q for which match(q) is true. The order of results is unspecified.
func (*Graph) Scan ¶
Scan calls f with each row in the graph whose key is lexicographically greater than or equal to start If f reports an error, scanning terminates. If the error is storage.ErrStopScan, Scan returns nil. Otherwise Scan returns the error from f.
func (*Graph) ScanUpdate ¶
ScanUpdate calls f with each row in the graph having the specified prefix. If f reports true, the modified value of the row is updated; otherwise no action is taken for the row.
type Row ¶
type Row struct { // The simple name and import path of the package whose row this is. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` ImportPath string `protobuf:"bytes,2,opt,name=import_path,json=importPath,proto3" json:"import_path,omitempty"` // The repository where the package was defined. Repository string `protobuf:"bytes,3,opt,name=repository,proto3" json:"repository,omitempty"` // The import paths of the direct dependencies of source. Directs []string `protobuf:"bytes,4,rep,name=directs,proto3" json:"directs,omitempty"` // The names and content digests of source files in this package. SourceFiles []*Row_File `protobuf:"bytes,5,rep,name=source_files,json=sourceFiles,proto3" json:"source_files,omitempty"` // Classify the package type according to its role, if known. Type Row_Type `protobuf:"varint,6,opt,name=type,proto3,enum=graph.Row_Type" json:"type,omitempty"` // Ranking weight; 0 represents an unranked value. Ranking float64 `protobuf:"fixed64,7,opt,name=ranking,proto3" json:"ranking,omitempty"` // contains filtered or unexported fields }
A Row is a single row of the dependency graph adjacency list.
func (*Row) Descriptor
deprecated
func (*Row) GetDirects ¶
func (*Row) GetImportPath ¶
func (*Row) GetRanking ¶
func (*Row) GetRepository ¶
func (*Row) GetSourceFiles ¶
func (*Row) MarshalJSON ¶
MarshalJSON implements json.Marshaler for a Row by delegating to protojson.
func (*Row) ProtoMessage ¶
func (*Row) ProtoMessage()
func (*Row) ProtoReflect ¶
func (x *Row) ProtoReflect() protoreflect.Message
func (*Row) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for a Row by delegating to jsonpb.
type Row_File ¶
type Row_File struct { RepoPath string `protobuf:"bytes,1,opt,name=repo_path,json=repoPath,proto3" json:"repo_path,omitempty"` // file path relative to the repository root Digest []byte `protobuf:"bytes,2,opt,name=digest,proto3" json:"digest,omitempty"` // content digest (sha256) // contains filtered or unexported fields }
func (*Row_File) Descriptor
deprecated
func (*Row_File) GetRepoPath ¶
func (*Row_File) ProtoMessage ¶
func (*Row_File) ProtoMessage()
func (*Row_File) ProtoReflect ¶
func (x *Row_File) ProtoReflect() protoreflect.Message
type Row_Type ¶
type Row_Type int32
func (Row_Type) Descriptor ¶
func (Row_Type) Descriptor() protoreflect.EnumDescriptor
func (Row_Type) EnumDescriptor
deprecated
func (Row_Type) Number ¶
func (x Row_Type) Number() protoreflect.EnumNumber
func (Row_Type) Type ¶
func (Row_Type) Type() protoreflect.EnumType