service

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyContent    = callback.NewBizError(callback.CodeBadRequest, "content is empty")
	ErrTextTooLarge    = callback.NewBizError(callback.CodeFileTooLarge, "text content exceeds maximum size")
	ErrFileTooLarge    = callback.NewBizError(callback.CodeFileTooLarge, "file exceeds maximum size")
	ErrInvalidMIMEType = callback.NewBizError(callback.CodeBadRequest, "unsupported image type")
	ErrClipNotFound    = callback.NewBizError(callback.CodeNotFound, "clip not found")
	ErrNotImageClip    = callback.NewBizError(callback.CodeNotFound, "file not found")
	ErrHashMismatch    = callback.NewBizError(callback.CodeBadRequest, "content hash mismatch")
)

Functions

This section is empty.

Types

type ClipService

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

ClipService implements the core business logic for clip management.

func NewClipService

func NewClipService(store *store.ClipStore, hub *ws.Hub, cfg *config.ServerConfig) *ClipService

NewClipService creates a new ClipService.

func (*ClipService) CleanExpired

func (s *ClipService) CleanExpired() (timerCh <-chan time.Time, kick <-chan struct{})

CleanExpired removes all expired clips and broadcasts each removal. Returns timer channel and kick channel for the cleaner loop.

func (*ClipService) CreateImage

func (s *ClipService) CreateImage(file *multipart.FileHeader, ttl time.Duration, clientHash string) (*model.Clip, error)

CreateImage creates an image clip, saving the file to disk with rollback on failure.

func (*ClipService) CreateText

func (s *ClipService) CreateText(content string, ttl time.Duration, clientHash string) (*model.Clip, error)

CreateText creates a text clip after validating content constraints.

func (*ClipService) Delete

func (s *ClipService) Delete(id string) error

Delete removes a clip and broadcasts the expiry event.

func (*ClipService) GetFilePath

func (s *ClipService) GetFilePath(id string) (string, string, error)

GetFilePath returns the on-disk path for an image clip's file.

func (*ClipService) StartCleaner

func (s *ClipService) StartCleaner(ctx context.Context)

StartCleaner launches a goroutine that cleans expired clips on precise timers.

func (*ClipService) ValidateTTL

func (s *ClipService) ValidateTTL(requested time.Duration) time.Duration

ValidateTTL clamps the requested TTL within [MinTTL, MaxTTL].

Jump to

Keyboard shortcuts

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