app

package
v0.0.0-...-e995cac Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ActivateDeactivateServerCmdName = "activateDeactivateServer"
View Source
const CreateProgramsCmdName = "createPrograms"
View Source
const CreateStatusCmdName = "createStatus"
View Source
const CreateZoneCmdName = "createZone"
View Source
const ExecutePinsCmdName = "executePins"
View Source
const ExecuteZoneCmdName = "executeZone"
View Source
const ExecuteZoneWithStatusCmdName = "executeZoneWithStatus"
View Source
const FindAllProgramsQueryName = "findAllPrograms"
View Source
const FindExecutionLogsQueryName = "findExecutionLogs"
View Source
const FindProgramsInTimeQueryName = "findProgramsInTime"
View Source
const FindStatusQueryName = "findStatus"
View Source
const FindWeatherQueryName = "findWeather"
View Source
const PublishMessageCmdName = "publishMessage"
View Source
const RemoveZoneCmdName = "removeZone"
View Source
const SaveExecutionLogCmdName = "saveExecutionLog"
View Source
const UpdateStatusCmdName = "updateStatus"

Variables

View Source
var ErrInvalidExecutionsLogLimit = errors.New("invalid executions log limit")
View Source
var ErrStatusAlreadyExist = errors.New("status already exist")

Functions

func NewEventMiddleware

func NewEventMiddleware(evCh chan<- cqs.Event) cqs.CommandHandlerMiddleware

Types

type ActivateDeactivateServer

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

func NewActivateDeactivateServer

func NewActivateDeactivateServer(stRepo StatusRepository) *ActivateDeactivateServer

func (ActivateDeactivateServer) Handle

type ActivateDeactivateServerCmd

type ActivateDeactivateServerCmd struct {
	Active bool
}

func (ActivateDeactivateServerCmd) Name

type AllPrograms

type AllPrograms struct {
	Daily, Odd, Even []program.Program
	Weekly           []program.Weekly
	Temperature      []program.Temperature
}

type CommandBus

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

func NewCommandBus

func NewCommandBus() CommandBus

func (CommandBus) Handle

func (c CommandBus) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

func (CommandBus) Subscribe

func (c CommandBus) Subscribe(name string, command cqs.CommandHandler)

type CreatePrograms

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

func NewCreatePrograms

func NewCreatePrograms(
	daily, odd, even ProgramRepository,
	weekly WeeklyProgramRepository,
	temperature TemperatureProgramRepository,
) CreatePrograms

func (CreatePrograms) Handle

func (c CreatePrograms) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type CreateProgramsCmd

type CreateProgramsCmd struct {
	Daily, Odd, Even []program.Program
	Weekly           []program.Weekly
	Temperature      []program.Temperature
}

func (CreateProgramsCmd) Name

func (c CreateProgramsCmd) Name() string

type CreateStatus

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

func NewCreateStatus

func NewCreateStatus(sr StatusRepository) CreateStatus

func (CreateStatus) Handle

func (c CreateStatus) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type CreateStatusCmd

type CreateStatusCmd struct {
	StartedAt vo.Time
	Weather   weather.Weather
}

func (CreateStatusCmd) Name

func (c CreateStatusCmd) Name() string

type CreateZone

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

func NewCreateZone

func NewCreateZone(zr ZoneRepository) CreateZone

func (CreateZone) Handle

func (c CreateZone) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type CreateZoneCmd

type CreateZoneCmd struct {
	ID, ZoneName string
	Relays       []int
}

func (CreateZoneCmd) Name

func (c CreateZoneCmd) Name() string

type CreateZoneError

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

func (CreateZoneError) Error

func (c CreateZoneError) Error() string

type ExecutePins

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

func NewExecutePins

func NewExecutePins(pe PinExecutor) ExecutePins

func (ExecutePins) Handle

func (e ExecutePins) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type ExecutePinsCmd

type ExecutePinsCmd struct {
	Seconds uint
	Pins    []string
}

func (ExecutePinsCmd) Name

func (e ExecutePinsCmd) Name() string

type ExecuteZone

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

func NewExecuteZone

func NewExecuteZone(zr ZoneRepository) ExecuteZone

func (ExecuteZone) Handle

func (e ExecuteZone) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type ExecuteZoneCmd

type ExecuteZoneCmd struct {
	Seconds uint
	ZoneID  string
}

func (ExecuteZoneCmd) Name

func (e ExecuteZoneCmd) Name() string

type ExecuteZoneError

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

func (ExecuteZoneError) Error

func (e ExecuteZoneError) Error() string

type ExecuteZoneWithStatus

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

func (ExecuteZoneWithStatus) Handle

func (e ExecuteZoneWithStatus) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type ExecuteZoneWithStatusCmd

type ExecuteZoneWithStatusCmd struct {
	Seconds uint
	ZoneID  string
}

func (ExecuteZoneWithStatusCmd) Name

type ExecuteZoneWithStatusError

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

func (ExecuteZoneWithStatusError) Error

type ExecutionLogRepository

type ExecutionLogRepository interface {
	Save(ctx context.Context, logs []program.ExecutionLog) error
	FindAll(ctx context.Context) ([]program.ExecutionLog, error)
}

type FindAllPrograms

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

func (FindAllPrograms) Handle

func (f FindAllPrograms) Handle(ctx context.Context, _ cqs.Query) (any, error)

type FindAllProgramsQuery

type FindAllProgramsQuery struct{}

func (FindAllProgramsQuery) Name

func (f FindAllProgramsQuery) Name() string

type FindExecutionLogs

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

func NewFindExecutionLogs

func NewFindExecutionLogs(elr ExecutionLogRepository) FindExecutionLogs

func (FindExecutionLogs) Handle

func (f FindExecutionLogs) Handle(ctx context.Context, query cqs.Query) (any, error)

type FindExecutionLogsQuery

type FindExecutionLogsQuery struct {
	Limit int
}

func (FindExecutionLogsQuery) Name

func (f FindExecutionLogsQuery) Name() string

type FindProgramsInTime

type FindProgramsInTime struct {
	Daily, Odd, Even ProgramRepository
	Weekly           WeeklyProgramRepository
	Temperature      TemperatureProgramRepository
}

func NewFindProgramsInTime

func NewFindProgramsInTime(
	daily, odd, even ProgramRepository,
	weekly WeeklyProgramRepository,
	temperature TemperatureProgramRepository,
) FindProgramsInTime

func (FindProgramsInTime) Handle

func (f FindProgramsInTime) Handle(ctx context.Context, query cqs.Query) (any, error)

type FindProgramsInTimeQuery

type FindProgramsInTimeQuery struct {
	On          vo.Time
	Temperature float32
}

func (FindProgramsInTimeQuery) Name

type FindStatus

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

func NewFindStatus

func NewFindStatus(sr StatusRepository) FindStatus

func (FindStatus) Handle

func (f FindStatus) Handle(ctx context.Context, _ cqs.Query) (any, error)

type FindStatusQuery

type FindStatusQuery struct{}

func (FindStatusQuery) Name

func (f FindStatusQuery) Name() string

type FindWeather

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

func (FindWeather) Handle

func (f FindWeather) Handle(ctx context.Context, _ cqs.Query) (any, error)

type FindWeatherQuery

type FindWeatherQuery struct{}

func (FindWeatherQuery) Name

func (f FindWeatherQuery) Name() string

type MessagePublisher

type MessagePublisher interface {
	Publish(ctx context.Context, message string) error
}

type PinExecutor

type PinExecutor interface {
	Execute(ctx context.Context, seconds uint, pins []string) error
}

type ProgramRepository

type ProgramRepository interface {
	Save(ctx context.Context, programs []program.Program) error
	FindAll(ctx context.Context) ([]program.Program, error)
	FindByHour(ctx context.Context, hour program.Hour) (program.Program, error)
}

