internal

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NUM_EVENTS       = 10000
	BATCH_SIZE       = 100 // Reduced batch size
	REQUESTS_PER_SEC = 50  // Rate limit: requests per second
	MAX_RETRIES      = 1   // Maximum number of retries for failed requests
	INITIAL_BACKOFF  = 100 // Initial backoff in milliseconds
	API_ENDPOINT     = "https://api.cloud.flexprice.io/v1/events"
	TIMEOUT_SECONDS  = 5
)

Variables

This section is empty.

Functions

func AssignTenantToUser

func AssignTenantToUser() error

AssignTenantToUser assigns a tenant to a user

func GenerateNewAPIKey

func GenerateNewAPIKey() error

GenerateNewAPIKey generates a new API key

func ImportPricing added in v1.0.17

func ImportPricing() error

ImportPricing is the main function to import pricing data from a CSV file

func MigrateEnvironments

func MigrateEnvironments() error

MigrateEnvironments is the main function that migrates all entities to use environment_id

func OnboardNewTenant

func OnboardNewTenant() error

func ReprocessEvents added in v1.0.17

func ReprocessEvents() error

ReprocessEvents triggers reprocessing of events

func SeedEventsClickhouse

func SeedEventsClickhouse() error

SeedEventsClickhouse seeds events data into Clickhouse

func SeedEventsFromMeters

func SeedEventsFromMeters() error

SeedEventsFromMeters seeds events data based on existing meters

func SyncBillingCustomers added in v1.0.13

func SyncBillingCustomers() error

func SyncPlanPrices added in v1.0.17

func SyncPlanPrices() error

SyncPlanPrices synchronizes all prices from a plan to subscriptions

func TestKafkaConnection

func TestKafkaConnection(brokers []string, username, password string) error

Types

type BatchResult

type BatchResult struct {
	BatchNumber int
	LastEventID string
	StartTime   time.Time
	EndTime     time.Time
	EventCount  int
}

type EventGenerator

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

EventGenerator holds the configuration for generating events

func NewEventGenerator

func NewEventGenerator(meters []*meter.Meter, customers []*customer.Customer, logger *logger.Logger) *EventGenerator

NewEventGenerator creates a new event generator with the given meters

type MeterType

type MeterType struct {
	Code        string
	MinValue    int64
	MaxValue    int64
	Description string
}

MeterType represents different types of billable metrics

type PricingImportSummary added in v1.0.17

type PricingImportSummary struct {
	TotalRows       int
	MetersUpdated   int
	MetersDeleted   int
	FeaturesUpdated int
	FeaturesDeleted int
	PricesCreated   int
	PricesUpdated   int
	PricesDeleted   int
	Errors          []string
}

PricingImportSummary contains statistics about the import process

type PricingRow added in v1.0.17

type PricingRow struct {
	FeatureName  string  `json:"feature_name" csv:"feature_name"`
	EventName    string  `json:"event_name" csv:"event_name"`
	Aggregation  string  `json:"aggregation" csv:"aggregation"`
	Filters      string  `json:"filters" csv:"filters"`
	PerUnitPrice float64 `json:"per_unit_price" csv:"per_unit_price"`
	PlanName     string  `json:"plan_name" csv:"plan_name"`
	FeatureID    string  `json:"feature_id" csv:"feature_id"`
	MeterID      string  `json:"meter_id" csv:"meter_id"`
	PriceID      string  `json:"price_id" csv:"price_id"`
	PlanID       string  `json:"plan_id" csv:"plan_id"`
	Delete       string  `json:"delete" csv:"delete"`
}

PricingRow represents a row in the pricing CSV file

type ReprocessEventsScript added in v1.0.17

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

ReprocessEventsScript holds all dependencies for the script

Jump to

Keyboard shortcuts

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