-
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1628 from orozery/objectstore_marshaller
add objectstore marshaller
- Loading branch information
Showing
5 changed files
with
97 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
# subscriber_username: | ||
# subscriber_password: | ||
# max_seconds_per_stream: 86400 | ||
# flow_transformer: custom1 |
42 changes: 42 additions & 0 deletions
42
contrib/objectstore/subscriber/flowtransformer/custom1/custom1.go
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,42 @@ | ||
package custom1 | ||
|
||
import ( | ||
"github.com/skydive-project/skydive/flow" | ||
) | ||
|
||
// Flow represents a transformed flow | ||
type Flow struct { | ||
UUID string | ||
LayersPath string | ||
Network *flow.FlowLayer | ||
Transport *flow.TransportLayer | ||
LastUpdateMetric *flow.FlowMetric | ||
Metric *flow.FlowMetric | ||
Start int64 | ||
Last int64 | ||
FinishType flow.FlowFinishType | ||
} | ||
|
||
// FlowTransformer is a custom transformer for flows | ||
type FlowTransformer struct { | ||
} | ||
|
||
// Transform transforms a flow before being stored | ||
func (m *FlowTransformer) Transform(f *flow.Flow) interface{} { | ||
return &Flow{ | ||
UUID: f.UUID, | ||
LayersPath: f.LayersPath, | ||
Network: f.Network, | ||
Transport: f.Transport, | ||
LastUpdateMetric: f.LastUpdateMetric, | ||
Metric: f.Metric, | ||
Start: f.Start, | ||
Last: f.Last, | ||
FinishType: f.FinishType, | ||
} | ||
} | ||
|
||
// New returns a new Custom1Marshaller | ||
func New() *FlowTransformer { | ||
return &FlowTransformer{} | ||
} |
25 changes: 25 additions & 0 deletions
25
contrib/objectstore/subscriber/flowtransformer/flowtransformer.go
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,25 @@ | ||
package flowtransformer | ||
|
||
import ( | ||
"fmt" | ||
"github.com/skydive-project/skydive/contrib/objectstore/subscriber/flowtransformer/custom1" | ||
"github.com/skydive-project/skydive/flow" | ||
) | ||
|
||
// FlowTransformer allows generic transformations of a flow | ||
type FlowTransformer interface { | ||
// Transform transforms a flow before being stored | ||
Transform(flow *flow.Flow) interface{} | ||
} | ||
|
||
// New creates a new flow transformer based on a name string | ||
func New(flowTransformerName string) (FlowTransformer, error) { | ||
switch flowTransformerName { | ||
case "custom1": | ||
return custom1.New(), nil | ||
case "": | ||
return nil, nil | ||
default: | ||
return nil, fmt.Errorf("Marshaller '%s' is not supported", flowTransformerName) | ||
} | ||
} |
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