log_export

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEnterpriseFeature is returned when attempting to use log export in community edition
	ErrEnterpriseFeature = errors.New("proxy log export is an Enterprise Edition feature - visit https://tyk.io/ai-studio/pricing for more information")

	// ErrExportNotFound is returned when an export record doesn't exist
	ErrExportNotFound = errors.New("export not found")

	// ErrExportNotReady is returned when trying to download an incomplete export
	ErrExportNotReady = errors.New("export is not ready for download")

	// ErrExportExpired is returned when trying to download an expired export
	ErrExportExpired = errors.New("export has expired")

	// ErrUnauthorized is returned when user lacks permission
	ErrUnauthorized = errors.New("unauthorized access to export")
)

Error definitions for log export service

Functions

func IsEnterpriseAvailable

func IsEnterpriseAvailable() bool

IsEnterpriseAvailable returns true if enterprise features are available. Used by edition detection API and feature gating.

func RegisterEnterpriseFactory

func RegisterEnterpriseFactory(f FactoryFunc)

RegisterEnterpriseFactory allows the enterprise implementation to register itself. This is called from the enterprise submodule's init() function.

Types

type ExportRequest

type ExportRequest struct {
	SourceType   models.ExportSourceType
	SourceID     uint
	StartDate    time.Time
	EndDate      time.Time
	SearchFilter string
	RequestedBy  uint // Admin user ID
}

ExportRequest contains parameters for initiating a proxy log export

type FactoryFunc

type FactoryFunc func(db *gorm.DB, notificationSvc NotificationService, storagePath, siteURL string) Service

FactoryFunc is a function type that creates a log export service instance. Enterprise code registers its factory via init() function.

type NotificationService

type NotificationService interface{}

NotificationService is the interface we need from services package. This avoids import cycle between services and services/log_export.

type Service

type Service interface {
	// StartExport initiates a new export job (returns immediately, processes in background)
	// CE: Returns enterprise feature error
	// ENT: Creates job, starts background goroutine, returns job ID
	StartExport(ctx context.Context, req *ExportRequest) (*models.ProxyLogExport, error)

	// GetExport retrieves export job status by export ID
	GetExport(ctx context.Context, exportID string) (*models.ProxyLogExport, error)

	// GetDownloadPath returns file path if export is ready and not expired
	// Validates admin access and expiration
	GetDownloadPath(ctx context.Context, exportID string, userID uint) (string, error)

	// CleanupExpired removes expired export files and marks records as expired
	// Called periodically by cleanup routine
	CleanupExpired(ctx context.Context) error

	// Stop gracefully shuts down the service (stops cleanup goroutine)
	Stop()

	// IsEnterpriseAvailable returns whether enterprise features are available
	IsEnterpriseAvailable() bool
}

Service defines the interface for proxy log export functionality. This is an Enterprise Edition feature - community edition returns errors.

func NewService

func NewService(db *gorm.DB, notificationSvc NotificationService, storagePath, siteURL string) Service

NewService creates a new log export service instance. Returns enterprise implementation if available (when built with -tags enterprise), otherwise returns community edition stub.

Jump to

Keyboard shortcuts

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