fetcher

package
v2.2.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "fetcher"

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 = [1]string{"fetch"}

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 MakeBadRequest

func MakeBadRequest(err error) *goa.ServiceError

MakeBadRequest builds a goa.ServiceError from an error.

func MakeInternalError

func MakeInternalError(err error) *goa.ServiceError

MakeInternalError builds a goa.ServiceError from an error.

func NewFetchEndpoint

func NewFetchEndpoint(s Service) endpoint.Endpoint

NewFetchEndpoint returns an endpoint function that calls the method "fetch" of service "fetcher".

func NewViewedFetchMedia

func NewViewedFetchMedia(res *FetchMedia, view string) *fetcherviews.FetchMedia

NewViewedFetchMedia initializes viewed result type FetchMedia from result type FetchMedia using the given view.

Types

type Client

type Client struct {
	FetchEndpoint endpoint.Endpoint
}

Client is the "fetcher" service client.

func NewClient

func NewClient(fetch endpoint.Endpoint) *Client

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

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, p *FetchPayload) (res *FetchMedia, err error)

Fetch calls the "fetch" endpoint of the "fetcher" service. Fetch may return the following errors:

  • "bad_request" (type *goa.ServiceError)
  • "internal_error" (type *goa.ServiceError)
  • error: internal error

type Endpoints

type Endpoints struct {
	Fetch endpoint.Endpoint
}

Endpoints wraps the "fetcher" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

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

func (*Endpoints) Use

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

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

type FetchMedia

type FetchMedia struct {
	// HTTP status code returned by fetched service
	Status int
	// The href to the corresponding archive in the archiver service
	ArchiveHref string
}

FetchMedia is the result type of the fetcher service fetch method.

func NewFetchMedia

func NewFetchMedia(vres *fetcherviews.FetchMedia) *FetchMedia

NewFetchMedia initializes result type FetchMedia from viewed result type FetchMedia.

type FetchPayload

type FetchPayload struct {
	// URL to be fetched
	URL string
}

FetchPayload is the payload type of the fetcher service fetch method.

type Service

type Service interface {
	// Fetch makes a GET request to the given URL and stores the results in the
	// archiver service which must be running or the request fails
	Fetch(context.Context, *FetchPayload) (res *FetchMedia, err error)
}

Service is the fetcher service interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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