Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNameAlreadyRegistered = errors.New("name already registered") ErrInvalidName = errors.New("name does not match this regular expression: " + namePattern) )
Errors that may occur when registering a host provider.
Functions ¶
func ReadSQLFileFromFS ¶
ReadSQLFileFromFS walk the directory and read *.sql files from FS such as embed.FS.
Types ¶
type Dependencies ¶
type Dependencies struct { Mysql *gorm.DB Redis *redis.Client Mailer mail.Mailer Queue *queue.Client }
Dependencies of hosts.
type Host ¶
type Host interface { // CreateFromLinks create shared links based on the input original links. CreateFromLinks(ctx context.Context, userID string, originalLinks []string, createBy string) (sharedLinks map[string]*share.Share, err error) // GetStatuses return the statuses of each host shared link. GetStatuses(ctx context.Context, userID string, hostSharedLinks []string) (statuses map[string]share.State, err error) // GetStatistics return the statistics of each host shared link. GetStatistics(ctx context.Context, userID string, hostSharedLinks []string) (details map[string]share.Statistics, err error) // Delete delete shared links by original links. Delete(ctx context.Context, userID string, originalLinks []string) error // HostInfo returns basic information of the host. HostInfo(ctx context.Context, userID string, options map[string]any) (resp map[string]any, err error) }
Host is an interface of file hosting provider.
type HostWithProperties ¶
type HostWithProperties struct { Host // contains filtered or unexported fields }
HostWithProperties save properties for hosts.
func (*HostWithProperties) CreateTableStatements ¶
func (h *HostWithProperties) CreateTableStatements() []string
CreateTableStatements returns the statements to create tables of the host.
func (*HostWithProperties) Name ¶
func (h *HostWithProperties) Name() string
Name returns the host's name.
type Properties ¶
type Properties struct { // Name is the host's name. // The name must match this regular expression: `^[0-9A-Za-z_]{1,32}$` Name string // New is the function to create a Host instance. New func(d *Dependencies) Host // CreateTableStatements return the statements to create tables in mysql database. // The name of tables must be prefixed with the host provider's name. // If the host do not need mysql database, this property can be empty. CreateTableStatements []string }
Properties of a host.
Click to show internal directories.
Click to hide internal directories.