server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 87 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobStatusNew     = "new"
	JobStatusError   = "error"
	JobStatusBusy    = "busy"
	JobStatusTimeout = "timeout"

	JobStatusAudioAnalysis     = "audio_analysis"
	JobStatusBusyAudioAnalysis = "busy_audio_analysis"

	JobStatusDone = "done"
)

Job statuses

View Source
const (
	StreamTrack string = "stream_track"
	ServeImage  string = "serve_image"
)

Metric actions

View Source
const (
	DelistStatusPollingInterval              = 20 * time.Second
	HTTPTimeout                              = 5 * time.Minute
	DelistBatchSize                          = 5000
	TimeFormat                               = "2006-01-02 15:04:05.999999-07"
	Tracks                      DelistEntity = "tracks"
	Users                       DelistEntity = "users"
)
View Source
const AUTO = -1
View Source
const MAX_TRIES = 3
View Source
const PercentSeededThreshold = 50
View Source
const PullLimit = 10000

Variables

View Source
var (
	ErrDiskFull                                 = errors.New("disk is too full to accept new uploads")
	ErrInvalidTemplate                          = errors.New("invalid template")
	ErrUploadToPlacementHosts                   = errors.New("if placement_hosts is specified, you must upload to one of the placement_hosts")
	ErrAllPlacementHostsMustBeRegisteredSigners = errors.New("all placement_hosts must be registered signers")
	ErrInvalidPreviewStartSeconds               = errors.New("invalid preview start seconds")
	ErrUploadProcessFailed                      = errors.New("upload process failed")
)

Functions

func ACAOHeaderOverwriteMiddleware

func ACAOHeaderOverwriteMiddleware(next echo.HandlerFunc) echo.HandlerFunc

func Resized

func Resized(ext string, read io.ReadSeeker, width, height int, mode string) (resized io.ReadSeeker, w int, h int)

Types

type AudioAnalysisResult

type AudioAnalysisResult struct {
	BPM float64 `json:"bpm"`
	Key string  `json:"key"`
}

type AudioPreview

type AudioPreview struct {
	CID                 string `json:"cid" gorm:"primaryKey;column:cid"`
	SourceCID           string
	PreviewStartSeconds string
	CreatedBy           string    `json:"created_by" `
	CreatedAt           time.Time `json:"created_at" gorm:"autoCreateTime:false"`
}

type BlobMetric

type BlobMetric struct {
	Timestamp time.Time `json:"timestamp" gorm:"primaryKey"`
	Count     int64     `json:"count"`
}

type BlobMetrics

type BlobMetrics struct {
	Data []BlobMetric `json:"data"`
}

type ByteRange

type ByteRange struct {
	Start, End int
}

type ContactResponse

type ContactResponse struct {
	Email string `json:"email"`
}

type DailyMetrics

type DailyMetrics struct {
	Timestamp time.Time `gorm:"primaryKey"`
	Action    string    `gorm:"primaryKey"`
	Count     int64     `gorm:"not null"`
	CreatedAt time.Time `json:"created_at" gorm:"not null"`
}

type DelistEntity

type DelistEntity string

type DelistStatus

type DelistStatus struct {
	CreatedAt time.Time `json:"-"`
	Delisted  bool      `json:"delisted"`
	Reason    string    `json:"reason"`

	// fields specific to TrackDelistStatus
	TrackID  int    `json:"trackId,omitempty"`
	TrackCID string `json:"trackCid,omitempty"`
	OwnerID  int    `json:"ownerId,omitempty"`

	// field specific to UserDelistStatus
	UserID int `json:"userId,omitempty"`
}

func (*DelistStatus) UnmarshalJSON

func (ds *DelistStatus) UnmarshalJSON(data []byte) error

type FFProbeResult

type FFProbeResult struct {
	Format struct {
		Filename       string `json:"filename"`
		FormatName     string `json:"format_name"`
		FormatLongName string `json:"format_long_name"`
		Duration       string `json:"duration,omitempty"`
		Size           string `json:"size"`
		BitRate        string `json:"bit_rate,omitempty"`
	} `json:"format"`
}

type FileReader

type FileReader interface {
	Filename() string
	Open() (io.ReadCloser, error)
}

type GeoLocation

