storeClient

package module
v0.0.0-...-d07f50b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

README

CubanProductFinder

CubanProductFinder is a library made to find products in the virtual stores of Cuba in a fast and light way.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(network, address string) (*Cache, error)

func (Cache) AddProduct

func (c Cache) AddProduct(product Product) error

func (Cache) SearchProducts

func (c Cache) SearchProducts(pattern string) (int, []Product, error)

type GenericProduct

type GenericProduct struct {
	Name    string
	Price   string
	Link    string
	Section Section
}
func (g *GenericProduct) GetLink() string

func (*GenericProduct) GetName

func (g *GenericProduct) GetName() string

func (*GenericProduct) GetPrice

func (g *GenericProduct) GetPrice() string

func (*GenericProduct) GetSection

func (g *GenericProduct) GetSection() Section

type GenericSection

type GenericSection struct {
	Name      string
	Url       string
	Parent    string
	Store     *Store
	Priority  int
	ReadyTime time.Time
}

func (*GenericSection) GetName

func (g *GenericSection) GetName() string

func (*GenericSection) GetParent

func (g *GenericSection) GetParent() string

func (*GenericSection) GetPriority

func (g *GenericSection) GetPriority(string) int

func (*GenericSection) GetReadyTime

func (g *GenericSection) GetReadyTime() time.Time

func (*GenericSection) GetStore

func (g *GenericSection) GetStore() *Store

func (*GenericSection) GetUrl

func (g *GenericSection) GetUrl() string

func (*GenericSection) SetReadyTime

func (g *GenericSection) SetReadyTime(readyTime time.Time)

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool(maxGoroutines int) *Pool

func (*Pool) Run

func (p *Pool) Run(w Worker)

func (*Pool) Shutdown

func (p *Pool) Shutdown()

type Product

type Product interface {
	GetName() string
	GetPrice() string
	GetLink() string
	GetSection() Section
}

type QuintaY42Product

type QuintaY42Product struct {
	Name      string `css:".product-name" extract:"attr" attr:"title"`
	Price     string `css:".product-price"`
	Link      string `css:".product-name" extract:"attr" attr:"href"`
	Available string `css:".ajax_add_to_cart_button" extract:"attr" attr:"href"`
	Section   Section
}
func (q *QuintaY42Product) GetLink() string

func (*QuintaY42Product) GetName

func (q *QuintaY42Product) GetName() string

func (*QuintaY42Product) GetPrice

func (q *QuintaY42Product) GetPrice() string

func (*QuintaY42Product) GetSection

func (q *QuintaY42Product) GetSection() Section

type QuintaY42Section

type QuintaY42Section struct {
	Name      string `css:"a"`
	Url       string `css:"a" extract:"attr" attr:"href"`
	Parent    string
	Store     *Store
	Priority  int
	ReadyTime time.Time
}

func (*QuintaY42Section) GetName

func (q *QuintaY42Section) GetName() string

func (*QuintaY42Section) GetParent

func (q *QuintaY42Section) GetParent() string

func (*QuintaY42Section) GetPriority

func (q *QuintaY42Section) GetPriority(string) int

func (*QuintaY42Section) GetReadyTime

func (q *QuintaY42Section) GetReadyTime() time.Time

func (*QuintaY42Section) GetStore

func (q *QuintaY42Section) GetStore() *Store

func (*QuintaY42Section) GetUrl

func (q *QuintaY42Section) GetUrl() string

func (*QuintaY42Section) SetReadyTime

func (q *QuintaY42Section) SetReadyTime(readyTime time.Time)

type Section

type Section interface {
	GetName() string
	GetUrl() string
	GetParent() string
	GetStore() *Store
	GetPriority(string) int
	GetReadyTime() time.Time
	SetReadyTime(readyTime time.Time)
}

type Store

type Store struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
	// Address        string `json:"address"`
	Province string `json:"province"`
	Online   bool   `json:"online"`
	// PickUpOnStore  bool   `json:"pickUpOnStore"`
	// HomeDelivery   bool   `json:"homeDelivery"`
	// FreezeDelivery string `json:"freezeDelivery"`
	// DeliveryTime   string `json:"deliveryTime"`
	// Cost           string `json:"cost"`
	Email string `json:"email"`
	Phone string `json:"phone"`
	Url   string `json:"url"`
}

type StoreClient

type StoreClient struct {
	// contains filtered or unexported fields
}

func NewStoreClient

func NewStoreClient(redisNetwork, redisAddr string) (*StoreClient, error)

func (*StoreClient) SearchProduct

func (sc *StoreClient) SearchProduct(pattern string) ([]Product, error)

func (*StoreClient) Start

func (sc *StoreClient) Start()

type TuEnvioProduct

type TuEnvioProduct struct {
	Name    string `css:".thumbTitle",redis:"name"`
	Price   string `css:".thumbPrice",redis:"price"`
	Link    string `css:".thumbnail a" extract:"attr" attr:"href",redis:"link"`
	Section Section
}
func (t *TuEnvioProduct) GetLink() string

func (*TuEnvioProduct) GetName

func (t *TuEnvioProduct) GetName() string

func (*TuEnvioProduct) GetPrice

func (t *TuEnvioProduct) GetPrice() string

func (*TuEnvioProduct) GetSection

func (t *TuEnvioProduct) GetSection() Section

type TuEnvioSection

type TuEnvioSection struct {
	Name      string `css:"div ul li a"`
	Url       string `css:"div ul li a" extract:"attr" attr:"href"`
	Parent    string
	Store     *Store
	Priority  int
	ReadyTime time.Time
}

func (*TuEnvioSection) GetName

func (t *TuEnvioSection) GetName() string

func (*TuEnvioSection) GetParent

func (t *TuEnvioSection) GetParent() string

func (*TuEnvioSection) GetPriority

func (t *TuEnvioSection) GetPriority(string) int

func (*TuEnvioSection) GetReadyTime

func (t *TuEnvioSection) GetReadyTime() time.Time

func (*TuEnvioSection) GetStore

func (t *TuEnvioSection) GetStore() *Store

func (*TuEnvioSection) GetUrl

func (t *TuEnvioSection) GetUrl() string

func (*TuEnvioSection) SetReadyTime

func (t *TuEnvioSection) SetReadyTime(readyTime time.Time)

type W

type W struct {
	// contains filtered or unexported fields
}

func (*W) GetArgs

func (w *W) GetArgs() context.Context

func (*W) Task

func (w *W) Task(ctx context.Context)

type Worker

type Worker interface {
	GetArgs() context.Context
	Task(ctx context.Context)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL