api

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownError         = "UNKNOWN_ERROR"
	InvalidRequest       = "INVALID_REQUEST"
	FileNotFound         = "FILE_NOT_FOUND"
	FileDeleted          = "FILE_DELETED"
	IllegalFormat        = "ILLEGAL_FORMAT"
	InvalidAuthorization = "INVALID_AUTHORIZATION"
)
View Source
const (
	FileStatusNormal    = "NORMAL"  // file.status - normal
	FileStatusLogicDel  = "LOG_DEL" // file.status - logically deleted
	FileStatusPhysicDel = "PHY_DEL" // file.status - physically deleted
)

Variables

View Source
var (
	ErrFileNotFound  = errors.New("file not found")
	ErrFileDeleted   = errors.New("file deleted")
	ErrIllegalFormat = errors.New("illegal format")

	ErrMapper = map[string]error{
		FileNotFound:  ErrFileNotFound,
		FileDeleted:   ErrFileDeleted,
		IllegalFormat: ErrIllegalFormat,
	}
)
View Source
var (
	// Pipeline to trigger async image thumbnail generation.
	//
	// Reply api.ImageCompressReplyEvent when the processing succeeds.
	GenImgThumbnailPipeline = rabbit.NewEventPipeline[ImgThumbnailTriggerEvent]("event.bus.fstore.image.compress.processing").
							LogPayload().
							MaxRetry(10).
							Document("GenImgThumbnailPipeline", "Pipeline to trigger async image thumbnail generation, will reply api.ImageCompressReplyEvent when the processing succeeds.", "fstore")

	// Pipeline to trigger async video thumbnail generation.
	//
	// Reply api.GenVideoThumbnailReplyEvent when the processing succeeds.
	GenVidThumbnailPipeline = rabbit.NewEventPipeline[VidThumbnailTriggerEvent]("event.bus.fstore.video.thumbnail.processing").
							LogPayload().
							MaxRetry(10).
							Document("GenVidThumbnailPipeline", "Pipeline to trigger async video thumbnail generation, will reply api.GenVideoThumbnailReplyEvent when the processing succeeds.", "fstore")
)

Functions

func DeleteFile added in v0.1.7

func DeleteFile(rail miso.Rail, fileId string) error

func DownloadFile added in v0.1.7

func DownloadFile(rail miso.Rail, tmpToken string, writer io.Writer) error

func DownloadFileDirect added in v0.1.11

func DownloadFileDirect(rail miso.Rail, fileId string, writer io.Writer) error

func GenTempFileKey added in v0.1.7

func GenTempFileKey(rail miso.Rail, fileId string, filename string) (string, error)

func TriggerFileUnzip added in v0.1.7

func TriggerFileUnzip(rail miso.Rail, req UnzipFileReq) error

func UploadFile added in v0.1.7

func UploadFile(rail miso.Rail, filename string, dat io.Reader) (string, error)

Types

type DirectDownloadFileReq added in v0.1.11

type DirectDownloadFileReq struct {
	FileId string
}

type FetchFileInfoReq added in v0.1.7

type FetchFileInfoReq struct {
	FileId       string
	UploadFileId string
}

type FstoreFile

type FstoreFile struct {
	FileId     string      `json:"fileId" desc:"file unique identifier"`
	Name       string      `json:"name" desc:"file name"`
	Status     string      `json:"status" desc:"status, 'NORMAL', 'LOG_DEL' (logically deleted), 'PHY_DEL' (physically deleted)"`
	Size       int64       `json:"size" desc:"file size in bytes"`
	Md5        string      `json:"md5" desc:"MD5 checksum"`
	UplTime    util.ETime  `json:"uplTime" desc:"upload time"`
	LogDelTime *util.ETime `json:"logDelTime" desc:"logically deleted at"`
	PhyDelTime *util.ETime `json:"phyDelTime" desc:"physically deleted at"`
}

func FetchFileInfo added in v0.1.7

func FetchFileInfo(rail miso.Rail, req FetchFileInfoReq) (FstoreFile, error)

type GenVideoThumbnailReplyEvent added in v0.1.17

type GenVideoThumbnailReplyEvent struct {
	Identifier string // identifier
	FileId     string // file id from mini-fstore
}

Event replied from hammer about the generated video thumbnail.

type ImageCompressReplyEvent added in v0.1.17

type ImageCompressReplyEvent struct {
	Identifier string // identifier
	FileId     string // file id from mini-fstore
}

Event replied from hammer about the compressed image.

type ImgThumbnailTriggerEvent added in v0.1.17

type ImgThumbnailTriggerEvent struct {
	Identifier string `desc:"identifier"`
	FileId     string `desc:"file id from mini-fstore"`
	ReplyTo    string `desc:"event bus that will receive event about the generated image thumbnail."`
}

Event sent to hammer to trigger an image compression.

type UnzipFileReplyEvent added in v0.1.7

type UnzipFileReplyEvent struct {
	ZipFileId  string
	ZipEntries []ZipEntry
	Extra      string
}

type UnzipFileReq added in v0.1.7

type UnzipFileReq struct {
	// zip file's mini-fstore file_id.
	FileId string `valid:"notEmpty" desc:"file_id of zip file"`

	// rabbitmq exchange (both the exchange and queue must all use the same name, and are bound together using routing key '#').
	//
	// See UnzipFileReplyEvent (reply message body).
	ReplyToEventBus string `valid:"notEmpty" desc:"name of the rabbitmq exchange to reply to, routing_key is '#'"`

	// Extra information that will be passed back to the caller in reply event.
	Extra string `desc:"extra information that will be passed around for the caller"`
}

type VidThumbnailTriggerEvent added in v0.1.17

type VidThumbnailTriggerEvent struct {
	Identifier string `desc:"dentifier"`
	FileId     string `desc:"file id from mini-fstore"`
	ReplyTo    string `desc:"event bus that will receive event about the generated video thumbnail."`
}

Event sent to hammer to trigger an vidoe thumbnail generation.

type ZipEntry added in v0.1.7

type ZipEntry struct {
	FileId string
	Md5    string
	Name   string
	Size   int64
}

Jump to

Keyboard shortcuts

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