watch

package
v0.0.0-...-0140298 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	UpdateInterval time.Duration
}

Config holds configuration for item watcher

type ItemWatcher

type ItemWatcher struct {
	Client         *next.Client
	UpdateInterval time.Duration
	// contains filtered or unexported fields
}

ItemWatcher holds information about items to watch after

func New

func New(client *next.Client, config *Config) (*ItemWatcher, error)

New constructs new ItemWatcher instance

func (*ItemWatcher) AddItem

func (w *ItemWatcher) AddItem(item *shop.Item) error

AddItem add given item to the list of watched items

func (ItemWatcher) InStockChan

func (w ItemWatcher) InStockChan() <-chan shop.Item

InStockChan returns channel where InStock items will appear

func (*ItemWatcher) RemoveItem

func (w *ItemWatcher) RemoveItem(item shop.Item)

RemoveItem removes watching item from the list so it will not be processed next time when cron fires

func (*ItemWatcher) Run

func (w *ItemWatcher) Run()

Run satisfies cron.Job interface

func (*ItemWatcher) Start

func (w *ItemWatcher) Start() error

Start begins watcher's loop of checks

func (*ItemWatcher) Stop

func (w *ItemWatcher) Stop()

Stop terminates periodic checking

type Watcher

type Watcher interface {
	AddItem(*shop.Item) error
	InStockChan() <-chan shop.Item
	RemoveItem(shop.Item)
	Start() error
	Stop()
}

Watcher interface to be implemented by different watchers

Jump to

Keyboard shortcuts

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