Documentation ¶
Index ¶
- func ReplaceGlobals(repository Repository) func()
- type FrontNotification
- type MockNotification
- type Notification
- type PostgresRepository
- func (r *PostgresRepository) Create(notif Notification) (int64, error)
- func (r *PostgresRepository) Delete(id int64) error
- func (r *PostgresRepository) Get(id int64) *FrontNotification
- func (r *PostgresRepository) GetAll(queryOptionnal dbutils.DBQueryOptionnal) ([]FrontNotification, error)
- func (r *PostgresRepository) UpdateRead(id int64, status bool) error
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceGlobals ¶
func ReplaceGlobals(repository Repository) func()
ReplaceGlobals affects a new repository to the global repository singleton
Types ¶
type FrontNotification ¶
type FrontNotification struct { Notification IsRead bool }
FrontNotification data structure represente the notification and her current state
type MockNotification ¶
type MockNotification struct { ID int64 `json:"id"` Type string `json:"type"` CreationDate time.Time `json:"creationDate"` Groups []int64 `json:"groups"` Level string `json:"level"` Title string `json:"title"` SubTitle string `json:"subtitle"` Description string `json:"description"` Context map[string]interface{} `json:"context,omitempty"` }
MockNotification is an implementation of a notification main type
func NewMockNotification ¶
func NewMockNotification(level string, title string, subTitle string, description string, creationDate time.Time, groups []int64, context map[string]interface{}) *MockNotification
NewMockNotification renders a new MockNotification instance
func (MockNotification) ToBytes ¶
func (n MockNotification) ToBytes() ([]byte, error)
ToBytes convert a notification in a json byte slice to be sent though any required channel
type Notification ¶
Notification is a general interface for all notifications types
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
PostgresRepository is a repository containing the Fact definition based on a PSQL database and implementing the repository interface
func (*PostgresRepository) Create ¶
func (r *PostgresRepository) Create(notif Notification) (int64, error)
Create creates a new Notification definition in the repository
func (*PostgresRepository) Delete ¶
func (r *PostgresRepository) Delete(id int64) error
Delete deletes a notification from the repository by its id
func (*PostgresRepository) Get ¶
func (r *PostgresRepository) Get(id int64) *FrontNotification
Get returns a notification by it's ID
func (*PostgresRepository) GetAll ¶
func (r *PostgresRepository) GetAll(queryOptionnal dbutils.DBQueryOptionnal) ([]FrontNotification, error)
GetByRoles returns all notifications related to a certain list of roles
func (*PostgresRepository) UpdateRead ¶
func (r *PostgresRepository) UpdateRead(id int64, status bool) error
UpdateRead updates a notification status by changing the isRead state to true once it has been read
type Repository ¶
type Repository interface { Create(notif Notification) (int64, error) Get(id int64) *FrontNotification GetAll(queryOptionnal dbutils.DBQueryOptionnal) ([]FrontNotification, error) Delete(id int64) error UpdateRead(id int64, state bool) 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 facts
func NewPostgresRepository ¶
func NewPostgresRepository(dbClient *sqlx.DB) Repository
NewPostgresRepository returns a new instance of PostgresRepository