Documentation
¶
Index ¶
- Variables
- type CreateProviderInput
- type Handler
- type Provider
- type ProxyNode
- type RefreshAttempt
- type RefreshFailedError
- type RefreshProviderFunc
- type ReplaceSnapshotInput
- type Repository
- func (r *Repository) Create(ctx context.Context, p Provider) (Provider, error)
- func (r *Repository) Delete(ctx context.Context, id int64) error
- func (r *Repository) GetByID(ctx context.Context, id int64) (Provider, error)
- func (r *Repository) GetLatestSnapshot(ctx context.Context, providerID int64) (Snapshot, error)
- func (r *Repository) List(ctx context.Context) ([]Provider, error)
- func (r *Repository) ListLatestNodes(ctx context.Context) ([]map[string]any, error)
- func (r *Repository) ListLatestNodesByProviders(ctx context.Context, providerIDs []int64) ([]map[string]any, error)
- func (r *Repository) ListProxyNodesByProvider(ctx context.Context, providerID int64) ([]ProxyNode, error)
- func (r *Repository) RecordRefreshFailure(ctx context.Context, providerID int64, message string) error
- func (r *Repository) ReplaceLastKnownGoodSnapshot(ctx context.Context, providerID int64, in ReplaceSnapshotInput) error
- func (r *Repository) ToggleNodeEnabled(ctx context.Context, nodeID int64) (bool, error)
- func (r *Repository) Update(ctx context.Context, p Provider) (Provider, error)
- type Service
- func (s *Service) Create(ctx context.Context, in CreateProviderInput) (Provider, error)
- func (s *Service) Delete(ctx context.Context, id int64) error
- func (s *Service) GetByID(ctx context.Context, id int64) (Provider, error)
- func (s *Service) GetLatestSnapshot(ctx context.Context, id int64) (Snapshot, error)
- func (s *Service) List(ctx context.Context) ([]Provider, error)
- func (s *Service) ListNodes(ctx context.Context, providerID int64) ([]ProxyNode, error)
- func (s *Service) SetSubscriptionReferenceChecker(checker SubscriptionReferenceChecker)
- func (s *Service) ToggleNodeEnabled(ctx context.Context, nodeID int64) (bool, error)
- func (s *Service) Update(ctx context.Context, id int64, in UpdateProviderInput) (Provider, error)
- type Snapshot
- type SubscriptionReferenceChecker
- type UpdateProviderInput
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidURL = errors.New("invalid provider url")
View Source
var ErrNotFound = errors.New("provider not found")
View Source
var ErrRefreshIntervalTooShort = errors.New("refresh interval must be at least 5 minutes")
View Source
var ErrSubscriptionProviderRef = errors.New("provider is referenced by a subscription")
Functions ¶
This section is empty.
Types ¶
type CreateProviderInput ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) RegisterRoutes ¶
func (*Handler) SetRefresher ¶
func (h *Handler) SetRefresher(f RefreshProviderFunc)
type Provider ¶
type Provider struct {
ID int64 `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
RefreshIntervalMinutes int64 `json:"refresh_interval_minutes"`
Abbrev string `json:"abbrev"`
Used int64 `json:"used"`
Total int64 `json:"total"`
Expire int64 `json:"expire"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastRefreshStatus string `json:"last_refresh_status,omitempty"`
LastRefreshMessage string `json:"last_refresh_message,omitempty"`
LastAttemptedAt time.Time `json:"last_attempted_at"`
}
type RefreshAttempt ¶
type RefreshFailedError ¶
type RefreshFailedError struct {
Message string
}
func (*RefreshFailedError) Error ¶
func (e *RefreshFailedError) Error() string
type RefreshProviderFunc ¶
type ReplaceSnapshotInput ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *sql.DB) *Repository
func (*Repository) GetLatestSnapshot ¶
func (*Repository) ListLatestNodes ¶
func (*Repository) ListLatestNodesByProviders ¶
func (*Repository) ListProxyNodesByProvider ¶
func (*Repository) RecordRefreshFailure ¶
func (*Repository) ReplaceLastKnownGoodSnapshot ¶
func (r *Repository) ReplaceLastKnownGoodSnapshot(ctx context.Context, providerID int64, in ReplaceSnapshotInput) error
func (*Repository) ToggleNodeEnabled ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo *Repository) *Service
func (*Service) GetLatestSnapshot ¶
func (*Service) SetSubscriptionReferenceChecker ¶
func (s *Service) SetSubscriptionReferenceChecker(checker SubscriptionReferenceChecker)
func (*Service) ToggleNodeEnabled ¶
Click to show internal directories.
Click to hide internal directories.