storage

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

View Source
const ServiceName = "storage"

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 = [7]string{"list", "show", "add", "remove", "rate", "multi_add", "multi_update"}

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 NewAddEndpoint

func NewAddEndpoint(s Service) goa.Endpoint

NewAddEndpoint returns an endpoint function that calls the method "add" of service "storage".

func NewListEndpoint

func NewListEndpoint(s Service) goa.Endpoint

NewListEndpoint returns an endpoint function that calls the method "list" of service "storage".

func NewMultiAddEndpoint

func NewMultiAddEndpoint(s Service) goa.Endpoint

NewMultiAddEndpoint returns an endpoint function that calls the method "multi_add" of service "storage".

func NewMultiUpdateEndpoint

func NewMultiUpdateEndpoint(s Service) goa.Endpoint

NewMultiUpdateEndpoint returns an endpoint function that calls the method "multi_update" of service "storage".

func NewRateEndpoint

func NewRateEndpoint(s Service) goa.Endpoint

NewRateEndpoint returns an endpoint function that calls the method "rate" of service "storage".

func NewRemoveEndpoint

func NewRemoveEndpoint(s Service) goa.Endpoint

NewRemoveEndpoint returns an endpoint function that calls the method "remove" of service "storage".

func NewShowEndpoint

func NewShowEndpoint(s Service) goa.Endpoint

NewShowEndpoint returns an endpoint function that calls the method "show" of service "storage".

func NewViewedStoredBottle

func NewViewedStoredBottle(res *StoredBottle, view string) *storageviews.StoredBottle

NewViewedStoredBottle initializes viewed result type StoredBottle from result type StoredBottle using the given view.

func NewViewedStoredBottleCollection

func NewViewedStoredBottleCollection(res StoredBottleCollection, view string) storageviews.StoredBottleCollection

NewViewedStoredBottleCollection initializes viewed result type StoredBottleCollection from result type StoredBottleCollection using the given view.

Types

type Bottle

type Bottle struct {
	// Name of bottle
	Name string
	// Winery that produces wine
	Winery *Winery
	// Vintage of bottle
	Vintage uint32
	// Composition is the list of grape varietals and associated percentage.
	Composition []*Component
	// Description of bottle
	Description *string
	// Rating of bottle from 1 (worst) to 5 (best)
	Rating *uint32
}

Bottle is the payload type of the storage service add method.

type Client

type Client struct {
	ListEndpoint        goa.Endpoint
	ShowEndpoint        goa.Endpoint
	AddEndpoint         goa.Endpoint
	RemoveEndpoint      goa.Endpoint
	RateEndpoint        goa.Endpoint
	MultiAddEndpoint    goa.Endpoint
	MultiUpdateEndpoint goa.Endpoint
}

Client is the "storage" service client.

func NewClient

func NewClient(list, show, add, remove, rate, multiAdd, multiUpdate goa.Endpoint) *Client

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

func (*Client) Add

func (c *Client) Add(ctx context.Context, p *Bottle) (res string, err error)

Add calls the "add" endpoint of the "storage" service.

func (*Client) List

func (c *Client) List(ctx context.Context) (res StoredBottleCollection, err error)

List calls the "list" endpoint of the "storage" service.

func (*Client) MultiAdd

func (c *Client) MultiAdd(ctx context.Context, p []*Bottle) (res []string, err error)

MultiAdd calls the "multi_add" endpoint of the "storage" service.

func (*Client) MultiUpdate

func (c *Client) MultiUpdate(ctx context.Context, p *MultiUpdatePayload) (err error)

MultiUpdate calls the "multi_update" endpoint of the "storage" service.

func (*Client) Rate

func (c *Client) Rate(ctx context.Context, p map[uint32][]string) (err error)

Rate calls the "rate" endpoint of the "storage" service.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, p *RemovePayload) (err error)

Remove calls the "remove" endpoint of the "storage" service. Remove may return the following errors:

  • "not_found" (type *NotFound): Bottle not found
  • error: internal error

func (*Client) Show

func (c *Client) Show(ctx context.Context, p *ShowPayload) (res *StoredBottle, err error)

