service

package
v0.0.0-...-bc0265b Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInconsistentIDs = errors.New("inconsistent IDs")
	ErrAlreadyExists   = errors.New("already exists")
	ErrNotFound        = errors.New("not found")
)
View Source
var (
	ErrBadRouting = errors.New("inconsistent mapping between route and handler (programmer error)")
)

Functions

func MakeDeleteServiceInfoEndpoint

func MakeDeleteServiceInfoEndpoint(s Service) endpoint.Endpoint

func MakeGetServiceInfoEndpoint

func MakeGetServiceInfoEndpoint(s Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(s Service, logger log.Logger) http.Handler

func MakePostServiceInfoEndpoint

func MakePostServiceInfoEndpoint(s Service) endpoint.Endpoint

func MakePutServiceInfoEndpoint

func MakePutServiceInfoEndpoint(s Service) endpoint.Endpoint

Types

type Endpoints

type Endpoints struct {
	PostServiceInfoEndpoint   endpoint.Endpoint
	GetServiceInfoEndpoint    endpoint.Endpoint
	PutServiceInfoEndpoint    endpoint.Endpoint
	DeleteServiceInfoEndpoint endpoint.Endpoint
}

func MakeClientEndpoints

func MakeClientEndpoints(instance string) (Endpoints, error)

func MakeServerEndpoints

func MakeServerEndpoints(s Service) Endpoints

func (Endpoints) DeleteServiceInfo

func (e Endpoints) DeleteServiceInfo(ctx context.Context, id string) error

func (Endpoints) GetServiceInfo

func (e Endpoints) GetServiceInfo(ctx context.Context, id string) (ServiceInfo, error)

func (Endpoints) PostServiceInfo

func (e Endpoints) PostServiceInfo(ctx context.Context, h ServiceInfo) error

func (Endpoints) PutServiceInfo

func (e Endpoints) PutServiceInfo(ctx context.Context, id string, h ServiceInfo) error

type Middleware

type Middleware func(Service) Service

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

type MiddlewareService

type MiddlewareService func(Service) Service

func HostMiddleware

func HostMiddleware(hostInfo host.Host) MiddlewareService

type Service

type Service interface {
	PostServiceInfo(ctx context.Context, h ServiceInfo) error
	GetServiceInfo(ctx context.Context, id string) (ServiceInfo, error)
	PutServiceInfo(ctx context.Context, id string, h ServiceInfo) error
	DeleteServiceInfo(ctx context.Context, id string) error
}

func NewInmemService

func NewInmemService() Service

type ServiceInfo

type ServiceInfo struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	HostID    string    `json:"hostid"`
	CreatedAt time.Time `json:"createtime"`
	UpdatedAt time.Time `json:"updatetime"`
	Remark    string    `json:"remark"`
}

Jump to

Keyboard shortcuts

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