hour

package
v0.0.0-...-9f428d3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAvailable

func IsAvailable(availability Availability) bool

func IsErrHourNotAvailable

func IsErrHourNotAvailable(err error) bool

func IsErrNoTrainingScheduled

func IsErrNoTrainingScheduled(err error) bool

func IsErrNotFullHour

func IsErrNotFullHour(err error) bool

func IsErrPastHour

func IsErrPastHour(err error) bool

func IsErrTrainingScheduled

func IsErrTrainingScheduled(err error) bool

func IsNotAvailable

func IsNotAvailable(availability Availability) bool

func IsTrainingScheduled

func IsTrainingScheduled(availability Availability) bool

func NewErrHourNotAvailable

func NewErrHourNotAvailable() error

func NewErrNoTrainingScheduled

func NewErrNoTrainingScheduled() error

func NewErrNotFullHour

func NewErrNotFullHour() error

func NewErrPastHour

func NewErrPastHour() error

func NewErrTrainingScheduled

func NewErrTrainingScheduled() error

Types

type Availability

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

Availability is enum.

Using struct instead of `type Availability string` for enums allows us to ensure, that we have full control of what values are possible. With `type Availability string` you are able to create `Availability("i_can_put_anything_here")`

func Available

func Available() Availability

func NewAvailabilityFromString

func NewAvailabilityFromString(availabilityStr string) (Availability, error)

func NotAvailable

func NotAvailable() Availability

func TrainingScheduled

func TrainingScheduled() Availability

func (Availability) IsZero

func (h Availability) IsZero() bool

func (Availability) String

func (h Availability) String() string

type Factory

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

func MustNewFactory

func MustNewFactory(fc FactoryConfig) Factory

func NewFactory

func NewFactory(fc FactoryConfig) (Factory, error)

func (Factory) Config

func (f Factory) Config() FactoryConfig

func (Factory) IsZero

func (f Factory) IsZero() bool

func (Factory) NewAvailableHour

func (f Factory) NewAvailableHour(hour time.Time) (*Hour, error)

func (Factory) NewNotAvailableHour

func (f Factory) NewNotAvailableHour(hour time.Time) (*Hour, error)

func (Factory) UnmarshalHourFromDatabase

func (f Factory) UnmarshalHourFromDatabase(hour time.Time, availability Availability) (*Hour, error)

UnmarshalHourFromDatabase unmarshals Hour from the database.

It should be used only for unmarshalling from the database! You can't use UnmarshalHourFromDatabase as constructor - It may put domain into the invalid state!

type FactoryConfig

type FactoryConfig struct {
	MaxWeeksInTheFutureToSet int
	MinUtcHour               int
	MaxUtcHour               int
}

func (FactoryConfig) Validate

func (f FactoryConfig) Validate() error

type Hour

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

func (Hour) Availability

func (h Hour) Availability() Availability

func (*Hour) CancelTraining

func (h *Hour) CancelTraining() error

func (Hour) HasTrainingScheduled

func (h Hour) HasTrainingScheduled() bool

func (Hour) IsAvailable

func (h Hour) IsAvailable() bool

func (*Hour) MakeAvailable

func (h *Hour) MakeAvailable() error

func (*Hour) MakeNotAvailable

func (h *Hour) MakeNotAvailable() error

func (*Hour) ScheduleTraining

func (h *Hour) ScheduleTraining() error

func (*Hour) Time

func (h *Hour) Time() time.Time

type Repository

type Repository interface {
	GetHour(ctx context.Context, hourTime time.Time) (*Hour, error)
	UpdateHour(
		ctx context.Context,
		hourTime time.Time,
		updateFn func(h *Hour) (*Hour, error),
	) error
}

type TooDistantDateError

type TooDistantDateError struct {
	MaxWeeksInTheFutureToSet int
	ProvidedDate             time.Time
}

func (TooDistantDateError) Error

func (e TooDistantDateError) Error() string

type TooEarlyHourError

type TooEarlyHourError struct {
	MinUtcHour   int
	ProvidedTime time.Time
}

func (TooEarlyHourError) Error

func (e TooEarlyHourError) Error() string

type TooLateHourError

type TooLateHourError struct {
	MaxUtcHour   int
	ProvidedTime time.Time
}

func (TooLateHourError) Error

func (e TooLateHourError) Error() string

Jump to

Keyboard shortcuts

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