Documentation
¶
Index ¶
- type MemoryStore
- func (s *MemoryStore) Acquire(key string, ttl time.Duration, now time.Time) bool
- func (s *MemoryStore) AcquireDedupLock(key string, ttl time.Duration, now time.Time) bool
- func (s *MemoryStore) AcquireJobLock(jobID string, ttl time.Duration, now time.Time) bool
- func (s *MemoryStore) GC(now time.Time)
- func (s *MemoryStore) GetCheckpoint(org, repo string) (time.Time, bool, error)
- func (s *MemoryStore) Healthy(_ context.Context) bool
- func (s *MemoryStore) SetCheckpoint(org, repo string, checkpoint time.Time) error
- func (s *MemoryStore) Snapshot() []MetricPoint
- func (s *MemoryStore) UpsertMetric(role RuntimeRole, source WriteSource, point MetricPoint) error
- type MetricPoint
- type RedisStore
- func (s *RedisStore) Acquire(key string, ttl time.Duration, now time.Time) bool
- func (s *RedisStore) AcquireDedupLock(key string, ttl time.Duration, now time.Time) bool
- func (s *RedisStore) AcquireJobLock(jobID string, ttl time.Duration, now time.Time) bool
- func (s *RedisStore) Close() error
- func (s *RedisStore) GC(_ time.Time)
- func (s *RedisStore) GetCheckpoint(org, repo string) (time.Time, bool, error)
- func (s *RedisStore) Healthy(ctx context.Context) bool
- func (s *RedisStore) SetCheckpoint(org, repo string, checkpoint time.Time) error
- func (s *RedisStore) Snapshot() []MetricPoint
- func (s *RedisStore) SnapshotCursor() (uint64, error)
- func (s *RedisStore) SnapshotDelta(cursor uint64) (SnapshotDelta, error)
- func (s *RedisStore) UpsertMetric(role RuntimeRole, source WriteSource, point MetricPoint) error
- type RedisStoreConfig
- type RuntimeRole
- type SnapshotDelta
- type SnapshotDeltaEvent
- type WriteSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory shared metric store.
func NewMemoryStore ¶
func NewMemoryStore(retention time.Duration, maxSeries int) *MemoryStore
NewMemoryStore creates a memory store.
func (*MemoryStore) Acquire ¶
Acquire acquires a dedup lock for a key. It is an adapter for queue deduper interfaces.
func (*MemoryStore) AcquireDedupLock ¶
AcquireDedupLock acquires a dedup lock for a key.
func (*MemoryStore) AcquireJobLock ¶
AcquireJobLock acquires an idempotency lock for a job id.
func (*MemoryStore) GC ¶
func (s *MemoryStore) GC(now time.Time)
GC deletes expired metrics and locks.
func (*MemoryStore) GetCheckpoint ¶
GetCheckpoint returns the last processed timestamp for one org/repo.
func (*MemoryStore) Healthy ¶
func (s *MemoryStore) Healthy(_ context.Context) bool
Healthy reports memory store availability.
func (*MemoryStore) SetCheckpoint ¶
func (s *MemoryStore) SetCheckpoint(org, repo string, checkpoint time.Time) error
SetCheckpoint stores the latest processed timestamp for one org/repo.
func (*MemoryStore) Snapshot ¶
func (s *MemoryStore) Snapshot() []MetricPoint
Snapshot returns all non-expired metrics.
func (*MemoryStore) UpsertMetric ¶
func (s *MemoryStore) UpsertMetric(role RuntimeRole, source WriteSource, point MetricPoint) error
UpsertMetric inserts or updates a metric point with role/source write guards.
type MetricPoint ¶
MetricPoint is a single metric sample.
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore stores shared metrics and lock state in Redis.
func NewRedisStore ¶
func NewRedisStore(client redis.UniversalClient, cfg RedisStoreConfig) *RedisStore
NewRedisStore creates a Redis-backed metric store.
func (*RedisStore) Acquire ¶
Acquire acquires a dedup lock for a key. It is an adapter for queue deduper interfaces.
func (*RedisStore) AcquireDedupLock ¶
AcquireDedupLock acquires a dedup lock for a key.
func (*RedisStore) AcquireJobLock ¶
AcquireJobLock acquires an idempotency lock for a job id.
func (*RedisStore) Close ¶
func (s *RedisStore) Close() error
Close closes the underlying Redis client.
func (*RedisStore) GC ¶
func (s *RedisStore) GC(_ time.Time)
GC removes stale metric index references where series keys have already expired.
func (*RedisStore) GetCheckpoint ¶
GetCheckpoint returns the latest processed timestamp for one org/repo.
func (*RedisStore) Healthy ¶
func (s *RedisStore) Healthy(ctx context.Context) bool
Healthy reports Redis connectivity for dependency health probing.
func (*RedisStore) SetCheckpoint ¶
func (s *RedisStore) SetCheckpoint(org, repo string, checkpoint time.Time) error
SetCheckpoint stores the latest processed timestamp for one org/repo.
func (*RedisStore) Snapshot ¶
func (s *RedisStore) Snapshot() []MetricPoint
Snapshot returns all currently available metric series from Redis.
func (*RedisStore) SnapshotCursor ¶
func (s *RedisStore) SnapshotCursor() (uint64, error)
SnapshotCursor returns the current incremental snapshot cursor.
func (*RedisStore) SnapshotDelta ¶
func (s *RedisStore) SnapshotDelta(cursor uint64) (SnapshotDelta, error)
SnapshotDelta returns incremental series changes after the provided cursor.
func (*RedisStore) UpsertMetric ¶
func (s *RedisStore) UpsertMetric(role RuntimeRole, source WriteSource, point MetricPoint) error
UpsertMetric inserts or updates a metric point with role/source write guards.
type RedisStoreConfig ¶
type RedisStoreConfig struct {
Namespace string
Retention time.Duration
MaxSeries int
IndexShards int
}
RedisStoreConfig configures the Redis-backed shared metric store.
type RuntimeRole ¶
type RuntimeRole string
RuntimeRole represents the current runtime role.
const ( // RoleLeader is the leader role. RoleLeader RuntimeRole = "leader" // RoleFollower is the follower role. RoleFollower RuntimeRole = "follower" )
type SnapshotDelta ¶
type SnapshotDelta struct {
NextCursor uint64
Events []SnapshotDeltaEvent
}
SnapshotDelta contains a set of incremental changes after a cursor.
type SnapshotDeltaEvent ¶
type SnapshotDeltaEvent struct {
SeriesID string
Point MetricPoint
Deleted bool
}
SnapshotDeltaEvent is one incremental snapshot change for a series.
type WriteSource ¶
type WriteSource string
WriteSource represents the source path for a metric write.
const ( // SourceLeaderScrape writes originate from scheduled leader scrape. SourceLeaderScrape WriteSource = "leader_scrape" // SourceWorkerBackfill writes originate from backfill workers. SourceWorkerBackfill WriteSource = "worker_backfill" )