internal

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: AGPL-3.0 Imports: 47 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 AddNewUserToTenant added in v1.0.18

func AddNewUserToTenant() error

func AssignPlanToCustomers added in v1.0.18

func AssignPlanToCustomers() error

AssignPlanToCustomers assigns a specific plan to customers who don't already have a subscription for it

func AssignTenantToUser

func AssignTenantToUser() error

AssignTenantToUser assigns a tenant to a user

func BulkReprocessEvents added in v1.0.18

func BulkReprocessEvents(params BulkReprocessEventsParams) error

BulkReprocessEvents pulls all customers and triggers reprocessing for their active subscriptions

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 MigrateInvoiceSequences added in v1.0.21

func MigrateInvoiceSequences() error

func OnboardNewTenant

func OnboardNewTenant() error

func ReprocessEvents added in v1.0.17

func ReprocessEvents(params ReprocessEventsScriptParams) error

ReprocessEvents triggers reprocessing of events with given parameters

func ReprocessEventsFromEnv added in v1.0.18

func ReprocessEventsFromEnv() error

ReprocessEventsFromEnv triggers reprocessing of events using environment variables (for backwards compatibility)

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 using the plan service

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 BulkReprocessEventsParams added in v1.0.18

type BulkReprocessEventsParams struct {
	TenantID      string
	EnvironmentID string
	EventName     string
	BatchSize     int
}

BulkReprocessEventsParams holds parameters for bulk reprocessing events

type BulkReprocessEventsScript added in v1.0.18

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

BulkReprocessEventsScript holds all dependencies for the script

type DryRunResult added in v1.0.21

type DryRunResult struct {
	TenantID      string `json:"tenant_id"`
	Environment   string `json:"environment_id"`
	LastValue     int64  `json:"last_value"`
	YearMonth     string `json:"year_month"`
	WouldCreate   bool   `json:"would_create"`
	AlreadyExists bool   `json:"already_exists"`
}

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

type ReprocessEventsScriptParams added in v1.0.18

type ReprocessEventsScriptParams struct {
	TenantID           string
	EnvironmentID      string
	ExternalCustomerID string
	EventName          string
	StartTime          time.Time
	EndTime            time.Time
	BatchSize          int
}

ReprocessEventsScriptParams holds all parameters for the reprocess events script

Jump to

Keyboard shortcuts

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