productcatalog

package
v1.0.0-beta.120 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateFeatureInputs

type CreateFeatureInputs struct {
	Name                string              `json:"name"`
	Key                 string              `json:"key"`
	Namespace           string              `json:"namespace"`
	MeterSlug           *string             `json:"meterSlug"`
	MeterGroupByFilters MeterGroupByFilters `json:"meterGroupByFilters"`
	Metadata            map[string]string   `json:"metadata"`
}

type Feature

type Feature struct {
	Namespace string `json:"-"`
	ID        string `json:"id,omitempty"`

	// Name The name of the feature.
	Name string `json:"name"`
	// Key The unique key of the feature.
	Key string `json:"key"`

	// MeterSlug The meter that the feature is associated with and decreases grants by usage.
	MeterSlug *string `json:"meterSlug,omitempty"`

	// MeterGroupByFilters Optional meter group by filters. Useful if the meter scope is broader than what feature tracks.
	MeterGroupByFilters MeterGroupByFilters `json:"meterGroupByFilters,omitempty"`

	// Metadata Additional metadata.
	Metadata map[string]string `json:"metadata,omitempty"`

	// Read-only fields
	ArchivedAt *time.Time `json:"archivedAt,omitempty"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Feature is a feature or service offered to a customer. For example: CPU-Hours, Tokens, API Calls, etc.

type FeatureConnector

type FeatureConnector interface {
	// Feature Management
	CreateFeature(ctx context.Context, feature CreateFeatureInputs) (Feature, error)
	// Should just use deletedAt, there's no real "archiving"
	ArchiveFeature(ctx context.Context, featureID models.NamespacedID) error
	ListFeatures(ctx context.Context, params ListFeaturesParams) ([]Feature, error)
	GetFeature(ctx context.Context, namespace string, idOrKey string) (*Feature, error)
}

func NewFeatureConnector

func NewFeatureConnector(
	featureRepo FeatureRepo,
	meterRepo meter.Repository,
) FeatureConnector

type FeatureInvalidFiltersError

type FeatureInvalidFiltersError struct {
	RequestedFilters    map[string]string
	MeterGroupByColumns []string
}

func (*FeatureInvalidFiltersError) Error

type FeatureInvalidMeterAggregationError

type FeatureInvalidMeterAggregationError struct {
	MeterSlug         string
	Aggregation       models.MeterAggregation
	ValidAggregations []models.MeterAggregation
}

func (*FeatureInvalidMeterAggregationError) Error

type FeatureNotFoundError

type FeatureNotFoundError struct {
	ID string
}

func (*FeatureNotFoundError) Error

func (e *FeatureNotFoundError) Error() string

type FeatureOrderBy

type FeatureOrderBy string
const (
	FeatureOrderByCreatedAt FeatureOrderBy = "created_at"
	FeatureOrderByUpdatedAt FeatureOrderBy = "updated_at"
)

type FeatureRepo

type FeatureRepo interface {
	CreateFeature(ctx context.Context, feature CreateFeatureInputs) (Feature, error)
	ArchiveFeature(ctx context.Context, featureID models.NamespacedID) error
	ListFeatures(ctx context.Context, params ListFeaturesParams) ([]Feature, error)

	GetByIdOrKey(ctx context.Context, namespace string, idOrKey string, includeArchived bool) (*Feature, error)
	entutils.TxCreator
	entutils.TxUser[FeatureRepo]
}

type FeatureWithNameAlreadyExistsError

type FeatureWithNameAlreadyExistsError struct {
	Name string
	ID   string
}

func (*FeatureWithNameAlreadyExistsError) Error

type ListFeaturesParams

type ListFeaturesParams struct {
	Namespace       string
	MeterSlug       string
	IncludeArchived bool
	Offset          int
	Limit           int
	OrderBy         FeatureOrderBy
}

type MeterGroupByFilters

type MeterGroupByFilters map[string]string

MeterGroupByFilters is a map of filters that can be applied to a meter when querying the usage for a feature.

func (MeterGroupByFilters) Validate

func (f MeterGroupByFilters) Validate(meter models.Meter) error

Jump to

Keyboard shortcuts

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