costsql

package
v0.0.0-...-8bea463 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBatchAlreadyClosed = errors.New("batch already closed")
)

Functions

This section is empty.

Types

type CostForServiceParams

type CostForServiceParams struct {
	TeamSlug    slug.Slug
	Service     string
	AppLabel    string
	FromDate    pgtype.Date
	ToDate      pgtype.Date
	Environment string
}

type CostForTeamParams

type CostForTeamParams struct {
	TeamSlug slug.Slug
	Service  string
	FromDate pgtype.Date
	ToDate   pgtype.Date
}

type CostMonthlyTeam

type CostMonthlyTeam struct {
	TeamSlug         slug.Slug
	Month            pgtype.Date
	LastRecordedDate pgtype.Date
	DailyCost        float32
}

type CostUpsertBatchResults

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

func (*CostUpsertBatchResults) Close

func (b *CostUpsertBatchResults) Close() error

func (*CostUpsertBatchResults) Exec

func (b *CostUpsertBatchResults) Exec(f func(int, error))

type CostUpsertParams

type CostUpsertParams struct {
	Environment *string
	TeamSlug    slug.Slug
	AppLabel    string
	Service     string
	Date        pgtype.Date
	DailyCost   float32
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

type DailyCostForTeamEnvironmentParams

type DailyCostForTeamEnvironmentParams struct {
	Environment string
	TeamSlug    slug.Slug
	FromDate    pgtype.Date
	ToDate      pgtype.Date
}

type DailyCostForTeamEnvironmentRow

type DailyCostForTeamEnvironmentRow struct {
	Date        pgtype.Date
	Environment *string
	TeamSlug    *slug.Slug
	AppLabel    *string
	DailyCost   float32
}

type DailyCostForTeamParams

type DailyCostForTeamParams struct {
	TeamSlug slug.Slug
	Services []string
	FromDate pgtype.Date
	ToDate   pgtype.Date
}

type DailyCostForTeamRow

type DailyCostForTeamRow struct {
	Date    pgtype.Date
	Service *string
	Cost    float32
}

type DailyCostForWorkloadParams

type DailyCostForWorkloadParams struct {
	Environment string
	TeamSlug    slug.Slug
	AppLabel    string
	FromDate    pgtype.Date
	ToDate      pgtype.Date
}

type DailyCostForWorkloadRow

type DailyCostForWorkloadRow struct {
	Date        pgtype.Date
	Environment *string
	TeamSlug    *slug.Slug
	Service     *string
	DailyCost   *float32
}

type DailyEnvCostForTeamParams

type DailyEnvCostForTeamParams struct {
	FromDate    pgtype.Date
	ToDate      pgtype.Date
	Environment *string
	TeamSlug    slug.Slug
}

type DailyEnvCostForTeamRow

type DailyEnvCostForTeamRow struct {
	TeamSlug  slug.Slug
	AppLabel  string
	Date      pgtype.Date
	DailyCost float32
}

type MockQuerier

type MockQuerier struct {
	mock.Mock
}

MockQuerier is an autogenerated mock type for the Querier type

func NewMockQuerier

func NewMockQuerier(t interface {
	mock.TestingT
	Cleanup(func())
},
) *MockQuerier

NewMockQuerier creates a new instance of MockQuerier. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockQuerier) CostForService

func (_m *MockQuerier) CostForService(ctx context.Context, arg CostForServiceParams) (float32, error)

CostForService provides a mock function with given fields: ctx, arg

func (*MockQuerier) CostForTeam

func (_m *MockQuerier) CostForTeam(ctx context.Context, arg CostForTeamParams) (float32, error)

CostForTeam provides a mock function with given fields: ctx, arg

func (*MockQuerier) CostUpsert

CostUpsert provides a mock function with given fields: ctx, arg

func (*MockQuerier) DailyCostForTeam

