services

package
v0.0.0-...-5ba66fb Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 6 Imported by: 0

README

Services Layer

  • Purpose: The services layer contains the business logic of the application. It's where you define the rules and operations that your application needs to perform.
  • Functions: After data is fetched or before it's saved to the database, the services layer processes it, applies business rules, makes decisions, orchestrates transactions, etc.
  • Interaction with Data: While it uses data accessed through the repository layer, it's more concerned with what to do with this data - validating it, transforming it, applying business rules, etc.
  • Benefits: Separating business logic into a dedicated layer makes the code easier to test, maintain, and extend. It also means that changes in business requirements are less likely to require changes in the data access layer.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentService

type CommentService interface {
	PostComment(ctx context.Context, comment *models.Comment) error
	GetComments(ctx context.Context, videoID string) ([]models.Comment, error)
}

func NewCommentService

func NewCommentService(commentRepo repositories.CommentRepository, pubSubService *pubsubclient.PubSubService) CommentService

type LikeService

type LikeService interface {
	AddLike(ctx context.Context, like *models.Like) error
	GetLikes(ctx context.Context, videoID string) ([]models.Like, error)
}

func NewLikeService

func NewLikeService(likeRepo repositories.LikeRepository, pubSubService *pubsubclient.PubSubService) LikeService

type Services

type Services struct {
	UserService    *UserService
	VideoService   *VideoService
	CommentService *CommentService
	LikeService    *LikeService
}

Services struct encapsulates all the service layer dependencies TODO: Implement abstraction layer for services

type UserService

type UserService interface {
	RegisterUser(ctx context.Context, user *models.User) error
	GetUser(ctx context.Context, id string) (*models.User, error)
}

func NewUserService

func NewUserService(userRepo repositories.UserRepository, pubSubService *pubsubclient.PubSubService) UserService

type VideoService

type VideoService interface {
	UploadVideo(ctx context.Context, video *models.Video) error
	GetAllVideos(ctx context.Context) ([]models.Video, error)
}

func NewVideoService

func NewVideoService(videoRepo repositories.VideoRepository, pubSubService *pubsubclient.PubSubService) VideoService

NewVideoService initializes a new VideoService with the given VideoRepository and PubSubService

Jump to

Keyboard shortcuts

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