Documentation
¶
Overview ¶
Package export defines core interfaces and runner scaffolding for go-export.
Index ¶
- Constants
- func AsGoError(err error) *errorslib.Error
- func DefaultPDFAssetsHost() string
- func PDFAssetsFS() fs.FS
- func RuntimeAssetsFS() fs.FS
- type Actor
- type ActorProvider
- type ArtifactMeta
- type ArtifactRef
- type ArtifactStore
- type ArtifactTracker
- type AugmentTransformer
- type BufferedTransformer
- type BufferedTransformerFactory
- type CSVOptions
- type CSVRenderer
- type CancelHook
- type ChangeEmitter
- type ChangeEvent
- type Column
- type ColumnFormat
- type DefinitionRegistry
- func (r *DefinitionRegistry) Get(name string) (ExportDefinition, bool)
- func (r *DefinitionRegistry) List() []ExportDefinition
- func (r *DefinitionRegistry) Register(def ExportDefinition) error
- func (r *DefinitionRegistry) Resolve(req ExportRequest) (ResolvedDefinition, error)
- func (r *DefinitionRegistry) ResolveByResource(resource string) (ExportDefinition, error)
- type DeleteParams
- type DeleteStrategy
- type DeliveryMode
- type DeliveryPolicy
- type DeliveryThresholds
- type DownloadInfo
- type ErrorKind
- type ExportCounts
- type ExportDefinition
- type ExportError
- type ExportPolicy
- type ExportRecord
- type ExportRequest
- type ExportResult
- type ExportState
- type FilterTransformer
- type Format
- type FormatOptions
- type Guard
- type JSONMode
- type JSONOptions
- type JSONRenderer
- type Logger
- type MapTransformer
- type MemoryStore
- func (s *MemoryStore) Delete(ctx context.Context, key string) error
- func (s *MemoryStore) Open(ctx context.Context, key string) (io.ReadCloser, ArtifactMeta, error)
- func (s *MemoryStore) Put(ctx context.Context, key string, r io.Reader, meta ArtifactMeta) (ArtifactRef, error)
- func (s *MemoryStore) SignedURL(ctx context.Context, key string, ttl time.Duration) (string, error)
- type MemoryTracker
- func (t *MemoryTracker) Advance(ctx context.Context, id string, delta ProgressDelta, meta map[string]any) error
- func (t *MemoryTracker) Complete(ctx context.Context, id string, meta map[string]any) error
- func (t *MemoryTracker) Delete(ctx context.Context, id string) error
- func (t *MemoryTracker) Fail(ctx context.Context, id string, err error, meta map[string]any) error
- func (t *MemoryTracker) List(ctx context.Context, filter ProgressFilter) ([]ExportRecord, error)
- func (t *MemoryTracker) SetArtifact(ctx context.Context, id string, ref ArtifactRef) error
- func (t *MemoryTracker) SetState(ctx context.Context, id string, state ExportState, meta map[string]any) error
- func (t *MemoryTracker) Start(ctx context.Context, record ExportRecord) (string, error)
- func (t *MemoryTracker) Status(ctx context.Context, id string) (ExportRecord, error)
- func (t *MemoryTracker) Update(ctx context.Context, record ExportRecord) error
- type MetricsEvent
- type MetricsHook
- type NopLogger
- type PDFExternalAssetsPolicy
- type PDFOptions
- type ProgressDelta
- type ProgressFilter
- type ProgressTracker
- type QuotaHook
- type RateLimiter
- type RecordDeleter
- type RecordUpdater
- type RenderOptions
- type RenderStats
- type Renderer
- type RendererRegistry
- type ResolvedDefinition
- type ResolvedExport
- type RetentionPolicy
- type RetentionRule
- type RetentionRules
- type RouterRegistrar
- type Row
- type RowAugmentFunc
- type RowFilterFunc
- type RowIterator
- type RowMapFunc
- type RowSource
- type RowSourceFactory
- type RowSourceRegistry
- type RowSourceSpec
- type RowTransformer
- type Runner
- type SQLiteOptions
- type Schema
- type Scope
- type Selection
- type SelectionMode
- type SelectionPolicy
- type SelectionPolicyFunc
- type SelectionQueryRef
- type Service
- type ServiceConfig
- type SoftDeleteStrategy
- type SourceVariant
- type TemplateOptions
- type TemplateStrategy
- type TombstoneDeleteStrategy
- type TransformerConfig
- type TransformerFactory
- type TransformerRegistry
- type XLSXOptions
- type XLSXRenderer
Constants ¶
const (
// DefaultPDFAssetsPath is the local path used to serve embedded PDF preview assets.
DefaultPDFAssetsPath = "/exports/assets/pdf/"
)
Variables ¶
This section is empty.
Functions ¶
func DefaultPDFAssetsHost ¶
func DefaultPDFAssetsHost() string
DefaultPDFAssetsHost returns the default assets host, respecting GO_EXPORT_PDF_ASSETS_CDN if set.
func RuntimeAssetsFS ¶
RuntimeAssetsFS exposes the embedded frontend helpers (datagrid export client).
Typical mount:
mux.Handle("/assets/",
http.StripPrefix("/assets/",
http.FileServer(http.FS(export.RuntimeAssetsFS())),
),
)
Types ¶
type Actor ¶
type Actor struct {
ID string `json:"id"`
Scope Scope `json:"scope"`
Roles []string `json:"roles,omitempty"`
Details map[string]any `json:"details,omitempty"`
}
Actor identifies the requesting principal.
type ActorProvider ¶
ActorProvider extracts the actor from context.
type ArtifactMeta ¶
type ArtifactMeta struct {
ContentType string `json:"content_type,omitempty"`
Size int64 `json:"size,omitempty"`
Filename string `json:"filename,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
}
ArtifactMeta captures stored artifact metadata.
type ArtifactRef ¶
type ArtifactRef struct {
Key string `json:"key"`
Meta ArtifactMeta `json:"meta"`
}
ArtifactRef references a stored artifact.
type ArtifactStore ¶
type ArtifactStore interface {
Put(ctx context.Context, key string, r io.Reader, meta ArtifactMeta) (ArtifactRef, error)
Open(ctx context.Context, key string) (io.ReadCloser, ArtifactMeta, error)
Delete(ctx context.Context, key string) error
SignedURL(ctx context.Context, key string, ttl time.Duration) (string, error)
}
ArtifactStore stores export artifacts.
type ArtifactTracker ¶
type ArtifactTracker interface {
SetArtifact(ctx context.Context, id string, ref ArtifactRef) error
}
ArtifactTracker updates stored artifact metadata.
type AugmentTransformer ¶
type AugmentTransformer struct {
Columns []Column
AugmentFunc RowAugmentFunc
}
AugmentTransformer appends derived columns to each row.
func NewAugmentTransformer ¶
func NewAugmentTransformer(columns []Column, fn RowAugmentFunc) AugmentTransformer
NewAugmentTransformer creates an AugmentTransformer.
func (AugmentTransformer) Wrap ¶
func (t AugmentTransformer) Wrap(ctx context.Context, in RowIterator, schema Schema) (RowIterator, Schema, error)
Wrap implements RowTransformer.
type BufferedTransformer ¶
type BufferedTransformer interface {
Process(ctx context.Context, rows RowIterator, schema Schema) ([]Row, Schema, error)
}
BufferedTransformer collects rows to perform non-streaming transforms.
type BufferedTransformerFactory ¶
type BufferedTransformerFactory func(config TransformerConfig) (BufferedTransformer, error)
BufferedTransformerFactory creates a BufferedTransformer from config.
type CSVOptions ¶
CSVOptions configures CSV output.
type CSVRenderer ¶
type CSVRenderer struct{}
CSVRenderer renders CSV output.
func (CSVRenderer) Render ¶
func (r CSVRenderer) Render(ctx context.Context, schema Schema, rows RowIterator, w io.Writer, opts RenderOptions) (RenderStats, error)
Render streams rows as CSV.
type CancelHook ¶
CancelHook allows adapters to cancel running exports.
type ChangeEmitter ¶
type ChangeEmitter interface {
Emit(ctx context.Context, evt ChangeEvent) error
}
ChangeEmitter emits lifecycle events.
type ChangeEvent ¶
type ChangeEvent struct {
Name string
ExportID string
Definition string
Format Format
Delivery DeliveryMode
Actor Actor
Timestamp time.Time
Metadata map[string]any
}
ChangeEvent describes lifecycle events.
type Column ¶
type Column struct {
Name string
Label string
Type string
Format ColumnFormat
}
Column defines a column in the export schema.
type ColumnFormat ¶
ColumnFormat provides renderer-specific formatting hints.
type DefinitionRegistry ¶
type DefinitionRegistry struct {
// contains filtered or unexported fields
}
DefinitionRegistry stores export definitions.
func NewDefinitionRegistry ¶
func NewDefinitionRegistry() *DefinitionRegistry
NewDefinitionRegistry creates an empty registry.
func (*DefinitionRegistry) Get ¶ added in v0.2.0
func (r *DefinitionRegistry) Get(name string) (ExportDefinition, bool)
Get returns a definition by name.
func (*DefinitionRegistry) List ¶ added in v0.2.0
func (r *DefinitionRegistry) List() []ExportDefinition
List returns all registered definitions in name order.
func (*DefinitionRegistry) Register ¶
func (r *DefinitionRegistry) Register(def ExportDefinition) error
Register adds a definition.
func (*DefinitionRegistry) Resolve ¶
func (r *DefinitionRegistry) Resolve(req ExportRequest) (ResolvedDefinition, error)
Resolve returns a resolved definition for the request.
func (*DefinitionRegistry) ResolveByResource ¶
func (r *DefinitionRegistry) ResolveByResource(resource string) (ExportDefinition, error)
ResolveByResource finds a definition by resource name.
type DeleteParams ¶
type DeleteParams struct {
Record ExportRecord
Tracker ProgressTracker
Store ArtifactStore
Now time.Time
}
DeleteParams provides dependencies to delete strategies.
type DeleteStrategy ¶
type DeleteStrategy interface {
Delete(ctx context.Context, params DeleteParams) error
}
DeleteStrategy defines how delete requests are handled.
type DeliveryMode ¶
type DeliveryMode string
DeliveryMode describes how exports are delivered.
const ( DeliverySync DeliveryMode = "sync" DeliveryAsync DeliveryMode = "async" DeliveryAuto DeliveryMode = "auto" )
func SelectDelivery ¶
func SelectDelivery(req ExportRequest, def ResolvedDefinition, policy DeliveryPolicy) DeliveryMode
SelectDelivery determines the final delivery mode.
type DeliveryPolicy ¶
type DeliveryPolicy struct {
Default DeliveryMode
Thresholds DeliveryThresholds
}
DeliveryPolicy configures delivery selection thresholds.
type DeliveryThresholds ¶
DeliveryThresholds drive auto delivery decisions.
type DownloadInfo ¶
type DownloadInfo struct {
ExportID string
Artifact ArtifactRef
}
DownloadInfo describes downloadable export metadata.
type ErrorKind ¶
type ErrorKind string
ErrorKind defines export error kinds.
const ( KindValidation ErrorKind = "validation" KindAuthz ErrorKind = "authz" KindNotFound ErrorKind = "not_found" KindTimeout ErrorKind = "timeout" KindCanceled ErrorKind = "canceled" KindExternal ErrorKind = "external" KindInternal ErrorKind = "internal" KindNotImpl ErrorKind = "not_implemented" )
func KindFromError ¶
KindFromError maps an error to its export error kind.
type ExportCounts ¶
type ExportCounts struct {
Processed int64 `json:"processed,omitempty"`
Total int64 `json:"total,omitempty"`
Errors int64 `json:"errors,omitempty"`
}
ExportCounts tracks row counts.
type ExportDefinition ¶
type ExportDefinition struct {
Name string
Resource string
Schema Schema
AllowedFormats []Format
DefaultFilename string
RowSourceKey string
Transformers []TransformerConfig
DefaultSelection Selection
SelectionPolicy SelectionPolicy
SourceVariants map[string]SourceVariant
Policy ExportPolicy
DeliveryPolicy *DeliveryPolicy
Template TemplateOptions
}
ExportDefinition declares an exportable dataset.
type ExportError ¶
ExportError wraps errors with a kind.
func NewError ¶
func NewError(kind ErrorKind, msg string, err error) *ExportError
NewError creates a new export error.
func (*ExportError) Error ¶
func (e *ExportError) Error() string
func (*ExportError) Unwrap ¶
func (e *ExportError) Unwrap() error
type ExportPolicy ¶
type ExportPolicy struct {
AllowedColumns []string
RedactColumns []string
RedactionValue any
MaxRows int
MaxBytes int64
MaxDuration time.Duration
}
ExportPolicy enforces export limits and redaction.
type ExportRecord ¶
type ExportRecord struct {
ID string `json:"id"`
Definition string `json:"definition"`
Format Format `json:"format"`
State ExportState `json:"state"`
RequestedBy Actor `json:"requested_by"`
Scope Scope `json:"scope"`
Request ExportRequest `json:"-"`
Counts ExportCounts `json:"counts"`
BytesWritten int64 `json:"bytes_written,omitempty"`
Artifact ArtifactRef `json:"artifact"`
CreatedAt time.Time `json:"created_at"`
StartedAt time.Time `json:"started_at,omitempty"`
CompletedAt time.Time `json:"completed_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
}
ExportRecord captures tracker state for an export.
type ExportRequest ¶
type ExportRequest struct {
Definition string
Resource string
SourceVariant string
Format Format
Query any
Selection Selection
Columns []string
Locale string
Timezone string
Delivery DeliveryMode
IdempotencyKey string
EstimatedRows int
EstimatedBytes int64
EstimatedDuration time.Duration
Output io.Writer
RenderOptions RenderOptions
}
ExportRequest captures an export request.
type ExportResult ¶
type ExportResult struct {
ID string `json:"id"`
Delivery DeliveryMode `json:"delivery"`
Format Format `json:"format"`
Rows int64 `json:"rows"`
Bytes int64 `json:"bytes"`
Filename string `json:"filename"`
Artifact *ArtifactRef `json:"artifact,omitempty"`
}
ExportResult captures a completed export.
type ExportState ¶
type ExportState string
ExportState captures progress states.
const ( StateQueued ExportState = "queued" StateRunning ExportState = "running" StatePublishing ExportState = "publishing" StateCompleted ExportState = "completed" StateFailed ExportState = "failed" StateCanceled ExportState = "canceled" StateDeleted ExportState = "deleted" )
type FilterTransformer ¶
type FilterTransformer struct {
FilterFunc RowFilterFunc
}
FilterTransformer drops rows that do not pass the filter.
func NewFilterTransformer ¶
func NewFilterTransformer(fn RowFilterFunc) FilterTransformer
NewFilterTransformer creates a FilterTransformer.
func (FilterTransformer) Wrap ¶
func (t FilterTransformer) Wrap(ctx context.Context, in RowIterator, schema Schema) (RowIterator, Schema, error)
Wrap implements RowTransformer.
type Format ¶
type Format string
Format is the export output format.
func NormalizeFormat ¶
NormalizeFormat coerces format values into known aliases with defaults applied.
type FormatOptions ¶
FormatOptions configures locale/timezone formatting.
type Guard ¶
type Guard interface {
AuthorizeExport(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) error
AuthorizeDownload(ctx context.Context, actor Actor, exportID string) error
}
Guard enforces authorization.
type JSONRenderer ¶
type JSONRenderer struct{}
JSONRenderer renders JSON output.
func (JSONRenderer) Render ¶
func (r JSONRenderer) Render(ctx context.Context, schema Schema, rows RowIterator, w io.Writer, opts RenderOptions) (RenderStats, error)
Render streams rows as JSON array or NDJSON.
type Logger ¶
type Logger interface {
Debugf(format string, args ...any)
Infof(format string, args ...any)
Errorf(format string, args ...any)
}
Logger provides logging hooks.
type MapTransformer ¶
type MapTransformer struct {
MapFunc RowMapFunc
}
MapTransformer applies a mapping function to each row.
func NewMapTransformer ¶
func NewMapTransformer(fn RowMapFunc) MapTransformer
NewMapTransformer creates a MapTransformer.
func (MapTransformer) Wrap ¶
func (t MapTransformer) Wrap(ctx context.Context, in RowIterator, schema Schema) (RowIterator, Schema, error)
Wrap implements RowTransformer.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore stores artifacts in memory (test/dev only).
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore creates an in-memory artifact store.
func (*MemoryStore) Delete ¶
func (s *MemoryStore) Delete(ctx context.Context, key string) error
Delete removes an artifact.
func (*MemoryStore) Open ¶
func (s *MemoryStore) Open(ctx context.Context, key string) (io.ReadCloser, ArtifactMeta, error)
Open reads an artifact.
func (*MemoryStore) Put ¶
func (s *MemoryStore) Put(ctx context.Context, key string, r io.Reader, meta ArtifactMeta) (ArtifactRef, error)
Put stores an artifact.
type MemoryTracker ¶
type MemoryTracker struct {
// contains filtered or unexported fields
}
MemoryTracker stores progress in memory (test/dev only).
func NewMemoryTracker ¶
func NewMemoryTracker() *MemoryTracker
NewMemoryTracker creates an in-memory tracker.
func (*MemoryTracker) Advance ¶
func (t *MemoryTracker) Advance(ctx context.Context, id string, delta ProgressDelta, meta map[string]any) error
Advance updates counts.
func (*MemoryTracker) Delete ¶
func (t *MemoryTracker) Delete(ctx context.Context, id string) error
Delete removes a record from the tracker.
func (*MemoryTracker) List ¶
func (t *MemoryTracker) List(ctx context.Context, filter ProgressFilter) ([]ExportRecord, error)
List returns records matching a filter.
func (*MemoryTracker) SetArtifact ¶
func (t *MemoryTracker) SetArtifact(ctx context.Context, id string, ref ArtifactRef) error
SetArtifact updates the artifact metadata for a record.
func (*MemoryTracker) SetState ¶
func (t *MemoryTracker) SetState(ctx context.Context, id string, state ExportState, meta map[string]any) error
SetState updates the record state.
func (*MemoryTracker) Start ¶
func (t *MemoryTracker) Start(ctx context.Context, record ExportRecord) (string, error)
Start creates a new record.
func (*MemoryTracker) Status ¶
func (t *MemoryTracker) Status(ctx context.Context, id string) (ExportRecord, error)
Status returns a record by ID.
func (*MemoryTracker) Update ¶
func (t *MemoryTracker) Update(ctx context.Context, record ExportRecord) error
Update replaces a record by ID.
type MetricsEvent ¶
type MetricsEvent struct {
Name string
ExportID string
Definition string
Format Format
Delivery DeliveryMode
Actor Actor
Rows int64
Bytes int64
Duration time.Duration
ErrorKind ErrorKind
Timestamp time.Time
}
MetricsEvent describes lifecycle metrics.
type MetricsHook ¶
type MetricsHook interface {
Emit(ctx context.Context, evt MetricsEvent) error
}
MetricsHook emits metrics-friendly lifecycle observations.
type PDFExternalAssetsPolicy ¶
type PDFExternalAssetsPolicy string
PDFExternalAssetsPolicy controls how external assets are handled in PDF rendering.
const ( PDFExternalAssetsUnspecified PDFExternalAssetsPolicy = "" PDFExternalAssetsAllow PDFExternalAssetsPolicy = "allow" PDFExternalAssetsBlock PDFExternalAssetsPolicy = "block" )
type PDFOptions ¶
type PDFOptions struct {
PageSize string
Landscape *bool
PrintBackground *bool
Scale float64
MarginTop string
MarginBottom string
MarginLeft string
MarginRight string
PreferCSSPageSize *bool
BaseURL string
ExternalAssetsPolicy PDFExternalAssetsPolicy
}
PDFOptions configures PDF output for headless engines.
type ProgressDelta ¶
ProgressDelta indicates progress changes.
type ProgressFilter ¶
ProgressFilter filters tracker lists.
type ProgressTracker ¶
type ProgressTracker interface {
Start(ctx context.Context, record ExportRecord) (string, error)
Advance(ctx context.Context, id string, delta ProgressDelta, meta map[string]any) error
SetState(ctx context.Context, id string, state ExportState, meta map[string]any) error
Fail(ctx context.Context, id string, err error, meta map[string]any) error
Complete(ctx context.Context, id string, meta map[string]any) error
Status(ctx context.Context, id string) (ExportRecord, error)
List(ctx context.Context, filter ProgressFilter) ([]ExportRecord, error)
}
ProgressTracker tracks export progress.
type QuotaHook ¶
type QuotaHook interface {
Allow(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) error
}
QuotaHook enforces limits beyond per-definition policy.
type RateLimiter ¶
type RateLimiter struct {
Max int
Window time.Duration
KeyFunc func(actor Actor, req ExportRequest, def ResolvedDefinition) string
Now func() time.Time
// contains filtered or unexported fields
}
RateLimiter enforces per-actor rate limits in memory.
func (*RateLimiter) Allow ¶
func (l *RateLimiter) Allow(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) error
Allow enforces the configured rate limit, keyed by actor/scope unless overridden.
type RecordDeleter ¶
RecordDeleter removes records from the tracker.
type RecordUpdater ¶
type RecordUpdater interface {
Update(ctx context.Context, record ExportRecord) error
}
RecordUpdater updates records outside state transitions.
type RenderOptions ¶
type RenderOptions struct {
CSV CSVOptions
JSON JSONOptions
Template TemplateOptions
XLSX XLSXOptions
SQLite SQLiteOptions
PDF PDFOptions
Format FormatOptions
}
RenderOptions configures renderer behavior.
type RenderStats ¶
RenderStats capture renderer output.
type Renderer ¶
type Renderer interface {
Render(ctx context.Context, schema Schema, rows RowIterator, w io.Writer, opts RenderOptions) (RenderStats, error)
}
Renderer writes rows to the destination.
type RendererRegistry ¶
type RendererRegistry struct {
// contains filtered or unexported fields
}
RendererRegistry stores renderers by format.
func NewRendererRegistry ¶
func NewRendererRegistry() *RendererRegistry
NewRendererRegistry creates a registry.
type ResolvedDefinition ¶
type ResolvedDefinition struct {
ExportDefinition
Variant string
}
ResolvedDefinition is a definition with variant overrides applied.
type ResolvedExport ¶
type ResolvedExport struct {
Request ExportRequest
Definition ResolvedDefinition
Columns []Column
ColumnNames []string
RedactIndices map[int]any
Filename string
}
ResolvedExport contains validated inputs for a run.
func ResolveExport ¶
func ResolveExport(req ExportRequest, def ResolvedDefinition, now time.Time) (ResolvedExport, error)
ResolveExport validates and resolves a request against a definition.
type RetentionPolicy ¶
type RetentionPolicy interface {
TTL(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) (time.Duration, error)
}
RetentionPolicy decides artifact TTLs.
type RetentionRule ¶
RetentionRule defines a TTL override for matching exports.
type RetentionRules ¶
type RetentionRules struct {
DefaultTTL time.Duration
ByDefinition map[string]time.Duration
ByFormat map[Format]time.Duration
ByRole map[string]time.Duration
Rules []RetentionRule
RoleResolver func(actor Actor) []string
}
RetentionRules configures TTL lookups for exports.
func (RetentionRules) TTL ¶
func (r RetentionRules) TTL(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) (time.Duration, error)
TTL returns a TTL for the provided request.
type RouterRegistrar ¶
type RouterRegistrar interface {
RegisterRoutes(router any)
}
RouterRegistrar provides optional route registration.
type RowAugmentFunc ¶
RowAugmentFunc returns additional values to append to a row.
type RowFilterFunc ¶
RowFilterFunc decides whether a row should be kept.
type RowIterator ¶
RowIterator streams rows.
type RowMapFunc ¶
RowMapFunc maps a row to a new row.
type RowSource ¶
type RowSource interface {
Open(ctx context.Context, spec RowSourceSpec) (RowIterator, error)
}
RowSource provides row iterators for exports.
type RowSourceFactory ¶
type RowSourceFactory func(req ExportRequest, def ResolvedDefinition) (RowSource, error)
RowSourceFactory creates a RowSource for a request.
type RowSourceRegistry ¶
type RowSourceRegistry struct {
// contains filtered or unexported fields
}
RowSourceRegistry stores row source factories.
func NewRowSourceRegistry ¶
func NewRowSourceRegistry() *RowSourceRegistry
NewRowSourceRegistry creates an empty registry.
func (*RowSourceRegistry) Register ¶
func (r *RowSourceRegistry) Register(key string, factory RowSourceFactory) error
Register adds a row source factory.
func (*RowSourceRegistry) Resolve ¶
func (r *RowSourceRegistry) Resolve(key string) (RowSourceFactory, bool)
Resolve finds a row source factory by key.
type RowSourceSpec ¶
type RowSourceSpec struct {
Definition ResolvedDefinition
Request ExportRequest
Columns []Column
Actor Actor
}
RowSourceSpec is passed to RowSource.Open.
type RowTransformer ¶
type RowTransformer interface {
Wrap(ctx context.Context, in RowIterator, schema Schema) (RowIterator, Schema, error)
}
RowTransformer wraps an iterator with row-level transformations.
type Runner ¶
type Runner struct {
Definitions *DefinitionRegistry
RowSources *RowSourceRegistry
Renderers *RendererRegistry
Transformers *TransformerRegistry
Tracker ProgressTracker
Store ArtifactStore
Guard Guard
ActorProvider ActorProvider
Logger Logger
Emitter ChangeEmitter
Metrics MetricsHook
QuotaHook QuotaHook
Retention RetentionPolicy
DeliveryPolicy DeliveryPolicy
Now func() time.Time
IDGenerator func() string
}
Runner orchestrates export execution.
func (*Runner) Run ¶
func (r *Runner) Run(ctx context.Context, req ExportRequest) (ExportResult, error)
Run executes an export request.
type SQLiteOptions ¶ added in v0.6.0
type SQLiteOptions struct {
TableName string
}
SQLiteOptions configures SQLite output.
type Scope ¶
type Scope struct {
TenantID string `json:"tenant_id,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
}
Scope identifies tenant/workspace scope.
type Selection ¶
type Selection struct {
Mode SelectionMode
IDs []string
Query SelectionQueryRef
}
Selection captures row selection intent.
type SelectionMode ¶
type SelectionMode string
SelectionMode describes how rows are selected.
const ( SelectionAll SelectionMode = "all" SelectionIDs SelectionMode = "ids" SelectionQuery SelectionMode = "query" )
type SelectionPolicy ¶
type SelectionPolicy interface {
DefaultSelection(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) (Selection, bool, error)
}
SelectionPolicy supplies default selections for requests without one.
type SelectionPolicyFunc ¶
type SelectionPolicyFunc func(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) (Selection, bool, error)
SelectionPolicyFunc adapts a function to a SelectionPolicy.
func (SelectionPolicyFunc) DefaultSelection ¶
func (f SelectionPolicyFunc) DefaultSelection(ctx context.Context, actor Actor, req ExportRequest, def ResolvedDefinition) (Selection, bool, error)
type SelectionQueryRef ¶
SelectionQueryRef references a named selection query plus optional params.
type Service ¶
type Service interface {
RequestExport(ctx context.Context, actor Actor, req ExportRequest) (ExportRecord, error)
GenerateExport(ctx context.Context, actor Actor, exportID string, req ExportRequest) (ExportResult, error)
CancelExport(ctx context.Context, actor Actor, exportID string) (ExportRecord, error)
DeleteExport(ctx context.Context, actor Actor, exportID string) error
Status(ctx context.Context, actor Actor, exportID string) (ExportRecord, error)
History(ctx context.Context, actor Actor, filter ProgressFilter) ([]ExportRecord, error)
DownloadMetadata(ctx context.Context, actor Actor, exportID string) (DownloadInfo, error)
Cleanup(ctx context.Context, now time.Time) (int, error)
}
Service coordinates export operations across runner, guard, tracker, and store.
func NewService ¶
func NewService(cfg ServiceConfig) Service
NewService creates a Service with the provided configuration.
type ServiceConfig ¶
type ServiceConfig struct {
Runner *Runner
Tracker ProgressTracker
Store ArtifactStore
Guard Guard
DeliveryPolicy DeliveryPolicy
DeleteStrategy DeleteStrategy
CancelHook CancelHook
Now func() time.Time
IDGenerator func() string
}
ServiceConfig supplies dependencies for Service.
type SoftDeleteStrategy ¶
type SoftDeleteStrategy struct{}
SoftDeleteStrategy deletes artifacts and tombstones the record.
func (SoftDeleteStrategy) Delete ¶
func (SoftDeleteStrategy) Delete(ctx context.Context, params DeleteParams) error
type SourceVariant ¶
type SourceVariant struct {
RowSourceKey string
AllowedFormats []Format
DefaultFilename string
Transformers []TransformerConfig
Policy *ExportPolicy
Template *TemplateOptions
}
SourceVariant allows alternate sources and policy overrides.
type TemplateOptions ¶
type TemplateOptions struct {
Strategy TemplateStrategy
MaxRows int
TemplateName string
Layout string
Title string
Definition string
GeneratedAt time.Time
ChartConfig any
Theme map[string]any
Header map[string]any
Data map[string]any
}
TemplateOptions configures template rendering.
type TemplateStrategy ¶
type TemplateStrategy string
TemplateStrategy selects template rendering behavior.
const ( TemplateStrategyBuffered TemplateStrategy = "buffered" TemplateStrategyStreaming TemplateStrategy = "streaming" )
type TombstoneDeleteStrategy ¶
TombstoneDeleteStrategy marks records deleted and purges them after TTL.
func (TombstoneDeleteStrategy) Delete ¶
func (s TombstoneDeleteStrategy) Delete(ctx context.Context, params DeleteParams) error
type TransformerConfig ¶
type TransformerConfig struct {
Key string `json:"key"`
Params map[string]any `json:"params,omitempty"`
}
TransformerConfig identifies a configured transformer in a pipeline.
type TransformerFactory ¶
type TransformerFactory func(config TransformerConfig) (RowTransformer, error)
TransformerFactory creates a RowTransformer from config.
type TransformerRegistry ¶
type TransformerRegistry struct {
// contains filtered or unexported fields
}
TransformerRegistry stores transformers by key.
func NewTransformerRegistry ¶
func NewTransformerRegistry() *TransformerRegistry
NewTransformerRegistry creates a registry.
func (*TransformerRegistry) Register ¶
func (r *TransformerRegistry) Register(key string, factory TransformerFactory) error
Register adds a streaming transformer factory.
func (*TransformerRegistry) RegisterBuffered ¶
func (r *TransformerRegistry) RegisterBuffered(key string, factory BufferedTransformerFactory) error
RegisterBuffered adds a buffered transformer factory.
func (*TransformerRegistry) Resolve ¶
func (r *TransformerRegistry) Resolve(key string) (transformerFactory, bool)
Resolve finds a transformer factory by key.
type XLSXOptions ¶
type XLSXOptions struct {
IncludeHeaders bool
HeadersSet bool
SheetName string
MaxRows int
MaxBytes int64
}
XLSXOptions configures XLSX output.
type XLSXRenderer ¶
type XLSXRenderer struct{}
XLSXRenderer renders XLSX output.
func (XLSXRenderer) Render ¶
func (r XLSXRenderer) Render(ctx context.Context, schema Schema, rows RowIterator, w io.Writer, opts RenderOptions) (RenderStats, error)
Render streams rows into an XLSX workbook.
Source Files
¶
- delivery.go
- doc.go
- errors.go
- filename.go
- format.go
- format_context.go
- format_helpers.go
- memory.go
- pdf_assets.go
- quota.go
- registry.go
- render_csv.go
- render_helpers.go
- render_json.go
- render_xlsx.go
- request_record.go
- retention.go
- runner.go
- runtime_assets.go
- selection_policy.go
- service.go
- template_options.go
- transform.go
- transform_runner.go
- types.go
- validation.go