services

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: Apache-2.0 Imports: 15 Imported by: 0 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

This section is empty.

Variables

View Source
var (
	ErrNoMatchingPlatform = NewError(101, "no matching platform found")
	ErrDownloadFailed     = NewError(102, "failed to download episode")
	ErrEpisodeInProgress  = NewError(103, "episode already in progress")
	ErrEpisodeExists      = NewError(104, "episode already exists")
	ErrProcessInterrupted = NewError(105, "process was interrupted")
	ErrEmptyFeed          = NewError(106, "feed has no items")
	ErrInvalidRequest     = NewError(107, "invalid download request")

	ErrProcessUpsert              = NewError(201, "failed to update process")
	ErrProcessCountByUrlAndStatus = NewError(202, "failed to count processes by URL and status")
	ErrEpisodeGetByOriginalURL    = NewError(203, "failed to get episode by original URL")
	ErrEpisodeCreate              = NewError(204, "failed to create episode")
	ErrProcessGetByStatus         = NewError(205, "failed to get process by status")
	ErrEpisodeListAll             = NewError(206, "failed to list all episodes")
	ErrEpisodeCountAll            = NewError(207, "failed to count all episodes")
	ErrEpisodeGetLastTime         = NewError(208, "failed to get last episode time")

	ErrFeedSave = NewError(301, "failed to save feed to file")
)

Functions

This section is empty.

Types

type Downloader

type Downloader interface {
	Download(ctx context.Context, req entities.Request) (*entities.Episode, error)
}

Downloader is an interface for downloading episodes.

type EpisodeService

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

func NewEpisodeService

func NewEpisodeService(cfg *config.Settings, log *slog.Logger, s Store, p ...Platform) *EpisodeService

NewEpisodeService creates a new EpisodeService instance.

func (*EpisodeService) Download

func (s *EpisodeService) Download(ctx context.Context, req entities.Request) (*entities.Episode, error)

Download downloads an episode from the given URL using the appropriate platform.

func (*EpisodeService) Init

func (s *EpisodeService) Init(ctx context.Context) error

Init checks the service dependencies and prepares the environment.

type Error

type Error = struct {
	Code int
	// contains filtered or unexported fields
}

func NewError

func NewError(code int, msg string) Error

type FeedService

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

FeedService builds RSS podcast feed from episodes.

func NewFeedService

func NewFeedService(cfg *config.Settings, log *slog.Logger, s Store) *FeedService

NewFeedService creates a new FeedService instance.

func (*FeedService) Build

func (s *FeedService) Build(ctx context.Context) error

Build implements Feeder interface to generate RSS feed from all episodes.

func (*FeedService) Feed added in v0.1.0

func (s *FeedService) Feed(ctx context.Context) (*entities.Feed, error)

func (*FeedService) Init

func (s *FeedService) Init(_ context.Context) error

Init checks the service dependencies and prepares the environment.

type Feeder added in v0.1.0

type Feeder interface {
	Build(ctx context.Context) error
	Feed(ctx context.Context) (*entities.Feed, error)
}

Feeder is an interface for building the podcast feed.

type Platform

type Platform interface {
	ID() string
	Init(ctx context.Context) error
	Match(url string) bool
	Download(ctx context.Context, req entities.Request) (*entities.Episode, error)
}

Platform is an interface for different download platforms.

type ProcessService

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

ProcessService handles the processing of download requests.

func NewProcessService

func NewProcessService(cfg *config.Settings, log *slog.Logger, s Store, d Downloader, f Feeder) *ProcessService

NewProcessService creates a new ProcessService instance.

func (*ProcessService) In

func (s *ProcessService) In() chan<- entities.Request

In returns the input channel for receiving download requests.

func (*ProcessService) Init

func (s *ProcessService) Init(ctx context.Context) error

Init initializes the service before starting. It fails all in-progress processes to ensure a clean state.

func (*ProcessService) Out

func (s *ProcessService) Out() <-chan entities.Process

Out returns the output channel for sending notifications about process completion.

func (*ProcessService) Start

func (s *ProcessService) Start(ctx context.Context)

Start begins processing download requests. It runs until the provided context is canceled.

type Store

type Store = store.Store

Store is a store interface.

Jump to

Keyboard shortcuts

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