type ProgramsInTime

type ProgramsInTime struct {
	Daily, Odd, Even *program.Program
	Weekly           *program.Weekly
	Temperature      *program.Temperature
}

type PublishMessage

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

func NewPublishMessage

func NewPublishMessage(elp MessagePublisher) PublishMessage

func (PublishMessage) Handle

func (p PublishMessage) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type PublishMessageCmd

type PublishMessageCmd struct {
	Message string
}

func (PublishMessageCmd) Name

func (p PublishMessageCmd) Name() string

type QueryBus

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

func NewQueryBus

func NewQueryBus() QueryBus

func (QueryBus) Handle

func (c QueryBus) Handle(ctx context.Context, query cqs.Query) (any, error)

func (QueryBus) Subscribe

func (c QueryBus) Subscribe(name string, query cqs.QueryHandler)

type RainRepository

type RainRepository interface {
	Find(ctx context.Context) (bool, error)
}

type RemoveZone

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

func NewRemoveZone

func NewRemoveZone(zr ZoneRepository) RemoveZone

func (RemoveZone) Handle

func (r RemoveZone) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type RemoveZoneCmd

type RemoveZoneCmd struct {
	ID string
}

func (RemoveZoneCmd) Name

func (r RemoveZoneCmd) Name() string

type SaveExecutionLog

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

func NewSaveExecutionLog

func NewSaveExecutionLog(elr ExecutionLogRepository) SaveExecutionLog

func (SaveExecutionLog) Handle

func (s SaveExecutionLog) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type SaveExecutionLogCmd

type SaveExecutionLogCmd struct {
	ZoneName   string
	Seconds    program.Seconds
	ExecutedAt vo.Time
}

func (SaveExecutionLogCmd) Name

func (s SaveExecutionLogCmd) Name() string

type SaveExecutionLogError

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

func (SaveExecutionLogError) Error

func (s SaveExecutionLogError) Error() string

type StatusRepository

type StatusRepository interface {
	Save(ctx context.Context, st status.Status) error
	Find(ctx context.Context) (status.Status, error)
	Update(ctx context.Context, st status.Status) error
}

type TemperatureProgramRepository

type TemperatureProgramRepository interface {
	Save(ctx context.Context, programs []program.Temperature) error
	FindAll(ctx context.Context) ([]program.Temperature, error)
	FindByTemperatureAndHour(ctx context.Context, temperature float32, hour program.Hour) (program.Temperature, error)
}

type TemperatureRepository

type TemperatureRepository interface {
	Find(ctx context.Context) (temp, hum float32, err error)
}

type UnSubscribedCommandError

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

func (UnSubscribedCommandError) Error

func (u UnSubscribedCommandError) Error() string

type UnSubscribedQueryError

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

func (UnSubscribedQueryError) Error

func (u UnSubscribedQueryError) Error() string

type UpdateStatus

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

func NewUpdateStatus

func NewUpdateStatus(sr StatusRepository) UpdateStatus

func (UpdateStatus) Handle

func (u UpdateStatus) Handle(ctx context.Context, cmd cqs.Command) ([]cqs.Event, error)

type UpdateStatusCmd

type UpdateStatusCmd struct {
	Weather weather.Weather
}

func (UpdateStatusCmd) Name

func (u UpdateStatusCmd) Name() string

type WeeklyProgramRepository

type WeeklyProgramRepository interface {
	Save(ctx context.Context, programs []program.Weekly) error
	FindAll(ctx context.Context) ([]program.Weekly, error)
	FindByDayAndHour(ctx context.Context, day program.WeekDay, hour program.Hour) (program.Weekly, error)
}

type ZoneRepository

type ZoneRepository interface {
	FindByID(ctx context.Context, id string) (zone.Zone, error)
	Save(ctx context.Context, zo zone.Zone) error
	Remove(ctx context.Context, zo zone.Zone) error
}

Jump to

Keyboard shortcuts

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