service

package
v0.0.0-...-1aaf684 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCanceled is used when the request cannot be satisfied on time
	ErrCanceled = errors.New("timeout or canceled")
	// ErrNotFound is used when the given resource was not found
	ErrNotFound = errors.New("resource not found")
)
View Source
var (
	// ErrBadRouting is returned when an expected path variable is missing.
	// It always indicates programmer error.
	ErrBadRouting = errors.New("inconsistent mapping between route and handler (programmer error)")
)

Functions

func MakeDeleteLeaseClientEndpoint

func MakeDeleteLeaseClientEndpoint(s Service) endpoint.Endpoint

MakeDeleteLeaseClientEndpoint creates an endpoint for the DeleteClient service

func MakeDeleteLeaseDistccEndpoint

func MakeDeleteLeaseDistccEndpoint(s Service) endpoint.Endpoint

MakeDeleteLeaseDistccEndpoint creates an endpoint for the DeleteDistcc service

func MakeHTTPHandler

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

MakeHTTPHandler mounts all of the service endpoints into an http.Handler.

func MakePutLeaseClientEndpoint

func MakePutLeaseClientEndpoint(s Service) endpoint.Endpoint

MakePutLeaseClientEndpoint creates an endpoint for the LeaseDistccClient service

func MakePutLeaseDistccEndpoint

func MakePutLeaseDistccEndpoint(s Service) endpoint.Endpoint

MakePutLeaseDistccEndpoint creates an endpoint for the LeaseDistcc service

Types

type ClientLease

type ClientLease struct {
	// Expiration is the time at which the lease will end.
	Expiration time.Time `json:"expiration"`
	// NodePort is the port allocated for the service.
	//
	// The service will be accessible from any host with an external
	// interface running on the cluster.
	NodePort int `json:"nodePort,omitempty"`
}

ClientLease contains info about a lease for a specific user and tag.

type DistccLease

type DistccLease struct {
	// Expiration is the time at which the lease will end.
	Expiration time.Time `json:"expiration"`
	// Endpoints is the list of hosts that can be used to access the resoure
	// being leased.
	Endpoints []string `json:"endpoints,omitempty"`
	// Replicas is the number of replicas sitting behind the endpoints.
	//
	// This might be useful to determine the number of replicas behind the
	// given endpoints.
	Replicas int `json:"replicas,omitempty"`
}

DistccLease contains info about a lease for a specific user and tag.

type Endpoints

type Endpoints struct {
	PutLeaseDistccEndpoint    endpoint.Endpoint
	DeleteLeaseDistccEndpoint endpoint.Endpoint
	PutLeaseClientEndpoint    endpoint.Endpoint
	DeleteLeaseClientEndpoint endpoint.Endpoint
}

Endpoints collects all the api endpoints in a single struct

func MakeEndpoints

func MakeEndpoints(s Service) Endpoints

MakeEndpoints creates the api endpoints, wiring in the given service

type Middleware

type Middleware func(Service) Service

Middleware describes a service (as opposed to endpoint) middleware.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

LoggingMiddleware implements a service with logging

type Service

type Service interface {
	LeaseDistcc(ctx context.Context, u data.User, t data.Tag) (DistccLease, error)
	DeleteDistcc(ctx context.Context, u data.User, t data.Tag) error
	LeaseClient(ctx context.Context, u data.User, t data.Tag) (ClientLease, error)
	DeleteClient(ctx context.Context, u data.User, t data.Tag) error
}

Service is an interface that implements all the APIs.

func NewService

func NewService(sharedclient *controller.SharedClient, logger log.Logger) Service

NewService creates the API service

Jump to

Keyboard shortcuts

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