Skip to content

Commit

Permalink
move SendUsagePing
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Oct 24, 2023
1 parent fa10376 commit 860f078
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
15 changes: 3 additions & 12 deletions pkg/module/usage_metrics/server/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/pluralsh/kuberentes-agent/pkg/module/modserver"
"github.com/pluralsh/kuberentes-agent/pkg/module/modshared"
"github.com/pluralsh/kuberentes-agent/pkg/module/usage_metrics"
pluralapi "github.com/pluralsh/kuberentes-agent/pkg/plural/api"
"github.com/pluralsh/kuberentes-agent/pkg/tool/errz"
)

Expand Down Expand Up @@ -53,11 +54,11 @@ func (m *module) sendUsageInternal(ctx context.Context) error {
if usageData.IsEmpty() {
return nil
}
data := UsagePingData{
data := pluralapi.UsagePingData{
Counters: usageData.Counters,
UniqueCounters: usageData.UniqueCounters,
}
err := SendUsagePing(data)
err := pluralapi.SendUsagePing(ctx, data)
if err != nil {
return err // don't wrap
}
Expand All @@ -69,13 +70,3 @@ func (m *module) sendUsageInternal(ctx context.Context) error {
func (m *module) Name() string {
return usage_metrics.ModuleName
}

// TODO: Send usage to console. Move this code to plural package.
type UsagePingData struct {
Counters map[string]int64 `json:"counters,omitempty"`
UniqueCounters map[string][]int64 `json:"unique_counters,omitempty"`
}

func SendUsagePing(data UsagePingData) error {
return nil
}
13 changes: 13 additions & 0 deletions pkg/plural/api/send_usage_ping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package api

import "context"

type UsagePingData struct {
Counters map[string]int64 `json:"counters,omitempty"`
UniqueCounters map[string][]int64 `json:"unique_counters,omitempty"`
}

// TODO: Implement.
func SendUsagePing(_ context.Context, _ UsagePingData) error {
return nil
}

0 comments on commit 860f078

Please sign in to comment.