type GeoLocation struct {
	Country struct {
		ISOCode string            `maxminddb:"iso_code"`
		Names   map[string]string `maxminddb:"names"`
	} `maxminddb:"country"`
	City struct {
		Names map[string]string `maxminddb:"names"`
	} `maxminddb:"city"`
	Location struct {
		Latitude  float64 `maxminddb:"latitude"`
		Longitude float64 `maxminddb:"longitude"`
	} `maxminddb:"location"`
	Subdivisions []struct {
		ISOCode string            `maxminddb:"iso_code"`
		Names   map[string]string `maxminddb:"names"`
	} `maxminddb:"subdivisions"`
}

type GeoResult

type GeoResult struct {
	Country     string  `json:"country"`
	CountryCode string  `json:"country_code"`
	City        string  `json:"city"`
	Region      string  `json:"region"`
	RegionCode  string  `json:"region_code"`
	Latitude    float64 `json:"latitude"`
	Longitude   float64 `json:"longitude"`
}

type HealthCheckResponse

type HealthCheckResponse struct {
	Data      HealthCheckResponseData `json:"data"`
	Signer    string                  `json:"signer"`
	Signature string                  `json:"signature"`
	Timestamp time.Time               `json:"timestamp"`
}

type HealthCheckResponseData

type HealthCheckResponseData struct {
	Healthy                   bool                       `json:"healthy"`
	Version                   string                     `json:"version"`
	Service                   string                     `json:"service"` // used by registerWithDelegate()
	IsSeeding                 bool                       `json:"isSeeding"`
	IsAudiusdManaged          bool                       `json:"isAudiusdManaged"`
	BuiltAt                   string                     `json:"builtAt"`
	StartedAt                 time.Time                  `json:"startedAt"`
	SPID                      int                        `json:"spID"`
	SPOwnerWallet             string                     `json:"spOwnerWallet"`
	Git                       string                     `json:"git"`
	AudiusDockerCompose       string                     `json:"audiusDockerCompose"`
	MediorumPathUsed          uint64                     `json:"mediorumPathUsed"`   // bytes
	MediorumPathSize          uint64                     `json:"mediorumPathSize"`   // bytes
	StorageExpectation        uint64                     `json:"storageExpectation"` // bytes
	DatabaseSize              uint64                     `json:"databaseSize"`       // bytes
	DbSizeErr                 string                     `json:"dbSizeErr"`
	LastSuccessfulRepair      RepairTracker              `json:"lastSuccessfulRepair"`
	LastSuccessfulCleanup     RepairTracker              `json:"lastSuccessfulCleanup"`
	UploadsCount              int64                      `json:"uploadsCount"`
	UploadsCountErr           string                     `json:"uploadsCountErr"`
	AutoUpgradeEnabled        bool                       `json:"autoUpgradeEnabled"`
	TrustedNotifier           *ethcontracts.NotifierInfo `json:"trustedNotifier"`
	Env                       string                     `json:"env"`
	Self                      registrar.Peer             `json:"self"`
	WalletIsRegistered        bool                       `json:"wallet_is_registered"`
	Signers                   []registrar.Peer           `json:"signers"`
	ReplicationFactor         int                        `json:"replicationFactor"`
	Dir                       string                     `json:"dir"`
	BlobStorePrefix           string                     `json:"blobStorePrefix"`
	MoveFromBlobStorePrefix   string                     `json:"moveFromBlobStorePrefix"`
	ListenPort                string                     `json:"listenPort"`
	TrustedNotifierID         int                        `json:"trustedNotifierId"`
	PeerHealths               map[string]*PeerHealth     `json:"peerHealths"`
	UnreachablePeers          []string                   `json:"unreachablePeers"`
	FailsPeerReachability     bool                       `json:"failsPeerReachability"`
	StoreAll                  bool                       `json:"storeAll"`
	IsDbLocalhost             bool                       `json:"isDbLocalhost"`
	DiskHasSpace              bool                       `json:"diskHasSpace"`
	IsDiscoveryListensEnabled bool                       `json:"isDiscoveryListensEnabled"`
	TranscodeQueueLength      int                        `json:"transcodeQueueLength"`
	TranscodeStats            *TranscodeStats            `json:"transcodeStats"`
}

type HostAttrSniff

type HostAttrSniff struct {
	Host           string
	Attr           *blob.Attributes
	RendezvousRank int
}

type HostTuple

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

type HostTuples

type HostTuples []HostTuple

func (HostTuples) Len

func (s HostTuples) Len() int

func (HostTuples) Less

func (s HostTuples) Less(i, j int) bool

func (HostTuples) Swap

func (s HostTuples) Swap(i, j int)

type JobTemplate

type JobTemplate string

Upload templates

