service

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: Apache-2.0 Imports: 35 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ParamsType  = "params"
	FormsType   = "forms"
	HeadersType = "headers"
)

Variables

This section is empty.

Functions

func ByteToStream

func ByteToStream(data []byte) io.Reader

func CheckToken

func CheckToken(c *fiber.Ctx) error

func CreateFile

func CreateFile(file []byte) (*os.File, error)

func DownloadFile

func DownloadFile(filepath string, url string) error

func GetWidthAndHeight

func GetWidthAndHeight(c *fiber.Ctx, requestType string) (bool, uint, uint)

func ImageToByte

func ImageToByte(img string) []byte

func IsImageFile

func IsImageFile(filename string) bool

func IsInt

func IsInt(one, two string) bool

func MinioClient

func MinioClient() *minio.Client

func RandomName

func RandomName(length int) string

func RatioWidthHeight

func RatioWidthHeight(width, height, targetWidth, targetHeight uint) (uint, uint)

func ReadEnvAndSet added in v1.2.2

func ReadEnvAndSet() error

func Response

func Response(c *fiber.Ctx, code int, status bool, message string, result any) error

func SetWidthToHeight

func SetWidthToHeight(width, height string) (string, string)

func StreamToByte

func StreamToByte(stream io.Reader) []byte

Types

type AwsService

type AwsService interface {
	GlacierVaultList() *glacier.ListVaultsOutput
	GlacierUploadArchive(vaultName string, fileBuffer []byte) (*glacier.UploadArchiveOutput, error)
	S3PutObject(bucketName string, objectName string, fileBuffer io.Reader) (*manager.UploadOutput, error)
	ListBuckets() ([]types.Bucket, error)
	BucketExists(bucketName string) bool
	DeleteObjects(bucketName string, objectKeys []string) error
	IsConnected() bool
}

func NewAwsService

func NewAwsService() AwsService

type CacheService added in v1.5.0

type CacheService interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte, expiration time.Duration) error
	Delete(key string) error
	GetResizedImage(bucket, path string, width, height uint) ([]byte, error)
	SetResizedImage(bucket, path string, width, height uint, data []byte) error
	FlushAll() error
	Close() error
}

func NewCacheService added in v1.5.0

func NewCacheService(redisURL string) (CacheService, error)

type ImageService added in v1.5.0

type ImageService struct {
	MinioClient *minio.Client
}

func (*ImageService) GetImage added in v1.5.0

func (s *ImageService) GetImage(bucket, objectName string, width, height int) ([]byte, error)

GetImage gets an image from storage and optionally resizes it

func (*ImageService) GetImageInfo added in v1.5.0

func (s *ImageService) GetImageInfo(data []byte) (width uint, height uint, format string, err error)

GetImageInfo returns width, height and format of an image

func (*ImageService) ImagickFormat added in v1.5.0

func (s *ImageService) ImagickFormat(image []byte) (error, string)

func (*ImageService) ImagickGetWidthHeight added in v1.5.0

func (s *ImageService) ImagickGetWidthHeight(image []byte) (error, uint, uint)

func (*ImageService) ImagickResize added in v1.5.0

func (s *ImageService) ImagickResize(image []byte, targetWidth, targetHeight uint) []byte

func (*ImageService) IsImageFile added in v1.5.0

func (s *ImageService) IsImageFile(data []byte) bool

IsImageFile checks if the file is a valid image by examining its content (magic bytes)

func (*ImageService) IsResizable added in v1.5.0

func (s *ImageService) IsResizable(data []byte) bool

IsResizable checks if the file is a valid image that can be resized

func (*ImageService) ProcessImage added in v1.5.0

func (s *ImageService) ProcessImage(data []byte) ([]byte, error)

ProcessImage processes an image (resize, optimize, etc.)

func (*ImageService) ResizeImage added in v1.5.0

func (s *ImageService) ResizeImage(data []byte, width, height int) ([]byte, error)

ResizeImage resizes an image to the specified dimensions

type StatsService added in v1.5.0

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

func NewStatsService added in v1.5.0

func NewStatsService() *StatsService

func (*StatsService) AddUploadBytes added in v1.5.0

func (s *StatsService) AddUploadBytes(bytes int64)

func (*StatsService) DecrementActiveUploads added in v1.5.0

func (s *StatsService) DecrementActiveUploads()

func (*StatsService) GetActiveUploads added in v1.5.0

func (s *StatsService) GetActiveUploads() int

func (*StatsService) GetCPUUsage added in v1.5.0

func (s *StatsService) GetCPUUsage() float64

func (*StatsService) GetCacheHitRate added in v1.5.0

func (s *StatsService) GetCacheHitRate() float64

func (*StatsService) GetDiskUsage added in v1.5.0

func (s *StatsService) GetDiskUsage() map[string]int64

func (*StatsService) GetMemoryUsage added in v1.5.0

func (s *StatsService) GetMemoryUsage() float64

func (*StatsService) GetRecentErrors added in v1.5.0

func (s *StatsService) GetRecentErrors() []string

func (*StatsService) GetUploadSpeed added in v1.5.0

func (s *StatsService) GetUploadSpeed() float64

func (*StatsService) IncrementActiveUploads added in v1.5.0

func (s *StatsService) IncrementActiveUploads()

func (*StatsService) IncrementCacheHit added in v1.5.0

func (s *StatsService) IncrementCacheHit()

func (*StatsService) IncrementCacheMiss added in v1.5.0

func (s *StatsService) IncrementCacheMiss()

func (*StatsService) LogError added in v1.5.0

func (s *StatsService) LogError(err string)

Jump to

Keyboard shortcuts

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