import "github.com/kinorai/omnifeed/internal/engine/reddit/redisstate"
Package redisstate shares the Reddit method chain’s skip state between replicas through Redis (see reddit.SharedState).
A held method is one key whose TTL is the time left on the hold. Reddit’s budget belongs to the credential, not to the pod, so a back-off one replica receives applies to all of them. The TTL is Redis’ own clock, so the replicas’ clocks never need to agree.
Every operation is a script, like the rate limiter’s, so a Redis ACL that already admits the limiter needs no new command. The keys share one hash tag, so the multi-key read stays in one slot on a Redis Cluster.
Store is a reddit.SharedState on Redis.
type Store struct {
// contains filtered or unexported fields
}
func New(client redis.UniversalClient, prefix string) *Store
New returns a Store whose keys start with prefix, e.g. “omnifeed:ratelimit” gives “omnifeed:ratelimit:{reddit-method}:session”.
func (s *Store) Clear(ctx context.Context, method string) error
Clear ends the hold on method for every replica.
func (s *Store) Hold(ctx context.Context, method string, d time.Duration) error
Hold skips method on every replica for at least d.
func (s *Store) Holds(ctx context.Context, methods []string) (map[string]time.Duration, error)
Holds returns the time left on each held method. A method that is not held is absent from the map. One round trip for all methods.
Generated by gomarkdoc