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 }
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 ¶
NewServiceForTest creates a new user service for test.
Click to show internal directories.
Click to hide internal directories.