func (_m *MockQuerier) DailyCostForTeam(ctx context.Context, arg DailyCostForTeamParams) ([]*DailyCostForTeamRow, error)

DailyCostForTeam provides a mock function with given fields: ctx, arg

func (*MockQuerier) DailyCostForTeamEnvironment

func (_m *MockQuerier) DailyCostForTeamEnvironment(ctx context.Context, arg DailyCostForTeamEnvironmentParams) ([]*DailyCostForTeamEnvironmentRow, error)

DailyCostForTeamEnvironment provides a mock function with given fields: ctx, arg

func (*MockQuerier) DailyCostForWorkload

func (_m *MockQuerier) DailyCostForWorkload(ctx context.Context, arg DailyCostForWorkloadParams) ([]*DailyCostForWorkloadRow, error)

DailyCostForWorkload provides a mock function with given fields: ctx, arg

func (*MockQuerier) DailyEnvCostForTeam

func (_m *MockQuerier) DailyEnvCostForTeam(ctx context.Context, arg DailyEnvCostForTeamParams) ([]*DailyEnvCostForTeamRow, error)

DailyEnvCostForTeam provides a mock function with given fields: ctx, arg

func (*MockQuerier) EXPECT

func (_m *MockQuerier) EXPECT() *MockQuerier_Expecter

func (*MockQuerier) LastCostDate

func (_m *MockQuerier) LastCostDate(ctx context.Context) (pgtype.Date, error)

LastCostDate provides a mock function with given fields: ctx

func (*MockQuerier) ListTeamSlugsForCostUpdater

func (_m *MockQuerier) ListTeamSlugsForCostUpdater(ctx context.Context) ([]slug.Slug, error)

ListTeamSlugsForCostUpdater provides a mock function with given fields: ctx

func (*MockQuerier) MonthlyCostForTeam

func (_m *MockQuerier) MonthlyCostForTeam(ctx context.Context, teamSlug slug.Slug) ([]*CostMonthlyTeam, error)

MonthlyCostForTeam provides a mock function with given fields: ctx, teamSlug

func (*MockQuerier) MonthlyCostForWorkload

func (_m *MockQuerier) MonthlyCostForWorkload(ctx context.Context, arg MonthlyCostForWorkloadParams) ([]*MonthlyCostForWorkloadRow, error)

MonthlyCostForWorkload provides a mock function with given fields: ctx, arg

func (*MockQuerier) RefreshCostMonthlyTeam

func (_m *MockQuerier) RefreshCostMonthlyTeam(ctx context.Context) error

RefreshCostMonthlyTeam provides a mock function with given fields: ctx

type MockQuerier_CostForService_Call

type MockQuerier_CostForService_Call struct {
	*mock.Call
}

MockQuerier_CostForService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CostForService'

func (*MockQuerier_CostForService_Call) Return

func (*MockQuerier_CostForService_Call) Run

func (*MockQuerier_CostForService_Call) RunAndReturn

type MockQuerier_CostForTeam_Call

type MockQuerier_CostForTeam_Call struct {
	*mock.Call
}

MockQuerier_CostForTeam_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CostForTeam'

func (*MockQuerier_CostForTeam_Call) Return

func (*MockQuerier_CostForTeam_Call) Run

func (*MockQuerier_CostForTeam_Call) RunAndReturn

type MockQuerier_CostUpsert_Call

type MockQuerier_CostUpsert_Call struct {
	*mock.Call
}

MockQuerier_CostUpsert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CostUpsert'

func (*MockQuerier_CostUpsert_Call) Return

func (*MockQuerier_CostUpsert_Call) Run

func (*MockQuerier_CostUpsert_Call) RunAndReturn

type MockQuerier_DailyCostForTeamEnvironment_Call

type MockQuerier_DailyCostForTeamEnvironment_Call struct {
	*mock.Call
}

MockQuerier_DailyCostForTeamEnvironment_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DailyCostForTeamEnvironment'

func (*MockQuerier_DailyCostForTeamEnvironment_Call) Return

