fix(growth): harden AI jobs and cost controls
This commit is contained in:
@@ -23,22 +23,33 @@ import (
|
||||
|
||||
const maxExportBytes = 50 << 20
|
||||
|
||||
const (
|
||||
defaultGrowthSSECapacity = 64
|
||||
defaultGrowthSSEMaxDuration = 5 * time.Minute
|
||||
defaultGrowthSSEPollInterval = 2 * time.Second
|
||||
)
|
||||
|
||||
var defaultGrowthSSESlots = make(chan struct{}, defaultGrowthSSECapacity)
|
||||
|
||||
var errExportBytesExceeded = errors.New("export exceeds byte limit")
|
||||
|
||||
type Server struct {
|
||||
identity *identity.Service
|
||||
analytics *analytics.Service
|
||||
growth growthReportService
|
||||
logger *slog.Logger
|
||||
frontendOrigin string
|
||||
cookieSecure bool
|
||||
identity *identity.Service
|
||||
analytics *analytics.Service
|
||||
growth growthReportService
|
||||
logger *slog.Logger
|
||||
frontendOrigin string
|
||||
cookieSecure bool
|
||||
growthSSESlots chan struct{}
|
||||
growthSSEMaxDuration time.Duration
|
||||
growthSSEPollInterval time.Duration
|
||||
}
|
||||
|
||||
type sessionKey struct{}
|
||||
type tokenKey struct{}
|
||||
|
||||
func NewServer(identityService *identity.Service, analyticsService *analytics.Service, logger *slog.Logger, frontendOrigin string, cookieSecure bool, growthService ...growthReportService) *Server {
|
||||
server := &Server{identity: identityService, analytics: analyticsService, logger: logger, frontendOrigin: frontendOrigin, cookieSecure: cookieSecure}
|
||||
server := &Server{identity: identityService, analytics: analyticsService, logger: logger, frontendOrigin: frontendOrigin, cookieSecure: cookieSecure, growthSSESlots: defaultGrowthSSESlots, growthSSEMaxDuration: defaultGrowthSSEMaxDuration, growthSSEPollInterval: defaultGrowthSSEPollInterval}
|
||||
if len(growthService) > 0 {
|
||||
server.growth = growthService[0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user