feat: enhance context handling and add options for redis locker
This commit is contained in:
		@@ -128,6 +128,9 @@ func (r *apiRepository) GetProducts(ctx context.Context, marketplaceID int, req
 | 
			
		||||
	// all offers
 | 
			
		||||
	var allOffers []*pb.GetProductsResponse_Offer
 | 
			
		||||
	defer func() {
 | 
			
		||||
		if ctx.Err() != nil {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		// store only if offers is 90% or more then requested
 | 
			
		||||
		if len(allOffers) < int(float64(len(req.OfferIds))*0.9) {
 | 
			
		||||
			return
 | 
			
		||||
@@ -243,10 +246,16 @@ func (r *apiRepository) CalculateProductTariffs(ctx context.Context, marketplace
 | 
			
		||||
	offerChunks := lo.Chunk(req.Offers, defaultChunkSize)
 | 
			
		||||
	maxRetries := 5
 | 
			
		||||
	for chunkIndex, offerChunk := range offerChunks {
 | 
			
		||||
		if ctx.Err() != nil {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		fmt.Printf("Processing chunk %d/%d with %d offers\n", chunkIndex+1, len(offerChunks), len(offerChunk))
 | 
			
		||||
		var globalError error = nil
 | 
			
		||||
		for range maxRetries {
 | 
			
		||||
			response, err := r.processTariffChunk(ctx, client, ymParameters, offerChunk, chunkIndex)
 | 
			
		||||
			if ctx.Err() != nil {
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				globalError = err
 | 
			
		||||
				continue
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user