func (*MockQuerier_DailyCostForTeamEnvironment_Call) Run

type MockQuerier_DailyCostForTeam_Call

type MockQuerier_DailyCostForTeam_Call struct {
	*mock.Call
}

MockQuerier_DailyCostForTeam_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DailyCostForTeam'

func (*MockQuerier_DailyCostForTeam_Call) Return

func (*MockQuerier_DailyCostForTeam_Call) Run

func (*MockQuerier_DailyCostForTeam_Call) RunAndReturn

type MockQuerier_DailyCostForWorkload_Call

type MockQuerier_DailyCostForWorkload_Call struct {
	*mock.Call
}

MockQuerier_DailyCostForWorkload_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DailyCostForWorkload'

func (*MockQuerier_DailyCostForWorkload_Call) Return

func (*MockQuerier_DailyCostForWorkload_Call) Run

type MockQuerier_DailyEnvCostForTeam_Call

type MockQuerier_DailyEnvCostForTeam_Call struct {
	*mock.Call
}

MockQuerier_DailyEnvCostForTeam_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DailyEnvCostForTeam'

func (*MockQuerier_DailyEnvCostForTeam_Call) Return

func (*MockQuerier_DailyEnvCostForTeam_Call) Run

type MockQuerier_Expecter

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

func (*MockQuerier_Expecter) CostForService

func (_e *MockQuerier_Expecter) CostForService(ctx interface{}, arg interface{}) *MockQuerier_CostForService_Call

CostForService is a helper method to define mock.On call

  • ctx context.Context
  • arg CostForServiceParams

func (*MockQuerier_Expecter) CostForTeam

func (_e *MockQuerier_Expecter) CostForTeam(ctx interface{}, arg interface{}) *MockQuerier_CostForTeam_Call

CostForTeam is a helper method to define mock.On call

  • ctx context.Context
  • arg CostForTeamParams

func (*MockQuerier_Expecter) CostUpsert

func (_e *MockQuerier_Expecter) CostUpsert(ctx interface{}, arg interface{}) *MockQuerier_CostUpsert_Call

CostUpsert is a helper method to define mock.On call

  • ctx context.Context
  • arg []CostUpsertParams

func (*MockQuerier_Expecter) DailyCostForTeam

func (_e *MockQuerier_Expecter) DailyCostForTeam(ctx interface{}, arg interface{}) *MockQuerier_DailyCostForTeam_Call

DailyCostForTeam is a helper method to define mock.On call

  • ctx context.Context
  • arg DailyCostForTeamParams

func (*MockQuerier_Expecter) DailyCostForTeamEnvironment

func (_e *MockQuerier_Expecter) DailyCostForTeamEnvironment(ctx interface{}, arg interface{}) *MockQuerier_DailyCostForTeamEnvironment_Call

DailyCostForTeamEnvironment is a helper method to define mock.On call

  • ctx context.Context
  • arg DailyCostForTeamEnvironmentParams

func (*MockQuerier_Expecter) DailyCostForWorkload

func (_e *MockQuerier_Expecter) DailyCostForWorkload(ctx interface{}, arg interface{}) *MockQuerier_DailyCostForWorkload_Call

DailyCostForWorkload is a helper method to define mock.On call

  • ctx context.Context
  • arg DailyCostForWorkloadParams

func (*MockQuerier_Expecter) DailyEnvCostForTeam

func (_e *MockQuerier_Expecter) DailyEnvCostForTeam(ctx interface{}, arg interface{}) *MockQuerier_DailyEnvCostForTeam_Call

DailyEnvCostForTeam is a helper method to define mock.On call

  • ctx context.Context
  • arg DailyEnvCostForTeamParams

func (*MockQuerier_Expecter) LastCostDate

func (_e *MockQuerier_Expecter) LastCostDate(ctx interface{}) *MockQuerier_LastCostDate_Call

