cycles

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

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateCreateRequest

func ValidateCreateRequest(c *cyclesProto.CreateCycleRequest) error

ValidateCreateRequest validates the CreateCycleRequest fields.

func ValidateUpdateRequest

func ValidateUpdateRequest(u *cyclesProto.UpdateCycleRequest) error

Validate validates the UpdateCycleRequest fields.

Types

type API

type API interface {
	grpcgw.Controller
	cycles.CycleServiceServer
}

func New

func New(srv Service) API

type Repository

type Repository interface {
	// Get returns the cycle with the specified cycle UUID.
	Get(ctx context.Context, uuid string) (entity.Cycle, error)
	// Count returns the number of cycles.
	Count(ctx context.Context) (int64, error)
	// Query returns the list of cycles with the given offset and limit.
	Query(ctx context.Context, offset, limit int64) ([]entity.Cycle, int, error)
	// Create saves a new cycle in the storage.
	Create(ctx context.Context, cycle entity.Cycle) error
	// Update updates the cycle with given UUID in the storage.
	Update(ctx context.Context, cycle entity.Cycle) error
	// Delete removes the cycle with given UUID from the storage.
	Delete(ctx context.Context, uuid string) error
}

Repository encapsulates the logic to access cycles from the data source.

func NewRepository

func NewRepository(db *db.DB) Repository

NewRepository creates a new cycle repository

type Service

type Service interface {
	Get(ctx context.Context, uuid string) (*cyclesProto.Cycle, error)
	Query(ctx context.Context, offset, limit int64) (*cyclesProto.ListCyclesResponse, error)
	Count(ctx context.Context) (int64, error)
	Create(ctx context.Context, input *cyclesProto.CreateCycleRequest) (*cyclesProto.Cycle, error)
	Update(ctx context.Context, input *cyclesProto.UpdateCycleRequest) (*cyclesProto.Cycle, error)
	Delete(ctx context.Context, uuid string) (*cyclesProto.Cycle, error)
}

Service encapsulates use case logic for cycles.

func NewService

func NewService(repo Repository, userSrv users.Service) Service

NewService creates a new cycle service.

func NewServiceForTest

func NewServiceForTest(userSrv users.Service) Service

NewServiceForTest creates a new user service for test.

Jump to

Keyboard shortcuts

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