service

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateMovieRequest

type CreateMovieRequest struct {
	Title    string `json:"title"`
	Rated    string `json:"rated"`
	Released string `json:"release_date"`
	RunTime  int    `json:"run_time"`
	Director string `json:"director"`
	Writer   string `json:"writer"`
}

CreateMovieRequest is the request struct for Creating a Movie

type CreateMovieService

type CreateMovieService struct {
	RandomStringGenerator RandomStringGenerator
	MovieTransactor       MovieTransactor
}

CreateMovieService is a service for creating a Movie

func NewCreateMovieService

func NewCreateMovieService(rsg RandomStringGenerator, mt MovieTransactor) *CreateMovieService

NewCreateMovieService is an initializer for CreateMovieService

func (CreateMovieService) Create

Create is used to create a Movie

type DeleteMovieResponse

type DeleteMovieResponse struct {
	ExternalID string `json:"extl_id"`
	Deleted    bool   `json:"deleted"`
}

DeleteMovieResponse is the response struct for deleted Movies

type DeleteMovieService

type DeleteMovieService struct {
	MovieSelector   MovieSelector
	MovieTransactor MovieTransactor
}

DeleteMovieService is a service for deleting a Movie

func NewDeleteMovieService

func NewDeleteMovieService(ms MovieSelector, mt MovieTransactor) *DeleteMovieService

NewDeleteMovieService is an initializer for DeleteMovieService

func (DeleteMovieService) Delete

Delete is used to delete a movie

type FindMovieService

type FindMovieService struct {
	MovieSelector MovieSelector
}

FindMovieService is a service for reading a Movie from the DB

func NewFindMovieService

func NewFindMovieService(ms MovieSelector) *FindMovieService

NewFindMovieService is an initializer for FindMovieService

func (FindMovieService) FindAllMovies

func (fms FindMovieService) FindAllMovies(ctx context.Context) ([]MovieResponse, error)

FindAllMovies is used to list all movies in the db

func (FindMovieService) FindMovieByID

func (fms FindMovieService) FindMovieByID(ctx context.Context, extlID string) (MovieResponse, error)

FindMovieByID is used to find an individual movie

type LoggerRequest

type LoggerRequest struct {
	GlobalLogLevel string `json:"global_log_level"`
	LogErrorStack  string `json:"log_error_stack"`
}

LoggerRequest is the request struct for the app logger

type LoggerResponse

type LoggerResponse struct {
	LoggerMinimumLevel string `json:"logger_minimum_level"`
	GlobalLogLevel     string `json:"global_log_level"`
	LogErrorStack      bool   `json:"log_error_stack"`
}

LoggerResponse is the response struct for the current state of the app logger

type LoggerService

type LoggerService struct {
	Logger zerolog.Logger
}

LoggerService reads and updates the logger state

func NewLoggerService

func NewLoggerService(logger zerolog.Logger) *LoggerService

NewLoggerService is an initializer for LoggerService

func (LoggerService) Read

func (ls LoggerService) Read() LoggerResponse

ReadLogger handles GET requests for the /logger endpoint

func (LoggerService) Update

Update handles PUT requests for the /logger endpoint and updates the logger globals

type MovieResponse

type MovieResponse struct {
	ExternalID      string `json:"external_id"`
	Title           string `json:"title"`
	Rated           string `json:"rated"`
	Released        string `json:"release_date"`
	RunTime         int    `json:"run_time"`
	Director        string `json:"director"`
	Writer          string `json:"writer"`
	CreateUsername  string `json:"create_username"`
	CreateTimestamp string `json:"create_timestamp"`
	UpdateUsername  string `json:"update_username"`
	UpdateTimestamp string `json:"update_timestamp"`
}

MovieResponse is the response struct for a Movie

type MovieSelector

type MovieSelector interface {
	FindByID(context.Context, string) (*movie.Movie, error)
	FindAll(context.Context) ([]*movie.Movie, error)
}

MovieSelector reads Movie records from the db

type MovieTransactor

type MovieTransactor interface {
	Create(ctx context.Context, m *movie.Movie) error
	Update(ctx context.Context, m *movie.Movie) error
	Delete(ctx context.Context, m *movie.Movie) error
}

MovieTransactor is the interface that wraps the DML actions for a Movie in the DB

type PingResponse

type PingResponse struct {
	DBUp bool `json:"db_up"`
}

PingResponse is the response struct for the PingService

type PingService

type PingService struct {
	Pinger Pinger
}

PingService pings the database.

func NewPingService

func NewPingService(p Pinger) *PingService

NewPingService is an initializer for PingService

func (PingService) Ping

func (p PingService) Ping(ctx context.Context, logger zerolog.Logger) PingResponse

Ping method pings the database

type Pinger

type Pinger interface {
	PingDB(context.Context) error
}

Pinger pings the database

type RandomStringGenerator

type RandomStringGenerator interface {
	CryptoString(n int) (string, error)
}

RandomStringGenerator is the interface that generates random strings

type UpdateMovieRequest

type UpdateMovieRequest struct {
	ExternalID string
	Title      string `json:"title"`
	Rated      string `json:"rated"`
	Released   string `json:"release_date"`
	RunTime    int    `json:"run_time"`
	Director   string `json:"director"`
	Writer     string `json:"writer"`
}

UpdateMovieRequest is the request struct for updating a Movie

type UpdateMovieService

type UpdateMovieService struct {
	MovieTransactor MovieTransactor
}

UpdateMovieService is a service for updating a Movie

func NewUpdateMovieService

func NewUpdateMovieService(mt MovieTransactor) *UpdateMovieService

NewUpdateMovieService is an initializer for UpdateMovieService

func (UpdateMovieService) Update

Update is used to update a movie

Jump to

Keyboard shortcuts

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