LastCostDate is a helper method to define mock.On call

  • ctx context.Context

func (*MockQuerier_Expecter) ListTeamSlugsForCostUpdater

func (_e *MockQuerier_Expecter) ListTeamSlugsForCostUpdater(ctx interface{}) *MockQuerier_ListTeamSlugsForCostUpdater_Call

ListTeamSlugsForCostUpdater is a helper method to define mock.On call

  • ctx context.Context

func (*MockQuerier_Expecter) MonthlyCostForTeam

func (_e *MockQuerier_Expecter) MonthlyCostForTeam(ctx interface{}, teamSlug interface{}) *MockQuerier_MonthlyCostForTeam_Call

MonthlyCostForTeam is a helper method to define mock.On call

  • ctx context.Context
  • teamSlug slug.Slug

func (*MockQuerier_Expecter) MonthlyCostForWorkload

func (_e *MockQuerier_Expecter) MonthlyCostForWorkload(ctx interface{}, arg interface{}) *MockQuerier_MonthlyCostForWorkload_Call

MonthlyCostForWorkload is a helper method to define mock.On call

  • ctx context.Context
  • arg MonthlyCostForWorkloadParams

func (*MockQuerier_Expecter) RefreshCostMonthlyTeam

func (_e *MockQuerier_Expecter) RefreshCostMonthlyTeam(ctx interface{}) *MockQuerier_RefreshCostMonthlyTeam_Call

RefreshCostMonthlyTeam is a helper method to define mock.On call

  • ctx context.Context

type MockQuerier_LastCostDate_Call

type MockQuerier_LastCostDate_Call struct {
	*mock.Call
}

MockQuerier_LastCostDate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LastCostDate'

func (*MockQuerier_LastCostDate_Call) Return

func (*MockQuerier_LastCostDate_Call) Run

func (*MockQuerier_LastCostDate_Call) RunAndReturn

type MockQuerier_ListTeamSlugsForCostUpdater_Call

type MockQuerier_ListTeamSlugsForCostUpdater_Call struct {
	*mock.Call
}

MockQuerier_ListTeamSlugsForCostUpdater_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTeamSlugsForCostUpdater'

func (*MockQuerier_ListTeamSlugsForCostUpdater_Call) Return

func (*MockQuerier_ListTeamSlugsForCostUpdater_Call) Run

func (*MockQuerier_ListTeamSlugsForCostUpdater_Call) RunAndReturn

type MockQuerier_MonthlyCostForTeam_Call

type MockQuerier_MonthlyCostForTeam_Call struct {
	*mock.Call
}

MockQuerier_MonthlyCostForTeam_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MonthlyCostForTeam'

func (*MockQuerier_MonthlyCostForTeam_Call) Return

func (*MockQuerier_MonthlyCostForTeam_Call) Run

func (*MockQuerier_MonthlyCostForTeam_Call) RunAndReturn

type MockQuerier_MonthlyCostForWorkload_Call

type MockQuerier_MonthlyCostForWorkload_Call struct {
	*mock.Call
}

MockQuerier_MonthlyCostForWorkload_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MonthlyCostForWorkload'

func (*MockQuerier_MonthlyCostForWorkload_Call) Return

func (*MockQuerier_MonthlyCostForWorkload_Call) Run

type MockQuerier_RefreshCostMonthlyTeam_Call

type MockQuerier_RefreshCostMonthlyTeam_Call struct {
	*mock.Call
}

MockQuerier_RefreshCostMonthlyTeam_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RefreshCostMonthlyTeam'

func (*MockQuerier_RefreshCostMonthlyTeam_Call) Return

func (*MockQuerier_RefreshCostMonthlyTeam_Call) Run

func (*MockQuerier_RefreshCostMonthlyTeam_Call) RunAndReturn

type MonthlyCostForWorkloadParams

type MonthlyCostForWorkloadParams struct {
	TeamSlug    slug.Slug
	AppLabel    string
	Environment string
}

