Documentation
¶
Index ¶
- Variables
- type BackendStore
- type BackendStoreWithTicketCache
- func (s *BackendStoreWithTicketCache) AssignTickets(ctx context.Context, asgs []*pb.AssignmentGroup) ([]string, error)
- func (s *BackendStoreWithTicketCache) GetActiveTicketIDs(ctx context.Context, limit int64) ([]string, error)
- func (s *BackendStoreWithTicketCache) GetTicketCount(ctx context.Context) (int64, error)
- func (s *BackendStoreWithTicketCache) GetTickets(ctx context.Context, ticketIDs []string) ([]*pb.Ticket, error)
- func (s *BackendStoreWithTicketCache) ReleaseTickets(ctx context.Context, ticketIDs []string) error
- type FrontendStore
- type FrontendStoreWithTicketCache
- func (s *FrontendStoreWithTicketCache) CreateTicket(ctx context.Context, ticket *pb.Ticket, ttl time.Duration) error
- func (s *FrontendStoreWithTicketCache) DeindexTicket(ctx context.Context, ticketID string) error
- func (s *FrontendStoreWithTicketCache) DeleteTicket(ctx context.Context, ticketID string) error
- func (s *FrontendStoreWithTicketCache) GetAssignment(ctx context.Context, ticketID string) (*pb.Assignment, error)
- func (s *FrontendStoreWithTicketCache) GetTicket(ctx context.Context, ticketID string) (*pb.Ticket, error)
- type RedisOption
- func WithAssignedDeleteTimeout(assignedDeleteTimeout time.Duration) RedisOption
- func WithPendingReleaseTimeout(pendingReleaseTimeout time.Duration) RedisOption
- func WithRedisKeyPrefix(prefix string) RedisOption
- func WithRedisReadReplicaClient(client rueidis.Client) RedisOption
- func WithSeparatedAssignmentRedis(client rueidis.Client) RedisOption
- type RedisOptionFunc
- type RedisStore
- func (s *RedisStore) AssignTickets(ctx context.Context, asgs []*pb.AssignmentGroup) ([]string, error)
- func (s *RedisStore) CreateTicket(ctx context.Context, ticket *pb.Ticket, ttl time.Duration) error
- func (s *RedisStore) DeindexTicket(ctx context.Context, ticketID string) error
- func (s *RedisStore) DeleteTicket(ctx context.Context, ticketID string) error
- func (s *RedisStore) GetActiveTicketIDs(ctx context.Context, limit int64) ([]string, error)
- func (s *RedisStore) GetAssignment(ctx context.Context, ticketID string) (*pb.Assignment, error)
- func (s *RedisStore) GetTicket(ctx context.Context, ticketID string) (*pb.Ticket, error)
- func (s *RedisStore) GetTicketCount(ctx context.Context) (int64, error)
- func (s *RedisStore) GetTickets(ctx context.Context, ticketIDs []string) ([]*pb.Ticket, error)
- func (s *RedisStore) ReleaseTickets(ctx context.Context, ticketIDs []string) error
- type TicketCacheOption
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 (*BackendStoreWithTicketCache) GetTicketCount ¶
func (s *BackendStoreWithTicketCache) GetTicketCount(ctx context.Context) (int64, error)
func (*BackendStoreWithTicketCache) GetTickets ¶
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 (*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)
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 (*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 ¶
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) GetTicketCount ¶
func (s *RedisStore) GetTicketCount(ctx context.Context) (int64, error)
func (*RedisStore) GetTickets ¶
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.
Click to show internal directories.
Click to hide internal directories.