-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dc8332
commit efc729e
Showing
8 changed files
with
119 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package krt | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"istio.io/istio/pkg/slices" | ||
) | ||
|
||
var DebugCollections = []DebugCollection{} | ||
|
||
type CollectionDump struct { | ||
// Map of output key -> output | ||
Outputs map[string]any `json:"outputs"` | ||
// Map of input key -> info | ||
Inputs map[string]InputDump `json:"inputs"` | ||
} | ||
type InputDump struct { | ||
Outputs []string `json:"outputs"` | ||
Dependencies []string `json:"dependencies"` | ||
} | ||
type DebugCollection struct { | ||
name string | ||
dump func() CollectionDump | ||
} | ||
|
||
func (p DebugCollection) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(map[string]any{ | ||
"name": p.name, | ||
"state": p.dump(), | ||
}) | ||
} | ||
|
||
func RegisterCollectionForDebugging[T any](c Collection[T]) { | ||
cc := c.(internalCollection[T]) | ||
DebugCollections = append(DebugCollections, DebugCollection{ | ||
name: cc.name(), | ||
dump: cc.dump, | ||
}) | ||
} | ||
|
||
func eraseSlice[T any](l []T) []any { | ||
return slices.Map(l, func(e T) any { | ||
return any(e) | ||
}) | ||
} | ||
|
||
func eraseMap[T any](l map[Key[T]]T) map[string]any { | ||
nm := make(map[string]any, len(l)) | ||
for k, v := range l { | ||
nm[string(k)] = v | ||
} | ||
return nm | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters