poller

package
v0.0.8-rc12 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const APIName = "Forecast Poller Service API"

APIName is the name of the API as defined in the design.

View Source
const APIVersion = "0.0.1"

APIVersion is the version of the API as defined in the design.

View Source
const ServiceName = "Poller"

ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.

Variables

View Source
var MethodNames = [5]string{"add_location", "subscribe", "add_worker", "remove_worker", "status"}

MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.

Functions

func MakeLocationExists

func MakeLocationExists(err error) *goa.ServiceError

MakeLocationExists builds a goa.ServiceError from an error.

func MakeTooFew

func MakeTooFew(err error) *goa.ServiceError

MakeTooFew builds a goa.ServiceError from an error.

func NewAddLocationEndpoint

func NewAddLocationEndpoint(s Service) goa.Endpoint

NewAddLocationEndpoint returns an endpoint function that calls the method "add_location" of service "Poller".

func NewAddWorkerEndpoint

func NewAddWorkerEndpoint(s Service) goa.Endpoint

NewAddWorkerEndpoint returns an endpoint function that calls the method "add_worker" of service "Poller".

func NewRemoveWorkerEndpoint

func NewRemoveWorkerEndpoint(s Service) goa.Endpoint

NewRemoveWorkerEndpoint returns an endpoint function that calls the method "remove_worker" of service "Poller".

func NewStatusEndpoint

func NewStatusEndpoint(s Service) goa.Endpoint

NewStatusEndpoint returns an endpoint function that calls the method "status" of service "Poller".

func NewSubscribeEndpoint

func NewSubscribeEndpoint(s Service) goa.Endpoint

NewSubscribeEndpoint returns an endpoint function that calls the method "subscribe" of service "Poller".

Types

type CityAndState

type CityAndState struct {
	// State
	State string
	// City
	City string
}

CityAndState is the payload type of the Poller service add_location method.

type Client

type Client struct {
	AddLocationEndpoint  goa.Endpoint
	SubscribeEndpoint    goa.Endpoint
	AddWorkerEndpoint    goa.Endpoint
	RemoveWorkerEndpoint goa.Endpoint
	StatusEndpoint       goa.Endpoint
}

Client is the "Poller" service client.

func NewClient

func NewClient(addLocation, subscribe, addWorker, removeWorker, status goa.Endpoint) *Client

NewClient initializes a "Poller" service client given the endpoints.

func (*Client) AddLocation

func (c *Client) AddLocation(ctx context.Context, p *CityAndState) (err error)

AddLocation calls the "add_location" endpoint of the "Poller" service. AddLocation may return the following errors:

  • "location_exists" (type *goa.ServiceError): Location already exists
  • error: internal error

func (*Client) AddWorker

func (c *Client) AddWorker(ctx context.Context) (res *Worker, err error)

AddWorker calls the "add_worker" endpoint of the "Poller" service.

func (*Client) RemoveWorker

func (c *Client) RemoveWorker(ctx context.Context) (err error)

RemoveWorker calls the "remove_worker" endpoint of the "Poller" service. RemoveWorker may return the following errors:

  • "too_few" (type *goa.ServiceError): Only one worker left
  • error: internal error

func (*Client) Status

func (c *Client) Status(ctx context.Context) (res *PollerStatus, err error)

Status calls the "status" endpoint of the "Poller" service.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, p *CityAndState) (res SubscribeClientStream, err error)

Subscribe calls the "subscribe" endpoint of the "Poller" service.

type Endpoints

type Endpoints struct {
	AddLocation  goa.Endpoint
	Subscribe    goa.Endpoint
	AddWorker    goa.Endpoint
	RemoveWorker goa.Endpoint
	Status       goa.Endpoint
}

Endpoints wraps the "Poller" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

NewEndpoints wraps the methods of the "Poller" service with endpoints.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "Poller" service endpoints.

type Forecast

type Forecast struct {
	// Forecast location
	Location *Location
	// Weather forecast periods
	Periods []*Period
}

Forecast is the result type of the Poller service subscribe method.

type Job

type Job struct {
	// Job key
	Key string
	// Job payload
	Payload []byte
	// Creation timestamp
	CreatedAt string
}

Location forecast poll job

type Location

type Location struct {
	// Latitude
	Lat float64
	// Longitude
	Long float64
	// City
	City string
	// State
	State string
}

Geographical location

type Period

type Period struct {
	// Period name
	Name string
	// Start time
	StartTime string
	// End time
	EndTime string
	// Temperature
	Temperature int
	// Temperature unit
	TemperatureUnit string
	// Summary
	Summary string
}

Weather forecast period

type PollerStatus

type PollerStatus struct {
	// Poller workers
	Workers []*Worker
	// Location poll jobs
	Jobs []*Job
}

PollerStatus is the result type of the Poller service status method.

type Service

type Service interface {
	// Adds a location to the polling list.
	AddLocation(context.Context, *CityAndState) (err error)
	// Subscribes to weather forecast notifications for a location.
	Subscribe(context.Context, *CityAndState, SubscribeServerStream) (err error)
	// Adds a worker to the poller worker pool.
	AddWorker(context.Context) (res *Worker, err error)
	// Removes a worker from the poller worker pool.
	RemoveWorker(context.Context) (err error)
	// Provides poller status and statistics.
	Status(context.Context) (res *PollerStatus, err error)
}

Service that polls weather forecasts and notifies subscribers.

type SubscribeClientStream

type SubscribeClientStream interface {
	// Recv reads instances of "Forecast" from the stream.
	Recv() (*Forecast, error)
}

SubscribeClientStream is the interface a "subscribe" endpoint client stream must satisfy.

type SubscribeEndpointInput

type SubscribeEndpointInput struct {
	// Payload is the method payload.
	Payload *CityAndState
	// Stream is the server stream used by the "subscribe" method to send data.
	Stream SubscribeServerStream
}

SubscribeEndpointInput holds both the payload and the server stream of the "subscribe" method.

type SubscribeServerStream

type SubscribeServerStream interface {
	// Send streams instances of "Forecast".
	Send(*Forecast) error
	// Close closes the stream.
	Close() error
}

SubscribeServerStream is the interface a "subscribe" endpoint server stream must satisfy.

type Worker

type Worker struct {
	// Worker ID
	ID string
	// Worker poll jobs
	Jobs []*Job
	// Creation timestamp
	CreatedAt string
}

Worker is the result type of the Poller service add_worker method.

Jump to

Keyboard shortcuts

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