type MonthlyCostForWorkloadRow

type MonthlyCostForWorkloadRow struct {
	TeamSlug         slug.Slug
	AppLabel         string
	Environment      *string
	Month            pgtype.Date
	Service          string
	LastRecordedDate pgtype.Date
	DailyCost        float32
}

type Querier

type Querier interface {
	CostForService(ctx context.Context, arg CostForServiceParams) (float32, error)
	CostForTeam(ctx context.Context, arg CostForTeamParams) (float32, error)
	CostUpsert(ctx context.Context, arg []CostUpsertParams) *CostUpsertBatchResults
	DailyCostForTeam(ctx context.Context, arg DailyCostForTeamParams) ([]*DailyCostForTeamRow, error)
	DailyCostForTeamEnvironment(ctx context.Context, arg DailyCostForTeamEnvironmentParams) ([]*DailyCostForTeamEnvironmentRow, error)
	DailyCostForWorkload(ctx context.Context, arg DailyCostForWorkloadParams) ([]*DailyCostForWorkloadRow, error)
	DailyEnvCostForTeam(ctx context.Context, arg DailyEnvCostForTeamParams) ([]*DailyEnvCostForTeamRow, error)
	LastCostDate(ctx context.Context) (pgtype.Date, error)
	ListTeamSlugsForCostUpdater(ctx context.Context) ([]slug.Slug, error)
	MonthlyCostForTeam(ctx context.Context, teamSlug slug.Slug) ([]*CostMonthlyTeam, error)
	MonthlyCostForWorkload(ctx context.Context, arg MonthlyCostForWorkloadParams) ([]*MonthlyCostForWorkloadRow, error)
	RefreshCostMonthlyTeam(ctx context.Context) error
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CostForService

func (q *Queries) CostForService(ctx context.Context, arg CostForServiceParams) (float32, error)

func (*Queries) CostForTeam

func (q *Queries) CostForTeam(ctx context.Context, arg CostForTeamParams) (float32, error)

func (*Queries) CostUpsert

func (q *Queries) CostUpsert(ctx context.Context, arg []CostUpsertParams) *CostUpsertBatchResults

func (*Queries) DailyCostForTeam

func (q *Queries) DailyCostForTeam(ctx context.Context, arg DailyCostForTeamParams) ([]*DailyCostForTeamRow, error)

func (*Queries) DailyCostForTeamEnvironment

func (q *Queries) DailyCostForTeamEnvironment(ctx context.Context, arg DailyCostForTeamEnvironmentParams) ([]*DailyCostForTeamEnvironmentRow, error)

func (*Queries) DailyCostForWorkload

func (q *Queries) DailyCostForWorkload(ctx context.Context, arg DailyCostForWorkloadParams) ([]*DailyCostForWorkloadRow, error)

func (*Queries) DailyEnvCostForTeam

func (q *Queries) DailyEnvCostForTeam(ctx context.Context, arg DailyEnvCostForTeamParams) ([]*DailyEnvCostForTeamRow, error)

func (*Queries) LastCostDate

func (q *Queries) LastCostDate(ctx context.Context) (pgtype.Date, error)

func (*Queries) ListTeamSlugsForCostUpdater

func (q *Queries) ListTeamSlugsForCostUpdater(ctx context.Context) ([]slug.Slug, error)

func (*Queries) MonthlyCostForTeam

func (q *Queries) MonthlyCostForTeam(ctx context.Context, teamSlug slug.Slug) ([]*CostMonthlyTeam, error)

func (*Queries) MonthlyCostForWorkload

func (q *Queries) MonthlyCostForWorkload(ctx context.Context, arg MonthlyCostForWorkloadParams) ([]*MonthlyCostForWorkloadRow, error)

func (*Queries) RefreshCostMonthlyTeam

func (q *Queries) RefreshCostMonthlyTeam(ctx context.Context) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

Jump to

Keyboard shortcuts

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