mirror of
https://github.com/zr-hebo/sniffer-agent.git
synced 2025-09-19 10:16:53 +08:00
add communicator api
This commit is contained in:
36
communicator/model.go
Normal file
36
communicator/model.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package communicator
|
||||
|
||||
import "fmt"
|
||||
|
||||
type configItem interface {
|
||||
setVal (interface{}) error
|
||||
getVal () interface{}
|
||||
}
|
||||
|
||||
type throwPacketRateConfig struct {
|
||||
name string
|
||||
value float64
|
||||
}
|
||||
|
||||
func newThrowPacketRateConfig() (tpr *throwPacketRateConfig) {
|
||||
tpr = &throwPacketRateConfig{
|
||||
name: THROW_PACKET_RATE,
|
||||
value: 0.0,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tc *throwPacketRateConfig) setVal (val interface{}) (err error){
|
||||
realVal, ok := val.(float64)
|
||||
if !ok {
|
||||
err = fmt.Errorf("cannot reansform val: %v to float64", val)
|
||||
return
|
||||
}
|
||||
|
||||
tc.value = realVal
|
||||
return
|
||||
}
|
||||
|
||||
func (tc *throwPacketRateConfig) getVal () (val interface{}){
|
||||
return tc.value
|
||||
}
|
Reference in New Issue
Block a user