timout fx
This commit is contained in:
parent
ad4c216c75
commit
dc42eda2fe
|
|
@ -1,6 +1,7 @@
|
||||||
package gorm_models
|
package gorm_models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
helper "db_service/pkg"
|
helper "db_service/pkg"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -94,9 +95,10 @@ func (ProductFlat) TableName() string {
|
||||||
|
|
||||||
func DeleteProducts(db *gorm.DB) error {
|
func DeleteProducts(db *gorm.DB) error {
|
||||||
//todo delete from elastico
|
//todo delete from elastico
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||||
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
|
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 {
|
func Flush() error {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
func SendRequest(method string, endpoint string, values []byte, authKey string, isCouchDbReq bool) ([]byte, error) {
|
func SendRequest(method string, endpoint string, values []byte, authKey string, isCouchDbReq bool) ([]byte, error) {
|
||||||
|
|
||||||
const ConnectMaxWaitTime = 30 * time.Second
|
const ConnectMaxWaitTime = 30 * time.Second
|
||||||
const RequestMaxWaitTime = 60 * time.Second
|
const RequestMaxWaitTime = 10 * time.Minute
|
||||||
|
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue