service

package
v0.0.0-...-e9c9027 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counters

type Counters struct {
	CreateUserRequest           metrics.Counter
	SuccessfulCreateUserRequest metrics.Counter
	FailedCreateUserRequest     metrics.Counter
	GetUserRequest              metrics.Counter
	SuccessfulGetUserRequest    metrics.Counter
	FailedGetUserRequest        metrics.Counter
	SuccessfulLogInRequest      metrics.Counter
	FailedLogInRequest          metrics.Counter
	Duration                    metrics.Histogram
}

Counters is a type encompassing metrics for API definitions associated with the user microservice

type Middleware

type Middleware func(Service) Service

Middleware describes a service specific middleware

func InstrumentingMiddleware

func InstrumentingMiddleware(counters Counters) Middleware

InstrumentingMiddleware returns a service middleware that instruments the number of users created over the lifetime of the service.

func LoggingMiddleware

func LoggingMiddleware(logger *zap.Logger) Middleware

LoggingMiddleware returns a logging middleware that logs request specific information. From input arguments, to errors

type Service

type Service interface {
	// CreateUser effectively creates/adds a user object to the backend data store
	// if it doesm't already exist.
	CreateUser(ctx context.Context, user user_service.UserORM) (err error)

	// GetUserById queries the backend datastore for user objects based on a
	// passed in user id parameter.
	GetUserById(ctx context.Context, id string) (user user_service.UserORM, err error)

	// GetUserByEmail queries the backend datastore for user objects based on a
	// passed in user email parameter.
	GetUserByEmail(ctx context.Context, email string) (user user_service.UserORM, err error)

	// GetUserByUsername queries the backend datastore for user objects based on a
	// passed in user username parameter.
	GetUserByUsername(ctx context.Context, username string) (user user_service.UserORM, err error)

	// LogIn Checks if a user object exists in the backend datastore, performs some password checks,
	// and attempts to log a given user into the system
	LogIn(ctx context.Context, username, password string) (user user_service.UserORM, err error)
}

Service is a CRUD interface definition for the user microservice

func New

func New(logger *zap.Logger, db *gorm.DB, amqpProducer queues.Queue, amqpConsumer queues.Queue, counters Counters) Service

New returns a basic Service with all of the expected middlewares wired in.

func NewBasicService

func NewBasicService(db *gorm.DB, logger *zap.Logger, amqpProducer queues.Queue, amqpConsumer queues.Queue) Service

NewBasicService returns a naïve, stateless implementation of Service.

Jump to

Keyboard shortcuts

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