monitor

package
v0.0.0-...-0ad7e56 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineErrors

func CombineErrors(errors []error) error

CombineErrors combines multiple errors into a single error

func IsRecoverable

func IsRecoverable(err error) bool

IsRecoverable checks if an error is recoverable

func IsTemporaryError

func IsTemporaryError(err error) bool

IsTemporaryError checks if an error is temporary and might resolve on its own

func WrapError

func WrapError(err error, message string) error

WrapError wraps an error with additional context

func WrapNonRetryableError

func WrapNonRetryableError(err error) error

WrapNonRetryableError wraps an error as non-retryable

func WrapRetryableError

func WrapRetryableError(err error, isRateLimit bool, retryAfter time.Duration) error

WrapRetryableError wraps an error as retryable

Types

type ComparisonResult

type ComparisonResult struct {
	Added   []storage.Repository `json:"added"`
	Removed []storage.Repository `json:"removed"`
	Updated []RepositoryUpdate   `json:"updated"`
}

ComparisonResult contains the results of comparing two repository sets

func (*ComparisonResult) Summary

func (r *ComparisonResult) Summary() string

Summary returns a summary of the comparison results

type Differ

type Differ struct{}

Differ provides repository comparison functionality

func NewDiffer

func NewDiffer() *Differ

NewDiffer creates a new repository differ

func (*Differ) CompareRepositories

func (d *Differ) CompareRepositories(previous, current []storage.Repository) *ComparisonResult

CompareRepositories compares two sets of repositories and returns the differences

func (*Differ) FilterNewRepositories

func (d *Differ) FilterNewRepositories(repositories []storage.Repository, since time.Time) []storage.Repository

FilterNewRepositories filters repositories to show only newly starred ones

type ErrorHandler

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

ErrorHandler provides centralized error handling for monitoring operations

func NewErrorHandler

func NewErrorHandler() *ErrorHandler

NewErrorHandler creates a new error handler

func (*ErrorHandler) FormatUserFriendlyError

func (eh *ErrorHandler) FormatUserFriendlyError(err error) string

FormatUserFriendlyError formats an error for user display

func (*ErrorHandler) HandleError

func (eh *ErrorHandler) HandleError(err error, context string) *MonitorError

HandleError processes an error and returns an appropriate MonitorError

func (*ErrorHandler) NewMonitorError

func (eh *ErrorHandler) NewMonitorError(errorType ErrorType, message string, cause error) *MonitorError

NewMonitorError creates a new monitor error

func (*ErrorHandler) RetryWithBackoff

func (eh *ErrorHandler) RetryWithBackoff(ctx context.Context, operation func() error) error

RetryWithBackoff executes an operation with retry logic

type ErrorType

type ErrorType int

ErrorType represents different types of errors that can occur

const (
	ErrorTypeUnknown ErrorType = iota
	ErrorTypeAuth
	ErrorTypeRateLimit
	ErrorTypeNetwork
	ErrorTypeUser
	ErrorTypeStorage
	ErrorTypeValidation
	ErrorTypeAPI
)

type HTTPError

type HTTPError struct {
	StatusCode int
	Status     string
	Body       string
	URL        string
}

HTTPError represents an HTTP-related error

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error implements the error interface

type MonitorError

type MonitorError struct {
	Type      ErrorType
	Message   string
	Cause     error
	Timestamp time.Time
	Context   map[string]interface{}
}

MonitorError represents an error that occurred during monitoring

func (*MonitorError) Error

func (e *MonitorError) Error() string

Error implements the error interface

func (*MonitorError) GetRetryDelay

func (e *MonitorError) GetRetryDelay() time.Duration

GetRetryDelay returns the suggested delay before retrying

func (*MonitorError) IsRetryable

func (e *MonitorError) IsRetryable() bool

IsRetryable returns true if the error is retryable

func (*MonitorError) Unwrap

func (e *MonitorError) Unwrap() error

Unwrap returns the underlying error

type MonitorResult

type MonitorResult struct {
	PreviousCheck      time.Time            `json:"previous_check"`
	CurrentCheck       time.Time            `json:"current_check"`
	RateLimit          github.RateLimitInfo `json:"rate_limit"`
	Username           string               `json:"username"`
	Changes            *RepositoryChanges   `json:"changes"` // Detailed change analysis
	TotalRepositories  int                  `json:"total_repositories"`
	APICallsSaved      int                  `json:"api_calls_saved"` // Estimated API calls saved by incremental fetch
	IsFirstRun         bool                 `json:"is_first_run"`
	IsFullSync         bool                 `json:"is_full_sync"`        // Whether a full sync was performed
	IncrementalEnabled bool                 `json:"incremental_enabled"` // Whether incremental fetching is enabled
}

MonitorResult contains comprehensive results including incremental fetch information

type OperationProgress

type OperationProgress struct {
	Name      string
	Current   int
	Total     int
	Completed bool
	Error     error
}

OperationProgress tracks progress for a single operation

type ProgressCallback

type ProgressCallback func(current, total int, message string)

ProgressCallback is a function type for progress callbacks

func NewProgressCallback

