Documentation ¶
Index ¶
- func ReplaceGlobals(repository Repository) func()
- type PostgresRulesRepository
- func (r *PostgresRulesRepository) CheckByName(name string) (bool, error)
- func (r *PostgresRulesRepository) Create(rule Rule) (int64, error)
- func (r *PostgresRulesRepository) Delete(id int64) error
- func (r *PostgresRulesRepository) Get(id int64) (Rule, bool, error)
- func (r *PostgresRulesRepository) GetAll() (map[int64]Rule, error)
- func (r *PostgresRulesRepository) GetAllEnabled() (map[int64]Rule, error)
- func (r *PostgresRulesRepository) GetAllModifiedFrom(from time.Time) (map[int64]Rule, error)
- func (r *PostgresRulesRepository) GetByName(name string) (Rule, bool, error)
- func (r *PostgresRulesRepository) GetByVersion(id int64, version int64) (Rule, bool, error)
- func (r *PostgresRulesRepository) Update(rule Rule) error
- type Repository
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceGlobals ¶
func ReplaceGlobals(repository Repository) func()
ReplaceGlobals affect a new repository to the global repository singleton
Types ¶
type PostgresRulesRepository ¶
type PostgresRulesRepository struct {
// contains filtered or unexported fields
}
PostgresRulesRepository is a repository containing the rules based on a PSQL database and implementing the repository interface
func (*PostgresRulesRepository) CheckByName ¶
func (r *PostgresRulesRepository) CheckByName(name string) (bool, error)
CheckByName returns if at least one row exists with the input rule name
func (*PostgresRulesRepository) Create ¶
func (r *PostgresRulesRepository) Create(rule Rule) (int64, error)
Create creates a new Rule in the repository
func (*PostgresRulesRepository) Delete ¶
func (r *PostgresRulesRepository) Delete(id int64) error
Delete deletes an entry from the repository by it's ID
func (*PostgresRulesRepository) Get ¶
func (r *PostgresRulesRepository) Get(id int64) (Rule, bool, error)
Get search and returns an entity from the repository by its id
func (*PostgresRulesRepository) GetAll ¶
func (r *PostgresRulesRepository) GetAll() (map[int64]Rule, error)
GetAll returns all entities in the repository
func (*PostgresRulesRepository) GetAllEnabled ¶
func (r *PostgresRulesRepository) GetAllEnabled() (map[int64]Rule, error)
GetAllEnabled returns all entities in the repository that are enabled (column enabled = true)
func (*PostgresRulesRepository) GetAllModifiedFrom ¶
GetAllModifiedFrom returns all entities that have been modified since 'from' parameter
func (*PostgresRulesRepository) GetByName ¶
func (r *PostgresRulesRepository) GetByName(name string) (Rule, bool, error)
GetByName search and returns an entity from the repository by its name
func (*PostgresRulesRepository) GetByVersion ¶
GetByVersion search and returns an entity from the repository by its id
func (*PostgresRulesRepository) Update ¶
func (r *PostgresRulesRepository) Update(rule Rule) error
Update updates an entity in the repository by its name
type Repository ¶
type Repository interface { CheckByName(name string) (bool, error) Create(rule Rule) (int64, error) Get(id int64) (Rule, bool, error) GetByVersion(id int64, version int64) (Rule, bool, error) GetByName(name string) (Rule, bool, error) Update(rule Rule) error Delete(id int64) error GetAll() (map[int64]Rule, error) GetAllEnabled() (map[int64]Rule, error) GetAllModifiedFrom(from time.Time) (map[int64]Rule, error) }
Repository is a storage interface which can be implemented by multiple backend (in-memory map, sql database, in-memory cache, file system, ...) It allows standard CRUD operation on situations
func NewPostgresRepository ¶
func NewPostgresRepository(dbClient *sqlx.DB) Repository
NewPostgresRepository returns a new instance of PostgresRulesRepository
type Rule ¶
type Rule struct { Name string `json:"name"` Description string `json:"description"` Enabled bool `json:"enabled"` CalendarID int `json:"calendarId"` ruleeng.DefaultRule }
Rule ...
func (Rule) EqualTo ¶
EqualTo returns true if the rule is equal to the rule passed as parameter or false otherwise
func (*Rule) IsValid ¶
IsValid checks if a rule definition is valid and has no missing mandatory fields
func (Rule) SameCasesAs ¶
SameCasesAs returns true if the cases of the are equal to the case of the rule passed as parameter or false otherwise
func (*Rule) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to Expression