diff --git a/metrics.go b/metrics.go index a360b87..44fa155 100644 --- a/metrics.go +++ b/metrics.go @@ -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) } diff --git a/pkg/statestore/redis.go b/pkg/statestore/redis.go index 20800f0..2da06df 100644 --- a/pkg/statestore/redis.go +++ b/pkg/statestore/redis.go @@ -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 } @@ -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 { diff --git a/tests/intergration_test.go b/tests/intergration_test.go index d8dfc47..7a22033 100644 --- a/tests/intergration_test.go +++ b/tests/intergration_test.go @@ -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{})