export

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigKeyErrorPolicy        = "export.error_policy"
	ConfigKeyRetryAttempts      = "export.retry_attempts"
	ConfigKeyRetryBackoffMS     = "export.retry_backoff_ms"
	ConfigKeySkipEncodingErrors = "export.skip_encoding_errors"
	ConfigKeyWriteManifest      = "export.write_manifest"
	ConfigKeyAutoExportPolicy   = "auto_export.error_policy"
)

Config keys for export error handling

View Source
const (
	DefaultErrorPolicy        = PolicyStrict
	DefaultRetryAttempts      = 3
	DefaultRetryBackoffMS     = 100
	DefaultSkipEncodingErrors = false
	DefaultWriteManifest      = false
	DefaultAutoExportPolicy   = PolicyBestEffort
)

Default values

Variables

This section is empty.

Functions

func RetryWithBackoff

func RetryWithBackoff(ctx context.Context, attempts int, initialBackoffMS int, desc string, fn func() error) error

RetryWithBackoff wraps a function with retry logic

func SetPolicy

func SetPolicy(ctx context.Context, store storage.Storage, policy ErrorPolicy, autoExport bool) error

SetPolicy sets the error policy for exports

func SetRetryAttempts

func SetRetryAttempts(ctx context.Context, store storage.Storage, attempts int) error

SetRetryAttempts sets the number of retry attempts

func SetRetryBackoff

func SetRetryBackoff(ctx context.Context, store storage.Storage, backoffMS int) error

SetRetryBackoff sets the initial retry backoff in milliseconds

func SetSkipEncodingErrors

func SetSkipEncodingErrors(ctx context.Context, store storage.Storage, skip bool) error

SetSkipEncodingErrors sets whether to skip issues with encoding errors

func SetWriteManifest

func SetWriteManifest(ctx context.Context, store storage.Storage, write bool) error

SetWriteManifest sets whether to write export manifests

func WriteManifest

func WriteManifest(jsonlPath string, manifest *Manifest) error

WriteManifest writes an export manifest alongside the JSONL file

Types

type Config

type Config struct {
	Policy             ErrorPolicy
	RetryAttempts      int
	RetryBackoffMS     int
	SkipEncodingErrors bool
	WriteManifest      bool
	IsAutoExport       bool // If true, may use different policy
}

Config holds export error handling configuration

func LoadConfig

func LoadConfig(ctx context.Context, store ConfigStore, isAutoExport bool) (*Config, error)

LoadConfig reads export configuration from storage

type ConfigStore

type ConfigStore interface {
	GetConfig(ctx context.Context, key string) (string, error)
	SetConfig(ctx context.Context, key, value string) error
}

ConfigStore defines the minimal storage interface needed for config

type DataType

type DataType string

DataType represents a type of data being fetched

const (
	DataTypeCore     DataType = "core"     // Issues and dependencies
	DataTypeLabels   DataType = "labels"   // Issue labels
	DataTypeComments DataType = "comments" // Issue comments
)

type ErrorPolicy

type ErrorPolicy string

ErrorPolicy defines how export operations handle errors

const (
	// PolicyStrict fails fast on any error (default for user-initiated exports)
	PolicyStrict ErrorPolicy = "strict"

	// PolicyBestEffort skips failed operations with warnings (good for auto-export)
	PolicyBestEffort ErrorPolicy = "best-effort"

	// PolicyPartial retries transient failures, skips persistent ones with manifest
	PolicyPartial ErrorPolicy = "partial"

	// PolicyRequiredCore fails on core data (issues/deps), skips enrichments (labels/comments)
	PolicyRequiredCore ErrorPolicy = "required-core"
)

func (ErrorPolicy) IsValid

func (p ErrorPolicy) IsValid() bool

IsValid checks if the policy is a valid value

func (ErrorPolicy) String

func (p ErrorPolicy) String() string

String implements fmt.Stringer

type FailedIssue

type FailedIssue struct {
	IssueID     string   `json:"issue_id"`
	Reason      string   `json:"reason"`
	MissingData []string `json:"missing_data,omitempty"` // e.g., ["labels", "comments"]
}

FailedIssue tracks a single issue that failed to export

type FetchResult

type FetchResult struct {
	Success  bool
	Err      error
	Warnings []string
}

FetchResult holds the result of a data fetch operation

func FetchWithPolicy

func FetchWithPolicy(ctx context.Context, cfg *Config, dataType DataType, desc string, fn func() error) FetchResult

FetchWithPolicy executes a fetch operation with the configured error policy

type Manifest

type Manifest struct {
	ExportedCount int           `json:"exported_count"`
	FailedIssues  []FailedIssue `json:"failed_issues,omitempty"`
	PartialData   []string      `json:"partial_data,omitempty"` // e.g., ["labels", "comments"]
	Warnings      []string      `json:"warnings,omitempty"`
	Complete      bool          `json:"complete"`
	ExportedAt    time.Time     `json:"exported_at"`
	ErrorPolicy   string        `json:"error_policy"`
}

Manifest tracks export completeness and failures

func NewManifest

func NewManifest(policy ErrorPolicy) *Manifest

NewManifest creates a new export manifest

Jump to

Keyboard shortcuts

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