summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-07-06 17:37:37 +0530
committersinanmohd <sinan@sinanmohd.com>2024-07-06 17:37:37 +0530
commit554975e37db43e1f0f26c740ec5593603d67f601 (patch)
tree23edf709de24c469b726a4ed5832a894ba153a6e
parentf2af6ba15466f7ac39f2c12ea29fab5b0c5415c4 (diff)
usage: don't export unnecessary types
-rw-r--r--cmd/redq/main.go4
-rw-r--r--usage/main.go24
2 files changed, 14 insertions, 14 deletions
diff --git a/cmd/redq/main.go b/cmd/redq/main.go
index abac395..4514efc 100644
--- a/cmd/redq/main.go
+++ b/cmd/redq/main.go
@@ -35,8 +35,8 @@ func main() {
}
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, os.Interrupt, os.Kill, syscall.SIGTERM)
- go func () {
- <- sigs
+ go func() {
+ <-sigs
u.CleanUp(queries, ctx)
os.Exit(0)
}()
diff --git a/usage/main.go b/usage/main.go
index 8be8ed3..cc16311 100644
--- a/usage/main.go
+++ b/usage/main.go
@@ -14,7 +14,7 @@ import (
"sinanmohd.com/redq/db"
)
-type UsageStat struct {
+type usageStat struct {
lastSeen time.Time
lastDbPush time.Time
BandwidthIngress uint64
@@ -23,11 +23,11 @@ type UsageStat struct {
Egress uint64
}
-type UsageMap map[uint64]UsageStat
+type usageMap map[uint64]usageStat
type Usage struct {
- Data UsageMap
- Mutex sync.Mutex
- objs bpfObjects
+ Data usageMap
+ Mutex sync.Mutex
+ objs bpfObjects
egressLink, ingressLink link.Link
}
@@ -36,7 +36,7 @@ func (u *Usage) Init(iface *net.Interface) error {
if err := loadBpfObjects(&u.objs, nil); err != nil {
log.Printf("loading objects: %s", err)
- return err;
+ return err
}
defer func() {
if err != nil {
@@ -69,7 +69,7 @@ func (u *Usage) Init(iface *net.Interface) error {
return err
}
- u.Data = make(UsageMap)
+ u.Data = make(usageMap)
return nil
}
@@ -106,13 +106,13 @@ func (u *Usage) Run(iface *net.Interface, queries *db.Queries, ctxDb context.Con
}
}
-func (usageStat *UsageStat) expired(timeStart *time.Time) bool {
- timeDiff := timeStart.Sub(usageStat.lastSeen)
+func (us *usageStat) expired(timeStart *time.Time) bool {
+ timeDiff := timeStart.Sub(us.lastSeen)
if timeDiff > time.Minute {
return true
}
- timeDiff = timeStart.Sub(usageStat.lastDbPush)
+ timeDiff = timeStart.Sub(us.lastDbPush)
if timeDiff > time.Hour {
return true
}
@@ -177,7 +177,7 @@ func (u *Usage) update(ingress *ebpf.Map, egress *ebpf.Map) error {
usage.lastSeen = timeStart
u.Data[key] = usage
} else {
- u.Data[key] = UsageStat{
+ u.Data[key] = usageStat{
BandwidthIngress: batchValues[i],
Ingress: batchValues[i],
lastDbPush: timeStart,
@@ -212,7 +212,7 @@ func (u *Usage) update(ingress *ebpf.Map, egress *ebpf.Map) error {
usage.lastSeen = timeStart
u.Data[key] = usage
} else {
- u.Data[key] = UsageStat{
+ u.Data[key] = usageStat{
BandwidthEgress: batchValues[i],
Egress: batchValues[i],
lastDbPush: timeStart,