Skip to content

Commit e0e5fa0

Browse files
committed
common: moved TimeSlice to graph package
1 parent a34d022 commit e0e5fa0

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

common/types.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@ func UnixMillis(t time.Time) int64 {
5050
return t.UTC().UnixNano() / 1000000
5151
}
5252

53-
// TimeSlice defines a time boudary values
54-
type TimeSlice struct {
55-
Start int64 `json:"Start"`
56-
Last int64 `json:"Last"`
57-
}
58-
59-
// NewTimeSlice creates a new TimeSlice based on Start and Last
60-
func NewTimeSlice(s, l int64) *TimeSlice {
61-
return &TimeSlice{Start: s, Last: l}
62-
}
63-
6453
// Metric defines a common metric interface
6554
type Metric interface {
6655
// part of the Getter interface

graffiti/graph/filters.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,23 @@ func NewFilterForEdge(parent Identifier, child Identifier) *filters.Filter {
5959
)
6060
}
6161

62+
// TimeSlice defines a time boudary values
63+
type TimeSlice struct {
64+
Start int64 `json:"Start"`
65+
Last int64 `json:"Last"`
66+
}
67+
68+
// NewTimeSlice creates a new TimeSlice based on Start and Last
69+
func NewTimeSlice(s, l int64) *TimeSlice {
70+
return &TimeSlice{Start: s, Last: l}
71+
}
72+
6273
// filterForTimeSlice creates a filter based on a time slice between
6374
// startName and endName. time.Now() is used as reference if t == nil
64-
func filterForTimeSlice(t *common.TimeSlice, startName, endName string) *filters.Filter {
75+
func filterForTimeSlice(t *TimeSlice, startName, endName string) *filters.Filter {
6576
if t == nil {
6677
u := common.UnixMillis(time.Now())
67-
t = common.NewTimeSlice(u, u)
78+
t = NewTimeSlice(u, u)
6879
}
6980

7081
return filters.NewAndFilter(
@@ -76,7 +87,7 @@ func filterForTimeSlice(t *common.TimeSlice, startName, endName string) *filters
7687
)
7788
}
7889

79-
func getTimeFilter(t *common.TimeSlice) *filters.Filter {
90+
func getTimeFilter(t *TimeSlice) *filters.Filter {
8091
if t == nil {
8192
return filters.NewNullFilter("ArchivedAt")
8293
}

graffiti/graph/graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type PersistentBackend interface {
131131

132132
// Context describes within time slice
133133
type Context struct {
134-
TimeSlice *common.TimeSlice
134+
TimeSlice *TimeSlice
135135
TimePoint bool
136136
}
137137

graffiti/graph/traversal/traversal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func (t *GraphTraversal) Context(s ...interface{}) *GraphTraversal {
556556

557557
g, err := t.Graph.CloneWithContext(graph.Context{
558558
TimePoint: len(s) == 1,
559-
TimeSlice: common.NewTimeSlice(common.UnixMillis(at.Add(-duration)), common.UnixMillis(at)),
559+
TimeSlice: graph.NewTimeSlice(common.UnixMillis(at.Add(-duration)), common.UnixMillis(at)),
560560
})
561561
if err != nil {
562562
return &GraphTraversal{error: err}

graffiti/messages/messages.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/json"
2222
"errors"
2323

24-
"github.com/skydive-project/skydive/common"
2524
"github.com/skydive-project/skydive/graffiti/graph"
2625
ws "github.com/skydive-project/skydive/graffiti/websocket"
2726
)
@@ -86,7 +85,7 @@ func (s *SyncRequestMsg) UnmarshalJSON(b []byte) error {
8685
}
8786

8887
if raw.Time != 0 {
89-
s.TimeSlice = common.NewTimeSlice(raw.Time, raw.Time)
88+
s.TimeSlice = graph.NewTimeSlice(raw.Time, raw.Time)
9089
}
9190
s.GremlinFilter = raw.GremlinFilter
9291

gremlin/traversal/flows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ func captureAllowedNodes(nodes []*graph.Node) []*graph.Node {
838838
return allowed
839839
}
840840

841-
func (s *FlowGremlinTraversalStep) addTimeFilter(fsq *filters.SearchQuery, timeContext *common.TimeSlice) {
841+
func (s *FlowGremlinTraversalStep) addTimeFilter(fsq *filters.SearchQuery, timeContext *graph.TimeSlice) {
842842
var timeFilter *filters.Filter
843843
tr := filters.Range{
844844
// When we query the flows on the agents, we get the flows that have not

0 commit comments

Comments
 (0)