func NewProgressCallback(reporter *ProgressReporter, ctx context.Context) ProgressCallback

NewProgressCallback creates a progress callback function

type ProgressReporter

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

ProgressReporter handles progress reporting for monitoring operations

func NewProgressReporter

func NewProgressReporter(writer io.Writer) *ProgressReporter

NewProgressReporter creates a new progress reporter

func (*ProgressReporter) ReportCompletion

func (p *ProgressReporter) ReportCompletion(duration time.Duration, count int)

ReportCompletion reports completion of an operation

func (*ProgressReporter) ReportError

func (p *ProgressReporter) ReportError(err error)

ReportError reports an error during operation

func (*ProgressReporter) ReportProgress

func (p *ProgressReporter) ReportProgress(ctx context.Context, current, total int, message string)

ReportProgress reports progress during repository fetching

func (*ProgressReporter) ReportRateLimit

func (p *ProgressReporter) ReportRateLimit(remaining, resetTime int)

ReportRateLimit reports rate limit information

type ProgressTracker

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

ProgressTracker tracks overall progress across multiple operations

func NewProgressTracker

func NewProgressTracker(reporter *ProgressReporter) *ProgressTracker

NewProgressTracker creates a new progress tracker

func (*ProgressTracker) CompleteOperation

func (pt *ProgressTracker) CompleteOperation(name string, err error)

CompleteOperation marks an operation as completed

func (*ProgressTracker) Finish

func (pt *ProgressTracker) Finish()

Finish completes all tracking and reports final results

func (*ProgressTracker) StartOperation

func (pt *ProgressTracker) StartOperation(name string, total int)

StartOperation starts tracking a new operation

func (*ProgressTracker) UpdateOperation

func (pt *ProgressTracker) UpdateOperation(name string, current int)

UpdateOperation updates progress for an operation

type RecoverableError

type RecoverableError struct {
	Err          error
	RecoveryTips []string
	RetryAfter   *time.Duration
}

RecoverableError represents an error from which recovery might be possible

func NewRecoverableError

func NewRecoverableError(err error, tips []string, retryAfter *time.Duration) *RecoverableError

NewRecoverableError creates a new recoverable error

func (*RecoverableError) Error

func (r *RecoverableError) Error() string

Error implements the error interface

func (*RecoverableError) Unwrap

func (r *RecoverableError) Unwrap() error

Unwrap returns the underlying error

type RepositoryChanges

type RepositoryChanges struct {
	NewStars     []storage.Repository `json:"new_stars"`     // Newly starred repositories
	Unstars      []storage.Repository `json:"unstars"`       // Unstarred repositories
	ReStars      []storage.Repository `json:"re_stars"`      // Re-starred repositories (starred, unstarred, then starred again)
	Updated      []storage.Repository `json:"updated"`       // Repositories with updated metadata
	TotalChanges int                  `json:"total_changes"` // Total number of changes detected
}

RepositoryChanges represents the changes between two repository states

type RepositoryUpdate

type RepositoryUpdate struct {
	Previous storage.Repository `json:"previous"`
	Current  storage.Repository `json:"current"`
	Changes  []string           `json:"changes"`
}

RepositoryUpdate represents a repository that has been updated

type RetryManager

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

RetryManager handles retry logic with exponential backoff

func NewRetryManager

func NewRetryManager(cfg *config.RetryConfig) *RetryManager

NewRetryManager creates a new retry manager with the given configuration

func (*RetryManager) ExecuteWithRetry

func (r *RetryManager) ExecuteWithRetry(ctx context.Context, operation func() error) error

ExecuteWithRetry executes a function with retry logic

func (*RetryManager) SetLogger

func (r *RetryManager) SetLogger(logger func(format string, args ...interface{}))

SetLogger sets a custom logger function

type RetryableError

type RetryableError struct {
	Err         error
	IsRateLimit bool
	RetryAfter  time.Duration
	IsTemporary bool
}

RetryableError represents an error that can be retried

func (*RetryableError) Error

func (r *RetryableError) Error() string

func (*RetryableError) Unwrap

func (r *RetryableError) Unwrap() error

type Service

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

Service provides the core monitoring functionality

func NewService

func NewService(githubClient github.GitHubClient, storage storage.StateStorage, tokenManager auth.TokenManager, cfg *config.Config) *Service

NewService creates a new monitoring service

func (*Service) MonitorUser

func (s *Service) MonitorUser(ctx context.Context, username, stateFilePath string) (*MonitorResult, error)

MonitorUser monitors a GitHub user's starred repositories with enhanced incremental capabilities

func (*Service) SetProgressCallback

func (s *Service) SetProgressCallback(callback func(message string))

SetProgressCallback sets a callback function for progress updates

type SpinnerProgress

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

SpinnerProgress provides a simple spinner for indeterminate progress

func NewSpinnerProgress

func NewSpinnerProgress(writer io.Writer, message string) *SpinnerProgress

NewSpinnerProgress creates a new spinner progress indicator

func (*SpinnerProgress) Stop

func (sp *SpinnerProgress) Stop()

Stop stops the spinner

Jump to

Keyboard shortcuts

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