usage

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DAY = 24 * time.Hour

Variables

This section is empty.

Functions

func GetDB

func GetDB() (*sql.DB, error)

func InitDB

func InitDB(ctx context.Context, log *logging.Logger) error

Types

type HourlyUsageEntry

type HourlyUsageEntry struct {
	Project   string
	Workspace string
	Name      string
	Timestamp time.Time
	Minutes   int
}

func (*HourlyUsageEntry) ObjectKey

func (h *HourlyUsageEntry) ObjectKey() client.ObjectKey

func (*HourlyUsageEntry) ResourceName

func (h *HourlyUsageEntry) ResourceName() string

type TrackingMCPEntry

type TrackingMCPEntry struct {
	Project          string
	Workspace        string
	Name             string
	LastUsageCapture time.Time
	DeletedAt        sql.NullTime
}

type UsageTracker

type UsageTracker struct {
	// contains filtered or unexported fields
}

func NewUsageTracker

func NewUsageTracker(log *logging.Logger) (*UsageTracker, error)

func (*UsageTracker) Close

func (u *UsageTracker) Close() error

func (*UsageTracker) CreateOrIgnoreEvent

func (u *UsageTracker) CreateOrIgnoreEvent(ctx context.Context, project string, workspace string, mcp_name string) error

This method creates a tracking entry in the DB, if it not already exists updated a tracking entry in the DB, if it is there, but has a deleted_at entry does nothing to the DB, if it is already there

func (*UsageTracker) CreationEvent

func (u *UsageTracker) CreationEvent(ctx context.Context, project string, workspace string, mcp_name string) error

func (*UsageTracker) DeletionEvent

func (u *UsageTracker) DeletionEvent(ctx context.Context, project string, workspace string, mcp_name string) error

func (*UsageTracker) ScheduledEvent

func (u *UsageTracker) ScheduledEvent(ctx context.Context) error

func (*UsageTracker) WriteToResource

func (u *UsageTracker) WriteToResource(ctx context.Context, client client.Client) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL