timout fx

This commit is contained in:
merdan 2022-09-06 16:39:29 +05:00
parent ad4c216c75
commit dc42eda2fe
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package gorm_models
import (
"context"
helper "db_service/pkg"
"gorm.io/gorm"
"os"
@ -94,9 +95,10 @@ func (ProductFlat) TableName() string {
func DeleteProducts(db *gorm.DB) error {
//todo delete from elastico
return db.Exec("DELETE p.* FROM products p, order_items oi WHERE p.id NOT IN (select product_id from wishlist) AND p.id NOT IN (select product_id from order_items) AND p.id NOT IN (select parent_id from order_items)").Error
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
qb := "DELETE p.* FROM products p, order_items oi WHERE p.id NOT IN (select product_id from wishlist) AND p.id NOT IN (select product_id from order_items) AND p.id NOT IN (select parent_id from order_items)"
return db.WithContext(ctx).Exec(qb).Error
}
func Flush() error {

View File

@ -14,7 +14,7 @@ import (
func SendRequest(method string, endpoint string, values []byte, authKey string, isCouchDbReq bool) ([]byte, error) {
const ConnectMaxWaitTime = 30 * time.Second
const RequestMaxWaitTime = 60 * time.Second
const RequestMaxWaitTime = 10 * time.Minute
client := http.Client{
Transport: &http.Transport{