example

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

Example service

Boilerplate for architecture of a service based on go-kit (repo).

Service - is where all of the business logic is implemented. A service usually glues together multiple endpoints. In Go kit, services are typically modeled as interfaces, and implementations of those interfaces contain the business logic. Go kit services should strive to abide the Clean Architecture or the Hexagonal Architecture. That is, the business logic should have no knowledge of endpoint- or especially transport-domain concepts: your service shouldn’t know anything about HTTP headers, or gRPC error codes.

Endpoints is like an action/handler on a controller; it’s where safety and antifragile logic lives. If you implement two transports (HTTP and gRPC), you might have two methods of sending requests to the same endpoint.

Transport is bound to concrete transports like HTTP or gRPC. In a world where microservices may support one or more transports, this is very powerful; you can support a legacy HTTP API and a newer RPC service, all in a single microservice.

To get more details go to the official documentation - go-kit - architecture and design.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidParameter = errors.New("invalid parameter")
	ErrNotFound         = errors.New("not found")
)

Predefined package errors

Functions

func MakeExampleEndpoint

func MakeExampleEndpoint(s service) endpoint.Endpoint

MakeExampleEndpoint ...

func MakeHTTPHandler

func MakeHTTPHandler(e Endpoints, log logger) http.Handler

MakeHTTPHandler ...

Types

type Endpoints

type Endpoints struct {
	Example endpoint.Endpoint
}

Endpoints collection of profile service

func MakeEndpoints

func MakeEndpoints(s service, m ...endpoint.Middleware) Endpoints

Init endpoints

type Service

type Service struct {
}

Service struct

func NewService

func NewService() *Service

NewService is a factory function, returns a new instance of the Service interface implementation

func (*Service) Example

func (s *Service) Example(ctx context.Context, uid uuid.UUID) (string, error)

Example ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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