service

package
v0.0.0-...-caa39d1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPageSize is the default number of messages returned per page when not specified
	DefaultPageSize = 20
	// MaxPageSize is the maximum number of messages that can be returned per page
	// This prevents excessive memory usage and ensures reasonable response times
	MaxPageSize = 100
	// MinPageSize is the minimum page size allowed (must be at least 1)
	MinPageSize = 1
	// MinPage is the minimum page number (pages start from 1)
	MinPage = 1
)

Pagination constants

View Source
const MAXIMUM_MESSAGE_SENDING_TIME = 5 * time.Second

Variables

View Source
var (
	ErrInvalidPageSize  = errors.New("page size cannot be negative")
	ErrPageSizeTooLarge = fmt.Errorf("page size cannot exceed %d", MaxPageSize)
	ErrPageSizeTooSmall = fmt.Errorf("page size must be at least %d", MinPageSize)
	ErrMessageNotFound  = errors.New("message not found")
	ErrInvalidMessageID = errors.New("invalid message ID format")
)

Pagination errors

Functions

This section is empty.

Types

type MessageInterface

type MessageInterface interface {
	GetSentMessages(ctx context.Context, page, pageSize int) (*dto.MessagesListResponse, error)
	GetMessageByID(ctx context.Context, id string) (*dto.SingleMessageResponse, error)
}

MessageInterface defines message-related operations

type MessageService

type MessageService struct {
	// contains filtered or unexported fields
}

func NewMessageService

func NewMessageService(database *bun.DB) *MessageService

func (*MessageService) GetMessageByID

func (s *MessageService) GetMessageByID(ctx context.Context, id string) (*dto.SingleMessageResponse, error)

GetMessageByID retrieves a single message by its ID

func (*MessageService) GetSentMessages

func (s *MessageService) GetSentMessages(ctx context.Context, page, pageSize int) (*dto.MessagesListResponse, error)

GetSentMessages retrieves paginated sent messages Parameters: - page: Page number (starts from 1, defaults to 1 if < 1) - pageSize: Number of messages per page (0 = default, must be between 1-100) Returns error if pageSize is invalid (negative or > 100)

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler handles the automatic message sending functionality

func NewScheduler

func NewScheduler(database *bun.DB, cfg *config.Cfg) *Scheduler

func (*Scheduler) GetStatus

func (s *Scheduler) GetStatus() *dto.MessagingStatusResponse

GetStatus returns the current status of the messaging service

func (*Scheduler) IsRunning

func (s *Scheduler) IsRunning() bool

IsRunning returns whether the messaging service is currently running

func (*Scheduler) Start

Start begins the automatic message sending process

func (*Scheduler) Stop

Stop halts the automatic message sending process

type SchedulerInterface

type SchedulerInterface interface {
	Start(ctx context.Context) (*dto.MessagingControlResponse, error)
	Stop(ctx context.Context) (*dto.MessagingControlResponse, error)
	GetStatus() *dto.MessagingStatusResponse
	IsRunning() bool
}

SchedulerInterface defines messaging scheduler control operations

Jump to

Keyboard shortcuts

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