// @title Store app gRPC-client
// @version 0.0.1
// @description Simple application for loading/getting products
@title Store app gRPC-client
@version 0.0.1
@description Simple application for loading/getting products
// @title Store app gRPC - client // @version 0 . 0 . 1 // @description Simple application for loading / getting products
func main() {
	runtime.GOMAXPROCS(1)
	logrus.SetFormatter(new(logrus.JSONFormatter))
	if err := godotenv.Load(); err != nil {
		logrus.Fatalf("error reading env variables from file: %s\n", err.Error())
	}
	cfg, err := config.New()
	if err != nil {
		logrus.Fatalf("error loading env variables: %s\n", err.Error())
	}
	storeClient, err := grpc.New(*cfg)
	if err != nil {
		logrus.Fatalf("failed to initialize grpc client: %s\n", err.Error())
	}
	defer storeClient.Close()
	response, err := storeClient.Service.LoadProducts(context.Background(),
		&pb.LoadProductsRequest{Url: cfg.Store.Url})
	if err != nil {
		logrus.Fatalf("failed to load products:\n %s\n%s\n", cfg.Store.Url, err.Error())
	}
	fmt.Printf("download product response:\n%s\n\n", response.GetMessage())
	for page := 1; page <= 2; page++ {
		gettingProductsByPage(storeClient, int64(page))
	}
	infiniteGettingProducts(storeClient)
}
func main ( ) { runtime . GOMAXPROCS ( 1 ) logrus . SetFormatter ( new ( logrus . JSONFormatter ) ) if err := godotenv . Load ( ) ; err != nil { logrus . Fatalf ( " \n " , err . Error ( ) ) } cfg , err := config . New ( ) if err != nil { logrus . Fatalf ( " \n " , err . Error ( ) ) } storeClient , err := grpc . New ( * cfg ) if err != nil { logrus . Fatalf ( " \n " , err . Error ( ) ) } defer storeClient . Close ( ) response , err := storeClient . Service . LoadProducts ( context . Background ( ) , & pb . LoadProductsRequest { Url : cfg . Store . Url } ) if err != nil { logrus . Fatalf ( " \n \n \n " , cfg . Store . Url , err . Error ( ) ) } fmt . Printf ( " \n \n \n " , response . GetMessage ( ) ) for page := 1 ; page <= 2 ; page ++ { gettingProductsByPage ( storeClient , int64 ( page ) ) } infiniteGettingProducts ( storeClient ) }
@title Store app gRPC-client
@version 0.0.1
@description Simple application for loading/getting products
@title Store app gRPC - client @version 0 . 0 . 1 @description Simple application for loading / getting products
// 1. load product by url // 2. getting by page // 3. "infinite" getting