Documentation
¶
Index ¶
- Constants
- type AggregationType
- type ApiStore
- func (store *ApiStore) FetchBillableMetric(organizationID string, code string) utils.Result[*BillableMetric]
- func (store *ApiStore) FetchFlatFilters(planID string, billableMetricCode string) utils.Result[[]FlatFilter]
- func (store *ApiStore) FetchSubscription(organizationID string, externalID string, timestamp time.Time) utils.Result[*Subscription]
- type BillableMetric
- type CacheStore
- type Cacher
- type ChargeCache
- type EnrichedEvent
- type Event
- type FailedEvent
- type FlagStore
- type Flagger
- type FlatFilter
- type FlatFilterValues
- type PricingGroupKeys
- type SourceMetadata
- type Subscription
Constants ¶
View Source
const ( AggregationTypeCount = iota AggregationTypeSum AggregationTypeMax AggregationTypeUniqueCount AggregationTypeWeightedSum AggregationTypeLatest AggregationTypeCustom )
View Source
const CACHE_KEY_VERSION = "1"
View Source
const EXPIRATION_TIME = 5 * time.Second
View Source
const HTTP_RUBY string = "http_ruby"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregationType ¶
type AggregationType int
func (AggregationType) String ¶
func (t AggregationType) String() string
type ApiStore ¶
type ApiStore struct {
// contains filtered or unexported fields
}
func NewApiStore ¶
func (*ApiStore) FetchBillableMetric ¶
func (*ApiStore) FetchFlatFilters ¶
func (*ApiStore) FetchSubscription ¶
type BillableMetric ¶
type BillableMetric struct {
ID string `gorm:"primaryKey;->"`
OrganizationID string `gorm:"->"`
Code string `gorm:"->"`
AggregationType AggregationType `gorm:"->"`
FieldName string `gorm:"->"`
Expression string `gorm:"->"`
CreatedAt time.Time `gorm:"->"`
UpdatedAt time.Time `gorm:"->"`
DeletedAt gorm.DeletedAt `gorm:"index;->"`
}
type CacheStore ¶
type CacheStore struct {
// contains filtered or unexported fields
}
func NewCacheStore ¶
func NewCacheStore(ctx context.Context, redis *redis.RedisDB) *CacheStore
func (*CacheStore) Close ¶
func (store *CacheStore) Close() error
type ChargeCache ¶
type ChargeCache struct {
CacheStore Cacher
}
func NewChargeCache ¶
func NewChargeCache(cacheStore *Cacher) *ChargeCache
func (*ChargeCache) Expire ¶
func (cache *ChargeCache) Expire(ff *FlatFilter, subID string) utils.Result[bool]
type EnrichedEvent ¶
type EnrichedEvent struct {
InitialEvent *Event `json:"-"`
BillableMetric *BillableMetric `json:"-"`
Subscription *Subscription `json:"-"`
FlatFilter *FlatFilter `json:"-"`
OrganizationID string `json:"organization_id"`
ExternalSubscriptionID string `json:"external_subscription_id"`
SubscriptionID string `json:"subscription_id"`
PlanID string `json:"plan_id"`
TransactionID string `json:"transaction_id"`
Code string `json:"code"`
AggregationType string `json:"aggregation_type"`
Properties map[string]any `json:"properties"`
PreciseTotalAmountCents string `json:"precise_total_amount_cents"`
Source string `json:"source,omitempty"`
Value *string `json:"value"`
Timestamp float64 `json:"timestamp"`
TimestampStr string `json:"-"`
Time time.Time `json:"-"`
ChargeID *string `json:"charge_id"`
ChargeUpdatedAt *time.Time `json:"charge_updated_at"`
ChargeFilterID *string `json:"charge_filter_id"`
ChargeFilterUpdatedAt *time.Time `json:"charge_filter_updated_at"`
GroupedBy map[string]string `json:"grouped_by"`
}
type Event ¶
type Event struct {
OrganizationID string `json:"organization_id"`
ExternalSubscriptionID string `json:"external_subscription_id"`
TransactionID string `json:"transaction_id"`
Code string `json:"code"`
Properties map[string]any `json:"properties"`
PreciseTotalAmountCents string `json:"precise_total_amount_cents"`
Source string `json:"source,omitempty"`
Timestamp any `json:"timestamp"`
SourceMetadata *SourceMetadata `json:"source_metadata"`
IngestedAt utils.CustomTime `json:"ingested_at"`
}
func (*Event) NotAPIPostProcessed ¶
func (*Event) ToEnrichedEvent ¶
func (ev *Event) ToEnrichedEvent() utils.Result[*EnrichedEvent]
type FailedEvent ¶
type FlagStore ¶
type FlagStore struct {
// contains filtered or unexported fields
}
func NewFlagStore ¶
type FlatFilter ¶
type FlatFilter struct {
OrganizationID string `gorm:"->"`
BillableMetricCode string `gorm:"->"`
PlanID string `gorm:"->"`
ChargeID string `gorm:"->"`
ChargeUpdatedAt time.Time `gorm:"->"`
ChargeFilterID *string `gorm:"->"`
ChargeFilterUpdatedAt *time.Time `gorm:"->"`
Filters *FlatFilterValues `gorm:"type:jsonb"`
PricingGroupKeys PricingGroupKeys `gorm:"type:jsonb"`
PayInAdvance bool `gorm:"type:boolean"`
}
func MatchingFilter ¶
func MatchingFilter(filters []FlatFilter, event *EnrichedEvent) *FlatFilter
func (*FlatFilter) HasFilters ¶
func (ff *FlatFilter) HasFilters() bool
func (*FlatFilter) IsMatchingEvent ¶
func (ff *FlatFilter) IsMatchingEvent(event *EnrichedEvent) utils.Result[bool]
func (*FlatFilter) ToDefaultFilter ¶
func (ff *FlatFilter) ToDefaultFilter() *FlatFilter
type FlatFilterValues ¶
func (*FlatFilterValues) Keys ¶
func (ffv *FlatFilterValues) Keys() []string
func (*FlatFilterValues) Scan ¶
func (fm *FlatFilterValues) Scan(value any) error
Implements the sql.Scanner interface to convert JSONB into FlatFilterValues
type PricingGroupKeys ¶
type PricingGroupKeys []string
func (*PricingGroupKeys) Scan ¶
func (fm *PricingGroupKeys) Scan(value any) error
Implements the sql.Scanner interface to convert JSONB into FlatFilterValues
type SourceMetadata ¶
type SourceMetadata struct {
ApiPostProcess bool `json:"api_post_processed"`
}
Click to show internal directories.
Click to hide internal directories.