autopoller

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

auto-poller

A simple package for polling websites automatically

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallBack

type CallBack func(*WebsitePage, *http.Response, error)

CallBack is a pointer to a function that must be executed after an http call is performed

type PollSettings

type PollSettings struct {
	// Type of polling
	Type PollType `json:"type" yaml:"type"`
	// Frequency of polling, in seconds
	Frequency *int `json:"frequency" yaml:"frequency,omitempty"`
	// RandMin is the minimum value that can be extracted
	// when random polling
	RandMin *int `json:"randMin" yaml:"randMin,omitempty"`
	// RandMin is the maximum value that can be extracted
	// when random polling
	RandMax *int `json:"randMax" yaml:"randMax,omitempty"`
}

PollSettings contains settings about polling

type PollType

type PollType string

PollType represents the polling type (fixed or randomized)

const (
	// FixedPolling is a constant polling
	FixedPolling PollType = "fixed"
	// RandPolling means that the next poll will always be a random
	// value
	RandPolling PollType = "random"
)

type Poller

type Poller interface {
	Start(ctx context.Context, exitChan chan struct{})
	AddUserAgents(uas []string)
	AddPage(page *WebsitePage, f CallBack)
	RemovePage(id string)
}

Poller performs continous polling to websites

func New

func New(timeout int, redir bool) Poller

New returns a new instance of the poller

type WebsitePage

type WebsitePage struct {
	// ID of this page
	ID string `json:"id" yaml:"id"`
	// WebsiteName is the name of the website
	WebsiteName string `json:"websiteName" yaml:"websiteName"`
	// ProductName is the name of the product polled
	ProductName string `json:"productName" yaml:"productName"`
	// URL to poll
	URL string `json:"url" yaml:"url"`
	// NotifyURL is the url to notify externally
	NotifyURL *string `json:"notifyUrl" yaml:"notifyUrl,omitempty"`
	// UserAgents to use
	UserAgents []string `json:"userAgents" yaml:"userAgents,omitempty"`
	// PollSettings contains settings about polling
	PollSettings `json:"pollSettings" yaml:"pollSettings"`
}

WebsitePage contains information of the page to poll

Jump to

Keyboard shortcuts

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