Show calls the "show" endpoint of the "storage" service. Show may return the following errors:

  • "not_found" (type *NotFound): Bottle not found
  • error: internal error

type Component

type Component struct {
	// Grape varietal
	Varietal string
	// Percentage of varietal in wine
	Percentage *uint32
}

type Endpoints

type Endpoints struct {
	List        goa.Endpoint
	Show        goa.Endpoint
	Add         goa.Endpoint
	Remove      goa.Endpoint
	Rate        goa.Endpoint
	MultiAdd    goa.Endpoint
	MultiUpdate goa.Endpoint
}

Endpoints wraps the "storage" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

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

func (*Endpoints) Use

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

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

type MultiUpdatePayload

type MultiUpdatePayload struct {
	// IDs of the bottles to be updated
	Ids []string
	// Array of bottle info that matches the ids attribute
	Bottles []*Bottle
}

MultiUpdatePayload is the payload type of the storage service multi_update method.

type NotFound

type NotFound struct {
	// Message of error
	Message string
	// ID of missing bottle
	ID string
}

NotFound is the type returned when attempting to show or delete a bottle that does not exist.

func (*NotFound) Error

func (e *NotFound) Error() string

Error returns an error description.

func (*NotFound) ErrorName

func (e *NotFound) ErrorName() string

ErrorName returns "NotFound".

type RemovePayload

type RemovePayload struct {
	// ID of bottle to remove
	ID string
}

RemovePayload is the payload type of the storage service remove method.

type Service

type Service interface {
	// List all stored bottles
	List(context.Context) (res StoredBottleCollection, err error)
	// Show bottle by ID
	// The "view" return value must have one of the following views
	//	- "default"
	//	- "tiny"
	Show(context.Context, *ShowPayload) (res *StoredBottle, view string, err error)
	// Add new bottle and return its ID.
	Add(context.Context, *Bottle) (res string, err error)
	// Remove bottle from storage
	Remove(context.Context, *RemovePayload) (err error)
	// Rate bottles by IDs
	Rate(context.Context, map[uint32][]string) (err error)
	// Add n number of bottles and return their IDs. This is a multipart request
	// and each part has field name 'bottle' and contains the encoded bottle info
	// to be added.
	MultiAdd(context.Context, []*Bottle) (res []string, err error)
	// Update bottles with the given IDs. This is a multipart request and each part
	// has field name 'bottle' and contains the encoded bottle info to be updated.
	// The IDs in the query parameter is mapped to each part in the request.
	MultiUpdate(context.Context, *MultiUpdatePayload) (err error)
}

The storage service makes it possible to view, add or remove wine bottles.

type ShowPayload

type ShowPayload struct {
	// ID of bottle to show
	ID string
	// View to render
	View *string
}

ShowPayload is the payload type of the storage service show method.

type StoredBottle

type StoredBottle struct {
	// ID is the unique id of the bottle.
	ID string
	// Name of bottle
	Name string
	// Winery that produces wine
	Winery *Winery
	// Vintage of bottle
	Vintage uint32
	// Composition is the list of grape varietals and associated percentage.
	Composition []*Component
	// Description of bottle
	Description *string
	// Rating of bottle from 1 (worst) to 5 (best)
	Rating *uint32
}

StoredBottle is the result type of the storage service show method.

func NewStoredBottle

func NewStoredBottle(vres *storageviews.StoredBottle) *StoredBottle

NewStoredBottle initializes result type StoredBottle from viewed result type StoredBottle.

type StoredBottleCollection

type StoredBottleCollection []*StoredBottle

StoredBottleCollection is the result type of the storage service list method.

func NewStoredBottleCollection

func NewStoredBottleCollection(vres storageviews.StoredBottleCollection) StoredBottleCollection

NewStoredBottleCollection initializes result type StoredBottleCollection from viewed result type StoredBottleCollection.

type Winery

type Winery struct {
	// Name of winery
	Name string
	// Region of winery
	Region string
	// Country of winery
	Country string
	// Winery website URL
	URL *string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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