poller

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package poller implments a simple poller for the weather service. It consists of a Pulse worker that periodically calls the weather service to retrieve the weather forecast for given US cities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service is the poller service implementation.

func New

func New(ctx context.Context, nominatimc nominatim.Client, weatherc weathergov.Client, rdb *redis.Client) (*Service, error)

New instantiates a new poller service.

func (*Service) AddLocation

func (svc *Service) AddLocation(ctx context.Context, p *genpoller.CityAndState) error

AddJob adds a new job to the poller worker pool.

func (*Service) AddWorker

func (svc *Service) AddWorker(ctx context.Context) (*genpoller.Worker, error)

AddWorker adds a new worker to the poller worker pool.

func (*Service) RemoveWorker

func (svc *Service) RemoveWorker(ctx context.Context) error

RemoveWorker removes a worker from the poller worker pool.

func (*Service) Status

func (svc *Service) Status(ctx context.Context) (*genpoller.PollerStatus, error)

Status returns the status and statistics of the poller service.

func (*Service) Stop

func (svc *Service) Stop(ctx context.Context) error

Stop stops the poller service gracefully.

func (*Service) Subscribe

func (svc *Service) Subscribe(ctx context.Context, location *genpoller.CityAndState, sub genpoller.SubscribeServerStream) error

Subscribe subscribes to forecasts for the given location.

type Worker

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

Worker is the type that implements the Pulse worker interface.

func NewWorker

func NewWorker(ctx context.Context, updateStream *streaming.Stream, nominatimc nominatim.Client, weatherc weathergov.Client) *Worker

New returns a new poller.

func (*Worker) Start

func (worker *Worker) Start(job *pool.Job) error

Start starts polling the weather service for the city and state encoded in the Pulse job payload and associates the poller with the given key.

func (*Worker) Stop

func (worker *Worker) Stop(key string) error

Stop stops the poller associated with the given key.

Directories

Path Synopsis
clients
weathergov
Package weathergov provides a client for the Weather.gov API described at https://www.weather.gov/documentation/services-web-api#
Package weathergov provides a client for the Weather.gov API described at https://www.weather.gov/documentation/services-web-api#
cmd
gen

Jump to

Keyboard shortcuts

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