const (
	JobTemplateAudio       JobTemplate = "audio"
	JobTemplateImgSquare   JobTemplate = "img_square"
	JobTemplateImgBackdrop JobTemplate = "img_backdrop"
)

type MediorumConfig

type MediorumConfig struct {
	Env                       string
	Self                      registrar.Peer
	Peers                     []registrar.Peer
	Signers                   []registrar.Peer
	ReplicationFactor         int
	Dir                       string `default:"/tmp/mediorum"`
	BlobStoreDSN              string `json:"-"`
	MoveFromBlobStoreDSN      string `json:"-"`
	PostgresDSN               string `json:"-"`
	PrivateKey                string `json:"-"`
	ListenPort                string
	TrustedNotifierID         int
	SPID                      int
	SPOwnerWallet             string
	GitSHA                    string
	AudiusDockerCompose       string
	AutoUpgradeEnabled        bool
	WalletIsRegistered        bool
	StoreAll                  bool
	VersionJson               version.VersionJson
	DiscoveryListensEndpoints []string
	LogLevel                  string

	ProgrammableDistributionEnabled bool
	// contains filtered or unexported fields
}

type MediorumServer

type MediorumServer struct {
	StartedAt time.Time
	Config    MediorumConfig
	// contains filtered or unexported fields
}

func New

func New(lc *lifecycle.Lifecycle, logger *zap.Logger, config MediorumConfig, provider registrar.PeerProvider, posChannel chan pos.PoSRequest, core *coreServer.CoreService) (*MediorumServer, error)

func (*MediorumServer) MustStart

func (ss *MediorumServer) MustStart() error

func (*MediorumServer) Stop

func (ss *MediorumServer) Stop()

type Metrics

type Metrics struct {
	Host              string         `json:"host"`
	Uploads           int64          `json:"uploads"`
	OutboxSizes       map[string]int `json:"outbox_sizes"`
	RedirectCacheSize int            `json:"redirect_cache_size"`
}

type MonthlyMetrics

type MonthlyMetrics struct {
	Timestamp time.Time `gorm:"primaryKey"`
	Action    string    `gorm:"primaryKey"`
	Count     int64     `gorm:"not null"`
	CreatedAt time.Time `json:"created_at" gorm:"not null"`
}

type PeerHealth

type PeerHealth struct {
	Version        string               `json:"version"`
	LastReachable  time.Time            `json:"lastReachable"`
	LastHealthy    time.Time            `json:"lastHealthy"`
	ReachablePeers map[string]time.Time `json:"reachablePeers"`
}

type PlayEvent

type PlayEvent struct {
	RowID            int
	UserID           string
	TrackID          string
	PlayTime         time.Time
	Signature        string
	City             string
	Region           string
	Country          string
	RequestSignature string
}

func (PlayEvent) MarshalLogObject

func (e PlayEvent) MarshalLogObject(enc zapcore.ObjectEncoder) error

Marshal a single PlayEvent

type PlayEventQueue

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

func NewPlayEventQueue

func NewPlayEventQueue() *PlayEventQueue

type QmAudioAnalysis

type QmAudioAnalysis struct {
	CID        string               `json:"cid" gorm:"primaryKey;column:cid"`
	Mirrors    []string             `json:"mirrors" gorm:"serializer:json"`
	Status     string               `json:"status"`
	Error      string               `json:"error,omitempty"`
	ErrorCount int                  `json:"error_count"`
	AnalyzedBy string               `json:"analyzed_by"`
	AnalyzedAt time.Time            `json:"analyzed_at"`
	Results    *AudioAnalysisResult `json:"results" gorm:"serializer:json"`
}

type RendezvousHasher

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

func NewRendezvousHasher

func NewRendezvousHasher(hosts []string) *RendezvousHasher

func (*RendezvousHasher) Rank

func (rh *RendezvousHasher) Rank(key string) []string

type RepairTracker

type RepairTracker struct {
	StartedAt        time.Time `gorm:"primaryKey;not null"`
	UpdatedAt        time.Time `gorm:"not null"`
	FinishedAt       time.Time
	CleanupMode      bool           `gorm:"not null"`
	CursorI          int            `gorm:"not null"`
	CursorUploadID   string         `gorm:"not null"`
	CursorPreviewCID string         ``
	CursorQmCID      string         `gorm:"not null"`
	Counters         map[string]int `gorm:"not null;serializer:json"`
	ContentSize      int64          `gorm:"not null"`
	Duration         time.Duration  `gorm:"not null"`
	AbortedReason    string         `gorm:"not null"`
}

