Documentation
¶
Index ¶
- func IsSubscription(rl config.RuleListConfig) bool
- func SaveSubscriptionMeta(metaPath string, meta SubscriptionMeta) error
- func SubscriptionKey(rl config.RuleListConfig) (string, bool)
- func SubscriptionMetaPath(rl config.RuleListConfig) (string, bool)
- func SubscriptionRulesPath(rl config.RuleListConfig) (string, bool)
- func SubscriptionUpdateInterval(rl config.RuleListConfig) time.Duration
- func SubscriptionsDir() string
- type SubscriptionManager
- type SubscriptionMeta
- type SyncSubscriptionOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSubscription ¶
func IsSubscription(rl config.RuleListConfig) bool
func SaveSubscriptionMeta ¶
func SaveSubscriptionMeta(metaPath string, meta SubscriptionMeta) error
func SubscriptionKey ¶
func SubscriptionKey(rl config.RuleListConfig) (string, bool)
func SubscriptionMetaPath ¶
func SubscriptionMetaPath(rl config.RuleListConfig) (string, bool)
func SubscriptionRulesPath ¶
func SubscriptionRulesPath(rl config.RuleListConfig) (string, bool)
func SubscriptionUpdateInterval ¶
func SubscriptionUpdateInterval(rl config.RuleListConfig) time.Duration
func SubscriptionsDir ¶
func SubscriptionsDir() string
Types ¶
type SubscriptionManager ¶
type SubscriptionManager struct {
// contains filtered or unexported fields
}
SubscriptionManager periodically syncs rule list subscriptions and triggers a callback when content changes (typically for hot-reload).
func NewSubscriptionManager ¶
func NewSubscriptionManager(cfg *config.Manager, onUpdate func()) *SubscriptionManager
func (*SubscriptionManager) Start ¶
func (m *SubscriptionManager) Start()
func (*SubscriptionManager) Stop ¶
func (m *SubscriptionManager) Stop()
type SubscriptionMeta ¶
type SubscriptionMeta struct {
URL string `json:"url"`
ETag string `json:"etag,omitempty"`
LastModified string `json:"last_modified,omitempty"`
CheckedAt int64 `json:"checked_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
// ContentSHA256 is the sha256 (hex) of the accepted subscription content (after parsing):
// - used to detect content changes
// - shown in the admin UI as a cache fingerprint
ContentSHA256 string `json:"content_sha256,omitempty"`
// VerifiedSHA256 is a legacy field name (easy to confuse with "verified"); kept for backward compatibility with older meta files.
// New code should prefer ContentSHA256.
VerifiedSHA256 string `json:"verified_sha256,omitempty"`
Bytes int `json:"bytes,omitempty"`
LastError string `json:"last_error,omitempty"`
}
SubscriptionMeta tracks the subscription cache state (for conditional requests and admin UI display).
func LoadSubscriptionMeta ¶
func LoadSubscriptionMeta(metaPath string) (SubscriptionMeta, bool, error)
func SyncSubscriptionIfDue ¶
func SyncSubscriptionIfDue(ctx context.Context, rl config.RuleListConfig, opts SyncSubscriptionOptions) (updated bool, meta SubscriptionMeta, err error)
SyncSubscriptionIfDue pulls the subscription when "due" (or forced) and writes it to disk. updated indicates cache content changed (or first write); err only means this sync attempt failed and should not make the proxy unusable.
Click to show internal directories.
Click to hide internal directories.