Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 7e66df3

Browse files
committed
Rename annotation methods
Change AnnotateVertex and AnnotateEdge to VertexDebugInfo EdgeDebugInfo to avoid confusion between debug output and future graph annotations.
1 parent f37b2fa commit 7e66df3

4 files changed

Lines changed: 29 additions & 24 deletions

File tree

dag/graph.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,17 @@ func (g *Graph) SetDebugWriter(w io.Writer) {
343343
g.debug.Encode(newMarshalGraph("root", g))
344344
}
345345

346-
func (g *Graph) AnnotateVertex(v Vertex, info string) {
347-
va := newVertexAnnotation(v, info)
346+
// DebugVertexInfo encodes arbitrary information about a vertex in the graph
347+
// debug logs.
348+
func (g *Graph) DebugVertexInfo(v Vertex, info string) {
349+
va := newVertexDebugInfo(v, info)
348350
g.debug.Encode(va)
349351
}
350352

351-
func (g *Graph) AnnotateEdge(e Edge, info string) {
352-
ea := newEdgeAnnotation(e, info)
353+
// DebugEdgeInfo encodes arbitrary information about an edge in the graph debug
354+
// logs.
355+
func (g *Graph) DebugEdgeInfo(e Edge, info string) {
356+
ea := newEdgeDebugInfo(e, info)
353357
g.debug.Encode(ea)
354358
}
355359

dag/marshal.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ type marshalOperation struct {
426426
Type string
427427
Begin *string `json:",omitempty"`
428428
End *string `json:",omitempty"`
429+
Info *string `json:".omitempty"`
429430
}
430431

431432
func newBool(b bool) *bool { return &b }
@@ -468,31 +469,31 @@ func decodeGraph(r io.Reader) (*marshalGraph, error) {
468469
return g, nil
469470
}
470471

471-
// *Annotation structs allow encoding arbitrary information about the graph in
472+
// *DebugInfo structs allow encoding arbitrary information about the graph in
472473
// the logs.
473-
type vertexAnnotation struct {
474+
type vertexDebugInfo struct {
474475
Type string
475476
Vertex *marshalVertex
476477
Info string
477478
}
478479

479-
func newVertexAnnotation(v Vertex, info string) *vertexAnnotation {
480-
return &vertexAnnotation{
481-
Type: "VertexAnnotation",
480+
func newVertexDebugInfo(v Vertex, info string) *vertexDebugInfo {
481+
return &vertexDebugInfo{
482+
Type: "VertexDebugInfo",
482483
Vertex: newMarshalVertex(v),
483484
Info: info,
484485
}
485486
}
486487

487-
type edgeAnnotation struct {
488+
type edgeDebugInfo struct {
488489
Type string
489490
Edge *marshalEdge
490491
Info string
491492
}
492493

493-
func newEdgeAnnotation(e Edge, info string) *edgeAnnotation {
494-
return &edgeAnnotation{
495-
Type: "EdgeAnnotation",
494+
func newEdgeDebugInfo(e Edge, info string) *edgeDebugInfo {
495+
return &edgeDebugInfo{
496+
Type: "EdgeDebugInfo",
496497
Edge: newMarshalEdge(e),
497498
Info: info,
498499
}

dag/marshal_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestGraphJSON_basicRecord(t *testing.T) {
130130
}
131131

132132
// Verify that Vertex and Edge annotations appear in the debug output
133-
func TestGraphJSON_annotations(t *testing.T) {
133+
func TestGraphJSON_debugInfo(t *testing.T) {
134134
var g Graph
135135
var buf bytes.Buffer
136136
g.SetDebugWriter(&buf)
@@ -140,9 +140,9 @@ func TestGraphJSON_annotations(t *testing.T) {
140140
g.Add(3)
141141
g.Connect(BasicEdge(1, 2))
142142

143-
g.AnnotateVertex(2, "2")
144-
g.AnnotateVertex(3, "3")
145-
g.AnnotateEdge(BasicEdge(1, 2), "1|2")
143+
g.DebugVertexInfo(2, "2")
144+
g.DebugVertexInfo(3, "3")
145+
g.DebugEdgeInfo(BasicEdge(1, 2), "1|2")
146146

147147
dec := json.NewDecoder(bytes.NewReader(buf.Bytes()))
148148

@@ -156,8 +156,8 @@ func TestGraphJSON_annotations(t *testing.T) {
156156
}
157157

158158
switch d.Type {
159-
case "VertexAnnotation":
160-
va := &vertexAnnotation{}
159+
case "VertexDebugInfo":
160+
va := &vertexDebugInfo{}
161161
err := json.Unmarshal(d.JSON, va)
162162
if err != nil {
163163
t.Fatal(err)
@@ -177,8 +177,8 @@ func TestGraphJSON_annotations(t *testing.T) {
177177
default:
178178
t.Fatalf("unexpected annotation: %#v", va)
179179
}
180-
case "EdgeAnnotation":
181-
ea := &edgeAnnotation{}
180+
case "EdgeDebugInfo":
181+
ea := &edgeDebugInfo{}
182182
err := json.Unmarshal(d.JSON, ea)
183183
if err != nil {
184184
t.Fatal(err)

terraform/graph.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func (g *Graph) walk(walker GraphWalker) error {
294294
// then callback with the output.
295295
log.Printf("[DEBUG] vertex '%s.%s': evaluating", path, dag.VertexName(v))
296296

297-
g.AnnotateVertex(v, fmt.Sprintf("evaluating %T(%s)", v, path))
297+
g.DebugVertexInfo(v, fmt.Sprintf("evaluating %T(%s)", v, path))
298298

299299
tree = walker.EnterEvalTree(v, tree)
300300
output, err := Eval(tree, vertexCtx)
@@ -310,7 +310,7 @@ func (g *Graph) walk(walker GraphWalker) error {
310310
path,
311311
dag.VertexName(v))
312312

313-
g.AnnotateVertex(v, fmt.Sprintf("expanding %T(%s)", v, path))
313+
g.DebugVertexInfo(v, fmt.Sprintf("expanding %T(%s)", v, path))
314314

315315
g, err := ev.DynamicExpand(vertexCtx)
316316
if err != nil {
@@ -332,7 +332,7 @@ func (g *Graph) walk(walker GraphWalker) error {
332332
path,
333333
dag.VertexName(v))
334334

335-
g.AnnotateVertex(v, fmt.Sprintf("subgraph: %T(%s)", v, path))
335+
g.DebugVertexInfo(v, fmt.Sprintf("subgraph: %T(%s)", v, path))
336336

337337
if rerr = sn.Subgraph().(*Graph).walk(walker); rerr != nil {
338338
return

0 commit comments

Comments
 (0)