type StorageAndDbSize

type StorageAndDbSize struct {
	LoggedAt           time.Time `gorm:"primaryKey;not null"`
	Host               string    `gorm:"primaryKey;not null"`
	StorageBackend     string    `gorm:"not null"`
	DbUsed             uint64    `gorm:"not null"`
	MediorumDiskUsed   uint64    `gorm:"not null"`
	MediorumDiskSize   uint64    `gorm:"not null"`
	StorageExpectation uint64    `gorm:"not null;default:0"`
	LastRepairSize     int64     `gorm:"not null"`
	LastCleanupSize    int64     `gorm:"not null"`
}

type StorageService

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

func NewStorageService

func NewStorageService() *StorageService

func (*StorageService) GetHealth

GetHealth implements v1connect.StorageServiceHandler.

func (*StorageService) GetIPData

GetIPData implements v1connect.StorageServiceHandler.

func (*StorageService) GetRendezvousNodes

GetRendezvousNodes implements v1connect.StorageServiceHandler.

func (*StorageService) GetStatus

GetStatus implements v1connect.StorageServiceHandler.

func (*StorageService) GetStreamURL

GetStreamURL implements v1connect.StorageServiceHandler.

func (*StorageService) GetUpload

GetUpload implements v1connect.StorageServiceHandler.

func (*StorageService) Ping

Ping implements v1connect.StorageServiceHandler.

func (*StorageService) SetMediorum

func (s *StorageService) SetMediorum(mediorum *MediorumServer)

func (*StorageService) StreamTrack

StreamTrack implements v1connect.StorageServiceHandler.

func (*StorageService) UploadFiles

UploadFiles implements v1connect.StorageServiceHandler.

type TranscodeStats

type TranscodeStats struct {
	Since              time.Time `db:"since"`
	UploadCount        int       `db:"upload_count"`
	MinTranscodeTime   float64   `db:"min_transcode_time"`
	AvgTranscodeTime   float64   `db:"avg_transcode_time"`
	MaxTranscodeTime   float64   `db:"max_transcode_time"`
	TotalTranscodeTime float64   `db:"total_transcode_time"`
	TotalBytes         int       `db:"total_bytes"`
	TranscodeRate      float64   `db:"transcode_rate"`
}

type UpdateUploadBody

type UpdateUploadBody struct {
	PreviewStartSeconds string `json:"previewStartSeconds"`
}

type Upload

type Upload struct {
	ID string `json:"id"` // base32 file hash

	UserWallet        sql.NullString `json:"user_wallet"`
	Template          JobTemplate    `json:"template"`
	OrigFileName      string         `json:"orig_filename"`
	OrigFileCID       string         `json:"orig_file_cid" gorm:"column:orig_file_cid;index:idx_uploads_orig_file_cid"` //
	SelectedPreview   sql.NullString `json:"selected_preview"`
	FFProbe           *FFProbeResult `json:"probe" gorm:"serializer:json"`
	Error             string         `json:"error,omitempty"`
	ErrorCount        int            `json:"error_count,omitempty"`
	Mirrors           []string       `json:"mirrors" gorm:"serializer:json"`
	TranscodedMirrors []string       `json:"transcoded_mirrors" gorm:"serializer:json"`
	Status            string         `json:"status" gorm:"index"`
	PlacementHosts    []string       `json:"placement_hosts" gorm:"serializer:json"`

	CreatedBy string    `json:"created_by" `
	CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime:false"`
	UpdatedAt time.Time `json:"updated_at" gorm:"autoCreateTime:false"`

	TranscodedBy      string            `json:"transcoded_by"`
	TranscodeProgress float64           `json:"transcode_progress"`
	TranscodedAt      time.Time         `json:"transcoded_at"`
	TranscodeResults  map[string]string `json:"results" gorm:"serializer:json"`

	AudioAnalysisStatus     string               `json:"audio_analysis_status"`
	AudioAnalysisError      string               `json:"audio_analysis_error,omitempty"`
	AudioAnalysisErrorCount int                  `json:"audio_analysis_error_count"`
	AudioAnalyzedBy         string               `json:"audio_analyzed_by"`
	AudioAnalyzedAt         time.Time            `json:"audio_analyzed_at"`
	AudioAnalysisResults    *AudioAnalysisResult `json:"audio_analysis_results" gorm:"serializer:json"`
}

type UploadCursor

type UploadCursor struct {
	Host  string `gorm:"primaryKey"`
	After time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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