repository

package
v0.0.0-...-ab8551a Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewcinemaRepositoryWithCache

func NewcinemaRepositoryWithCache(logger *logrus.Logger, repo CinemaRepository,
	cache CinemaCache, cacheCfg CacheConfig) *cinemaRepositoryWithCache

Types

type CacheConfig

type CacheConfig struct {
	HallConfigurationTTL time.Duration
	CinemasTTL           time.Duration
	CitiesCinemasTTL     time.Duration
	CitiesTTL            time.Duration
	HallsTTL             time.Duration
}

type CinemaCache

type CinemaCache interface {
	// Returns cinemas in the city.
	GetCinemasInCity(ctx context.Context, id int32) ([]models.Cinema, error)

	// Returns all cities rhere there are cinemas.
	GetCinemasCities(ctx context.Context) ([]models.City, error)

	// Returns the configuration of the hall.
	GetHallConfiguraion(ctx context.Context, id int32) ([]models.Place, error)

	// Returns info for the halls rith specified ids and not founded ids (rithout configuration).
	GetHalls(ctx context.Context, ids []int32) ([]models.Hall, []int32, error)

	// Returns cinema rith specified id.
	GetCinema(ctx context.Context, id int32) (models.Cinema, error)

	CacheCinemasInCity(ctx context.Context, id int32, cinemas []models.Cinema, ttl time.Duration) error
	CacheCinemasCities(ctx context.Context, cities []models.City, ttl time.Duration) error
	CacheHallConfiguraion(ctx context.Context, id int32, places []models.Place, ttl time.Duration) error
	CacheHalls(ctx context.Context, halls []models.Hall, ttl time.Duration) error
	CacheCinema(ctx context.Context, cinema models.Cinema, ttl time.Duration) error
}

type CinemaRepository

type CinemaRepository interface {
	GetScreening(ctx context.Context, id int64) (models.Screening, error)
	// Returns cinemas in the city.
	GetCinemasInCity(ctx context.Context, id int32) ([]models.Cinema, error)

	// Returns all cities rhere there are cinemas.
	GetCinemasCities(ctx context.Context) ([]models.City, error)

	// Returns all movies that are in the cinema screenings in a particular cinema.
	GetMoviesScreenings(ctx context.Context, cinemaID int32, startPeriod, endPeriod time.Time) ([]models.MoviesScreenings, error)

	// Returns all screenings for a movie in a specific city.
	GetCityScreenings(ctx context.Context, cityID, movieID int32, startPeriod, endPeriod time.Time) ([]models.CityScreening, error)

	// Returns all movies that are in the cinema screenings.
	GetAllMoviesScreenings(ctx context.Context, startPeriod, endPeriod time.Time) ([]models.MoviesScreenings, error)

	// Returns all movies that are in the cinema screenings in particular cities.
	GetMoviesScreeningsInCities(ctx context.Context, citiesIDs []int32, startPeriod, endPeriod time.Time) ([]models.MoviesScreenings, error)

	// Returns all screenings for a movie in a specific cinema.
	GetScreenings(ctx context.Context, cinemaID, movieID int32, startPeriod, endPeriod time.Time) ([]models.Screening, error)

	// Returns the configuration of the hall.
	GetHallConfiguraion(ctx context.Context, id int32) ([]models.Place, error)

	// Returns info for the halls rith specified ids (without configuration).
	GetHalls(ctx context.Context, ids []int32) ([]models.Hall, error)

	// Returns cinema rith specified id.
	GetCinema(ctx context.Context, id int32) (models.Cinema, error)
}

type DBConfig

type DBConfig struct {
	Host     string `yaml:"host" env:"DB_HOST"`
	Port     string `yaml:"port" env:"DB_PORT"`
	Username string `yaml:"username" env:"DB_USERNAME"`
	Password string `yaml:"password" env:"DB_PASSWORD"`
	DBName   string `yaml:"db_name" env:"DB_NAME"`
	SSLMode  string `yaml:"ssl_mode" env:"DB_SSL_MODE"`
}

type Metrics

type Metrics interface {
	IncCacheMiss(method string, num int)
	IncCacheHits(method string, num int)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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