mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
Similar to video compression which uses key-frames and differences between them: every N publishes we send a full report, but inbetween we only send what has changed. Fairly simple approach in the probe - hold on to the last full report, and for the deltas remove anything that would be merged in from the full report. On the receiving side in the app it already merges a set of reports together to produce the final output for rendering, so provided N is smaller than that set we don't need to do anything different. Deltas don't need to represent nodes that have disappeared - an earlier full node will have that node so it would be merged into the final output anyway.
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package report
|
|
|
|
// IDList is a list of string IDs, which are always sorted and unique.
|
|
type IDList StringSet
|
|
|
|
var emptyIDList = IDList(MakeStringSet())
|
|
|
|
// MakeIDList makes a new IDList.
|
|
func MakeIDList(ids ...string) IDList {
|
|
if len(ids) == 0 {
|
|
return emptyIDList
|
|
}
|
|
return IDList(MakeStringSet(ids...))
|
|
}
|
|
|
|
// Add is the only correct way to add ids to an IDList.
|
|
func (a IDList) Add(ids ...string) IDList {
|
|
if len(ids) == 0 {
|
|
return a
|
|
}
|
|
return IDList(StringSet(a).Add(ids...))
|
|
}
|
|
|
|
// Merge all elements from a and b into a new list
|
|
func (a IDList) Merge(b IDList) IDList {
|
|
merged, _ := StringSet(a).Merge(StringSet(b))
|
|
return IDList(merged)
|
|
}
|
|
|
|
// Equal returns true if a and b have the same contents
|
|
func (a IDList) Equal(b IDList) bool {
|
|
return StringSet(a).Equal(StringSet(b))
|
|
}
|
|
|
|
// Contains returns true if id is in the list.
|
|
func (a IDList) Contains(id string) bool {
|
|
return StringSet(a).Contains(id)
|
|
}
|
|
|
|
// Intersection returns the intersection of a and b
|
|
func (a IDList) Intersection(b IDList) IDList {
|
|
return IDList(StringSet(a).Intersection(StringSet(b)))
|
|
}
|