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 f43a896
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
3 changes: 1 addition & 2 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ type matchFunctionWithMetrics struct {
func (m *matchFunctionWithMetrics) MakeMatches(ctx context.Context, profile *pb.MatchProfile, poolTickets map[string][]*pb.Ticket) ([]*pb.Match, error) {
start := time.Now()
defer func() {
m.metrics.matchFunctionLatency.Record(ctx, time.Since(start).Seconds(),
metric.WithAttributes(matchProfileKey.String(profile.Name)))
m.metrics.recordMatchFunctionLatency(ctx, time.Since(start).Seconds(), profile)
}()
return m.mmf.MakeMatches(ctx, profile, poolTickets)
}
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 f43a896

Please sign in to comment.