Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
castaneai committed Dec 25, 2023
1 parent c27cf35 commit 82d5cbf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
2 changes: 2 additions & 0 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ func (b *Backend) makeMatches(ctx context.Context, activeTickets []*pb.Ticket) (
if err != nil {
return err
}
start := time.Now()
matches, err := mmf.MakeMatches(ctx, profile, poolTickets)
if err != nil {
return err
}
b.metrics.recordMatchFunctionLatency(ctx, time.Since(start).Seconds(), profile)
resCh <- matches
return nil
})
Expand Down
24 changes: 3 additions & 21 deletions pkg/statestore/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ func (s *RedisStore) GetActiveTickets(ctx context.Context, limit int64) ([]*pb.T
defer unlock()

allTicketIDs, err := s.getAllTicketIDs(lockedCtx, limit)
if err != nil {
return nil, fmt.Errorf("failed to get all ticket IDs: %w", err)
}
if len(allTicketIDs) == 0 {
return nil, nil
}
Expand Down Expand Up @@ -333,27 +336,6 @@ func (s *RedisStore) getTickets(ctx context.Context, ticketIDs []string) ([]*pb.
return tickets, nil
}

func (s *RedisStore) setTickets(ctx context.Context, tickets []*pb.Ticket) error {
queries := make([]rueidis.Completed, len(tickets))
for i, ticket := range tickets {
data, err := encodeTicket(ticket)
if err != nil {
return fmt.Errorf("failed to encode ticket to update: %w", err)
}
queries[i] = s.client.B().Set().
Key(redisKeyTicketData(ticket.Id)).
Value(rueidis.BinaryString(data)).
Ex(s.opts.assignedDeleteTimeout).
Build()
}
for _, resp := range s.client.DoMulti(ctx, queries...) {
if err := resp.Error(); err != nil {
return fmt.Errorf("failed to update assigned tickets: %w", err)
}
}
return nil
}

func (s *RedisStore) setTicketsExpiration(ctx context.Context, ticketIDs []string, expiration time.Duration) error {
queries := make([]rueidis.Completed, len(ticketIDs))
for i, ticketID := range ticketIDs {
Expand Down
1 change: 1 addition & 0 deletions tests/intergration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestFrontend(t *testing.T) {
ctx := context.Background()

resp, err := c.GetTicket(ctx, &pb.GetTicketRequest{TicketId: "invalid"})
require.Error(t, err)
requireErrorCode(t, err, codes.NotFound)

t1 := mustCreateTicket(ctx, t, c, &pb.Ticket{})
Expand Down

0 comments on commit 82d5cbf

Please sign in to comment.