statestore

package
v0.0.0-...-55741f6 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTicketNotFound     = errors.New("ticket not found")
	ErrAssignmentNotFound = errors.New("assignment not found")
)

Functions

This section is empty.

Types

type BackendStore

type BackendStore interface {
	GetTickets(ctx context.Context, ticketIDs []string) ([]*pb.Ticket, error)
	GetActiveTicketIDs(ctx context.Context, limit int64) ([]string, error)
	GetTicketCount(ctx context.Context) (int64, error)
	ReleaseTickets(ctx context.Context, ticketIDs []string) error
	// AssignTickets Returns a list of ticket IDs that have failed assignments; you will need to check that list when err occurs.
	AssignTickets(ctx context.Context, asgs []*pb.AssignmentGroup) ([]string, error)
}

type BackendStoreWithTicketCache

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

BackendStoreWithTicketCache caches GetTickets results in-memory with TTL

func NewBackendStoreWithTicketCache

func NewBackendStoreWithTicketCache(origin BackendStore, ticketCache *cache.Cache[string, *pb.Ticket], opts ...TicketCacheOption) *BackendStoreWithTicketCache

func (*BackendStoreWithTicketCache) AssignTickets

func (s *BackendStoreWithTicketCache) AssignTickets(ctx context.Context, asgs []*pb.AssignmentGroup) ([]string, error)

func (*BackendStoreWithTicketCache) GetActiveTicketIDs

func (s *BackendStoreWithTicketCache) GetActiveTicketIDs(ctx context.Context, limit int64) ([]string, error)

func (*BackendStoreWithTicketCache) GetTicketCount

func (s *BackendStoreWithTicketCache) GetTicketCount(ctx context.Context) (int64, error)

func (*BackendStoreWithTicketCache) GetTickets

func (s *BackendStoreWithTicketCache) GetTickets(ctx context.Context, ticketIDs []string) ([]*pb.Ticket, error)

func (*BackendStoreWithTicketCache) ReleaseTickets

func (s *BackendStoreWithTicketCache) ReleaseTickets(ctx context.Context, ticketIDs []string) error

type FrontendStore

type FrontendStore interface {
	CreateTicket(ctx context.Context, ticket *pb.Ticket, ttl time.Duration) error
	DeleteTicket(ctx context.Context, ticketID string) error
	GetTicket(ctx context.Context, ticketID string) (*pb.Ticket, error)
	GetAssignment(ctx context.Context, ticketID string) (*pb.Assignment, error)
	DeindexTicket(ctx context.Context, ticketID string) error
}

type FrontendStoreWithTicketCache

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

FrontendStoreWithTicketCache caches GetTicket results in-memory with TTL

func NewFrontendStoreWithTicketCache

func NewFrontendStoreWithTicketCache(origin FrontendStore, ticketCache *cache.Cache[string, *pb.Ticket], opts ...TicketCacheOption) *FrontendStoreWithTicketCache

func (*FrontendStoreWithTicketCache) CreateTicket

func (s *FrontendStoreWithTicketCache) CreateTicket(ctx context.Context, ticket *pb.Ticket, ttl time.Duration) error

func (*FrontendStoreWithTicketCache) DeindexTicket

func (s *FrontendStoreWithTicketCache) DeindexTicket(ctx context.Context, ticketID string) error

func (*FrontendStoreWithTicketCache) DeleteTicket

func (s *FrontendStoreWithTicketCache) DeleteTicket(ctx context.Context, ticketID string) error

func (*FrontendStoreWithTicketCache) GetAssignment

func (s *FrontendStoreWithTicketCache) GetAssignment(ctx context.Context, ticketID string) (*pb.Assignment, error)

func (*FrontendStoreWithTicketCache) GetTicket

func (s *FrontendStoreWithTicketCache) GetTicket(ctx context.Context, ticketID string) (*pb.Ticket, error)

type RedisOption

type RedisOption interface {
	// contains filtered or unexported methods
}

func WithAssignedDeleteTimeout

func WithAssignedDeleteTimeout(assignedDeleteTimeout time.Duration) RedisOption

func WithPendingReleaseTimeout

func WithPendingReleaseTimeout(pendingReleaseTimeout time.Duration) RedisOption

func WithRedisKeyPrefix

func WithRedisKeyPrefix(prefix string) RedisOption

func WithRedisReadReplicaClient

func WithRedisReadReplicaClient(client rueidis.Client) RedisOption

func WithSeparatedAssignmentRedis

func WithSeparatedAssignmentRedis(client rueidis.Client) RedisOption

type RedisOptionFunc

type RedisOptionFunc func(opts *redisOpts)

type RedisStore

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

func NewRedisStore

func NewRedisStore(client rueidis.Client, locker rueidislock.Locker, opts ...RedisOption) *RedisStore

func (*RedisStore) AssignTickets

func (s *RedisStore) AssignTickets(ctx context.Context, asgs []*pb.AssignmentGroup) ([]string, error)

func (*RedisStore) CreateTicket

func (s *RedisStore) CreateTicket(ctx context.Context, ticket *pb.Ticket, ttl time.Duration) error

func (*RedisStore) DeindexTicket

func (s *RedisStore) DeindexTicket(ctx context.Context, ticketID string) error

func (*RedisStore) DeleteTicket

func (s *RedisStore) DeleteTicket(ctx context.Context, ticketID string) error

func (*RedisStore) GetActiveTicketIDs

func (s *RedisStore) GetActiveTicketIDs(ctx context.Context, limit int64) ([]string, error)

GetActiveTicketIDs may also retrieve tickets deleted by TTL. This is because the ticket index and Ticket data are stored in separate keys. The next `GetTickets` call will resolve this inconsistency.

func (*RedisStore) GetAssignment

func (s *RedisStore) GetAssignment(ctx context.Context, ticketID string) (*pb.Assignment, error)

func (*RedisStore) GetTicket

func (s *RedisStore) GetTicket(ctx context.Context, ticketID string) (*pb.Ticket, error)

func (*RedisStore) GetTicketCount

func (s *RedisStore) GetTicketCount(ctx context.Context) (int64, error)

func (*RedisStore) GetTickets

func (s *RedisStore) GetTickets(ctx context.Context, ticketIDs []string) ([]*pb.Ticket, error)

func (*RedisStore) ReleaseTickets

func (s *RedisStore) ReleaseTickets(ctx context.Context, ticketIDs []string) error

type TicketCacheOption

type TicketCacheOption interface {
	// contains filtered or unexported methods
}

func WithTicketCacheTTL

func WithTicketCacheTTL(ttl time.Duration) TicketCacheOption

WithTicketCacheTTL specifies the time to cache ticket data in-memory. The default is 10 seconds.

Jump to

Keyboard shortcuts

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