statestore

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

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 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 added in v0.2.3

func WithRedisKeyPrefix(prefix string) RedisOption

func WithRedisReadReplicaClient added in v0.3.1

func WithRedisReadReplicaClient(client rueidis.Client) RedisOption

func WithSeparatedAssignmentRedis added in v0.2.0

func WithSeparatedAssignmentRedis(client rueidis.Client) RedisOption

func WithTicketTTL added in v0.2.0

func WithTicketTTL(ticketTTL time.Duration) 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) error

func (*RedisStore) CreateTicket

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

func (*RedisStore) DeleteTicket

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

func (*RedisStore) GetActiveTicketIDs added in v0.2.3

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 `GetTicket` or `GetTickets` call will resolve this inconsistency.

func (*RedisStore) GetAssignment added in v0.2.0

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 added in v0.3.2

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

func (*RedisStore) GetTickets added in v0.2.3

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 StateStore

type StateStore interface {
	CreateTicket(ctx context.Context, ticket *pb.Ticket) error
	DeleteTicket(ctx context.Context, ticketID string) error
	GetTicket(ctx context.Context, ticketID string) (*pb.Ticket, error)
	GetTickets(ctx context.Context, ticketIDs []string) ([]*pb.Ticket, error)
	GetAssignment(ctx context.Context, ticketID string) (*pb.Assignment, error)
	GetActiveTicketIDs(ctx context.Context, limit int64) ([]string, error)
	GetTicketCount(ctx context.Context) (int64, error)
	ReleaseTickets(ctx context.Context, ticketIDs []string) error
	AssignTickets(ctx context.Context, asgs []*pb.AssignmentGroup) error
}

type StoreWithTicketCache added in v0.2.1

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

StoreWithTicketCache caches GetTicket results in-memory with TTL

func NewStoreWithTicketCache added in v0.2.1

func NewStoreWithTicketCache(origin StateStore, ticketCache *cache.Cache[string, *pb.Ticket], opts ...TicketCacheOption) *StoreWithTicketCache

func (*StoreWithTicketCache) AssignTickets added in v0.2.1

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

func (*StoreWithTicketCache) CreateTicket added in v0.2.1

func (s *StoreWithTicketCache) CreateTicket(ctx context.Context, ticket *pb.Ticket) error

func (*StoreWithTicketCache) DeleteTicket added in v0.2.1

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

func (*StoreWithTicketCache) GetActiveTicketIDs added in v0.2.3

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

func (*StoreWithTicketCache) GetAssignment added in v0.2.1

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

func (*StoreWithTicketCache) GetTicket added in v0.2.1

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

func (*StoreWithTicketCache) GetTicketCount added in v0.3.2

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

func (*StoreWithTicketCache) GetTickets added in v0.2.3

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

func (*StoreWithTicketCache) ReleaseTickets added in v0.2.1

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

type TicketCacheOption added in v0.2.1

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

func WithTicketCacheTTL added in v0.2.1

func WithTicketCacheTTL(ttl time.Duration) TicketCacheOption

Jump to

Keyboard shortcuts

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