service

package
v0.0.0-...-01347ba Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code = string

Code is a code that uniquely identifies a Service

type Endpoint

type Endpoint struct {
	// ID uniquely identifies this endpoint
	ID *int64
	// Code is a unique code for the Endpoint. Doesn't have to be globally unique, just unique per service. For example,
	// "POST /locations" or "GET /locations/:id"
	Code EndpointCode
	// Name is a friendly name for the Endpoint. For example, "Create location" or "Get location by id"
	Name EndpointName
	// Dependencies is a map of Dependencies for a given Endpoint. Keys are service codes, values are lists of endpoint codes
	Dependencies map[Code][]EndpointCode
}

Endpoint represents an Endpoint of a Service

type EndpointCode

type EndpointCode = string

EndpointCode is a code that uniquely identifies an Endpoint. It need not be globally unique, only unique within that one Service

type EndpointName

type EndpointName = string

EndpointName is the human-readable/friedly name of an Endpoint

type Name

type Name = string

Name is the human-readable/friedly name of a Service

type Repository

type Repository interface {
	// Save saves a Service
	Save(s *Service) error
	// FindByCode finds a Service by its Code
	FindByCode(code Code) (*Service, error)
}

Repository is a Service repository. It is a classic "Domain Driven Design" repository - the mental model is that it represents a collection of models.Service instances

func NewRepository

func NewRepository(
	dbURL *dburl.URL,
	db *sqlx.DB,
	logger *zap.SugaredLogger,
) Repository

type Service

type Service struct {
	// ID uniquely identifies this service
	ID *int64
	// Code is a unique code for the service. For example, "location_tracking" for a location tracking service
	Code Code
	// Name is a friendly name for the service. For example, "Location Tracking" for a location tracking service
	Name Name
	// Endpoints is a list of Endpoints that the Service has
	Endpoints []Endpoint
}

Service represents a service

func MakeService

func MakeService(
	id *int64,
	code Code,
	name Name,
	endpoints []Endpoint,
) Service

MakeService constructs a Service

Jump to

Keyboard shortcuts

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