Documentation
¶
Index ¶
- Constants
- type CreateFeatureInputs
- type Feature
- type FeatureArchiveEvent
- type FeatureConnector
- type FeatureCreateEvent
- type FeatureInvalidFiltersError
- type FeatureInvalidMeterAggregationError
- type FeatureNotFoundError
- type FeatureOrderBy
- type FeatureRepo
- type FeatureWithNameAlreadyExistsError
- type ForbiddenError
- type IncludeArchivedFeature
- type ListFeaturesParams
- type MeterGroupByFilters
Constants ¶
View Source
const ( FeatureEventSubsystem metadata.EventSubsystem = "feature" FeatureCreateEventName metadata.EventName = "feature.created" FeatureUpdateEventName metadata.EventName = "feature.updated" FeatureArchiveEventName metadata.EventName = "feature.archived" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateFeatureInputs ¶
type Feature ¶
type Feature struct {
Namespace string `json:"namespace"`
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 FeatureArchiveEvent ¶
type FeatureArchiveEvent struct {
Feature *Feature `json:"feature"`
UserID *string `json:"userId,omitempty"`
}
FeatureArchiveEvent is an event that is emitted when a feature is archived
func NewFeatureArchiveEvent ¶
func NewFeatureArchiveEvent(ctx context.Context, feature *Feature) FeatureArchiveEvent
NewFeatureArchiveEvent creates a new feature delete event
func (FeatureArchiveEvent) EventMetadata ¶
func (e FeatureArchiveEvent) EventMetadata() metadata.EventMetadata
func (FeatureArchiveEvent) EventName ¶
func (e FeatureArchiveEvent) EventName() string
func (FeatureArchiveEvent) Validate ¶
func (e FeatureArchiveEvent) Validate() error
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) (pagination.PagedResponse[Feature], error)
GetFeature(ctx context.Context, namespace string, idOrKey string, includeArchived IncludeArchivedFeature) (*Feature, error)
}
TODO: refactor to service pattern
func NewFeatureConnector ¶
func NewFeatureConnector( featureRepo FeatureRepo, meterService meterpkg.Service, publisher eventbus.Publisher, ) FeatureConnector
type FeatureCreateEvent ¶
type FeatureCreateEvent struct {
Feature *Feature `json:"feature"`
UserID *string `json:"userId,omitempty"`
}
FeatureCreateEvent is an event that is emitted when a feature is created
func NewFeatureCreateEvent ¶
func NewFeatureCreateEvent(ctx context.Context, feature *Feature) FeatureCreateEvent
NewFeatureCreateEvent creates a new feature create event
func (FeatureCreateEvent) EventMetadata ¶
func (e FeatureCreateEvent) EventMetadata() metadata.EventMetadata
func (FeatureCreateEvent) EventName ¶
func (e FeatureCreateEvent) EventName() string
func (FeatureCreateEvent) Validate ¶
func (e FeatureCreateEvent) Validate() error
type FeatureInvalidFiltersError ¶
type FeatureInvalidFiltersError struct {
RequestedFilters map[string]string
MeterGroupByColumns []string
}
func (*FeatureInvalidFiltersError) Error ¶
func (e *FeatureInvalidFiltersError) Error() string
type FeatureInvalidMeterAggregationError ¶
type FeatureInvalidMeterAggregationError struct {
MeterSlug string
Aggregation meter.MeterAggregation
ValidAggregations []meter.MeterAggregation
}
func (*FeatureInvalidMeterAggregationError) Error ¶
func (e *FeatureInvalidMeterAggregationError) Error() string
type FeatureNotFoundError ¶
type FeatureNotFoundError struct {
ID string
}
func (*FeatureNotFoundError) Error ¶
func (e *FeatureNotFoundError) Error() string
type FeatureOrderBy ¶
type FeatureOrderBy string
FeatureOrderBy is the order by clause for features
const ( FeatureOrderByKey FeatureOrderBy = "key" FeatureOrderByName FeatureOrderBy = "name" FeatureOrderByCreatedAt FeatureOrderBy = "created_at" FeatureOrderByUpdatedAt FeatureOrderBy = "updated_at" )
func (FeatureOrderBy) Values ¶
func (f FeatureOrderBy) Values() []FeatureOrderBy
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) (pagination.PagedResponse[Feature], error)
HasActiveFeatureForMeter(ctx context.Context, namespace string, meterSlug string) (bool, error)
GetByIdOrKey(ctx context.Context, namespace string, idOrKey string, includeArchived bool) (*Feature, error)
entutils.TxCreator
entutils.TxUser[FeatureRepo]
}
type FeatureWithNameAlreadyExistsError ¶
func (*FeatureWithNameAlreadyExistsError) Error ¶
func (e *FeatureWithNameAlreadyExistsError) Error() string
type ForbiddenError ¶
func (*ForbiddenError) Error ¶
func (e *ForbiddenError) Error() string
type IncludeArchivedFeature ¶
type IncludeArchivedFeature bool
const ( IncludeArchivedFeatureTrue IncludeArchivedFeature = true IncludeArchivedFeatureFalse IncludeArchivedFeature = false )
type ListFeaturesParams ¶
type MeterGroupByFilters ¶
MeterGroupByFilters is a map of filters that can be applied to a meter when querying the usage for a feature.
Click to show internal directories.
Click to hide internal directories.