Documentation ¶
Index ¶
- Constants
- Variables
- func MakeLocationExists(err error) *goa.ServiceError
- func MakeTooFew(err error) *goa.ServiceError
- func NewAddLocationEndpoint(s Service) goa.Endpoint
- func NewAddWorkerEndpoint(s Service) goa.Endpoint
- func NewRemoveWorkerEndpoint(s Service) goa.Endpoint
- func NewStatusEndpoint(s Service) goa.Endpoint
- func NewSubscribeEndpoint(s Service) goa.Endpoint
- type CityAndState
- type Client
- func (c *Client) AddLocation(ctx context.Context, p *CityAndState) (err error)
- func (c *Client) AddWorker(ctx context.Context) (res *Worker, err error)
- func (c *Client) RemoveWorker(ctx context.Context) (err error)
- func (c *Client) Status(ctx context.Context) (res *PollerStatus, err error)
- func (c *Client) Subscribe(ctx context.Context, p *CityAndState) (res SubscribeClientStream, err error)
- type Endpoints
- type Forecast
- type Job
- type Location
- type Period
- type PollerStatus
- type Service
- type SubscribeClientStream
- type SubscribeEndpointInput
- type SubscribeServerStream
- type Worker
Constants ¶
const APIName = "Forecast Poller Service API"
APIName is the name of the API as defined in the design.
const APIVersion = "0.0.1"
APIVersion is the version of the API as defined in the design.
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 ¶
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 ¶
NewAddLocationEndpoint returns an endpoint function that calls the method "add_location" of service "Poller".
func NewAddWorkerEndpoint ¶
NewAddWorkerEndpoint returns an endpoint function that calls the method "add_worker" of service "Poller".
func NewRemoveWorkerEndpoint ¶
NewRemoveWorkerEndpoint returns an endpoint function that calls the method "remove_worker" of service "Poller".
func NewStatusEndpoint ¶
NewStatusEndpoint returns an endpoint function that calls the method "status" of service "Poller".
func NewSubscribeEndpoint ¶
NewSubscribeEndpoint returns an endpoint function that calls the method "subscribe" of service "Poller".
Types ¶
type CityAndState ¶
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 (*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) RemoveWorker ¶
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 ¶
NewEndpoints wraps the methods of the "Poller" service with 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 ¶
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.