adding

package
v0.0.0-...-b7fba14 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPlanetNotFound = errors.New("planet not found")

Functions

This section is empty.

Types

type Planet

type Planet struct {
	Name        string `json:"name" valid:"length(2|128)"`
	Climate     string `json:"climate" valid:"length(2|128)"`
	Terrain     string `json:"terrain" valid:"length(2|128)"`
	Appearances int    `json:"appearances" valid:"optional"`
}

Planet defines the properties of a planet to be added

type PlanetsClient

type PlanetsClient interface {
	GetPlanetAppearances(context.Context, string) (int, error)
}

PlanetsClient provides an interface to fetch extra planets info from a third-party API

type Repository

type Repository interface {
	// AddPlanet saves a given planet to the repository.
	AddPlanet(context.Context, Planet) (string, error)
}

Repository provides access to planet repository.

type Service

type Service interface {
	// AddPlanet invokes the operations needed to save a planet
	AddPlanet(context.Context, Planet) (string, error)
}

Service provides planet adding operations.

func NewService

func NewService(r Repository, p PlanetsClient) Service

NewService creates an adding service with the necessary dependencies

type ValidationError

type ValidationError struct {
	Err    error
	Fields map[string]string
}

ValidationError defines the type for a validation error

func NewValidationError

func NewValidationError(err error) *ValidationError

func (ValidationError) Error

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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