Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions entity/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ go_library(
name = "entity",
srcs = [
"build_description.go",
"changed_targets.go",
"computation_strategy.go",
"optimized_target.go",
"target_graph.go",
],
importpath = "github.com/uber/tango/entity",
Expand Down
17 changes: 17 additions & 0 deletions entity/changed_targets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package entity

// ChangedTarget represents a target that differs between two revisions.
type ChangedTarget struct {
ChangeType int32 `json:"change_type"`
OldTarget *OptimizedTarget `json:"old_target,omitempty"`
NewTarget *OptimizedTarget `json:"new_target,omitempty"`
Distance int32 `json:"distance"`
}

// GetChangedTargetsResponse is one piece of a streamed changed-targets
// result — either a batch of changed targets or a metadata mapping.
// Exactly one field is non-nil.
type GetChangedTargetsResponse struct {
ChangedTargets []ChangedTarget `json:"changed_targets"`
Metadata *Metadata `json:"metadata,omitempty"`
}
34 changes: 34 additions & 0 deletions entity/optimized_target.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package entity

// OptimizedTarget is the compact, ID-mapped representation of a target used
// for streaming and storage. String fields are replaced with int32 IDs that
// reference the accompanying Metadata maps.
type OptimizedTarget struct {
ID int32 `json:"id"`
Hash string `json:"hash"`
DirectDependencies []int32 `json:"direct_dependencies"`
RuleType int32 `json:"rule_type"`
Tags []int32 `json:"tags"`
Root bool `json:"root"`
External bool `json:"external"`
Attributes map[int32]int32 `json:"attributes"`
}

// Metadata holds the ID-to-string mappings that accompany a set of
// OptimizedTarget entries. Consumers merge metadata across chunks before
// resolving IDs.
type Metadata struct {
TargetIDMapping map[int32]string `json:"target_id_mapping"`
RuleTypeMapping map[int32]string `json:"rule_type_mapping"`
TagMapping map[int32]string `json:"tag_mapping"`
AttributeNameMapping map[int32]string `json:"attribute_name_mapping"`
AttributeStringValueMapping map[int32]string `json:"attribute_string_value_mapping"`
}

// GetTargetGraphResponse is one piece of a streamed target graph — either a
// batch of ID-mapped targets or a metadata mapping. Exactly one field is
// non-nil.
type GetTargetGraphResponse struct {
Targets []OptimizedTarget `json:"targets"`
Metadata *Metadata `json:"metadata,omitempty"`
}
Loading