Documentation
¶
Index ¶
- Constants
- Variables
- type Breaches
- type Deadlines
- type Manager
- func (m *Manager) ApplySLA(startTime time.Time, conversationID, assignedTeamID, slaPolicyID int) (models.SLAPolicy, error)
- func (m *Manager) CalculateDeadline(start time.Time, slaMinutes int, businessHours models.BusinessHours, ...) (time.Time, error)
- func (m *Manager) Close() error
- func (m *Manager) Create(name, description string, ...) (models.SLAPolicy, error)
- func (m *Manager) CreateNextResponseSLAEvent(conversationID, appliedSLAID, slaPolicyID, assignedTeamID int) (time.Time, error)
- func (m *Manager) Delete(id int) error
- func (m *Manager) Get(id int) (models.SLAPolicy, error)
- func (m *Manager) GetAll() ([]models.SLAPolicy, error)
- func (m *Manager) GetDeadlines(startTime time.Time, slaPolicyID, assignedTeamID int) (Deadlines, error)
- func (m *Manager) Run(ctx context.Context, interval time.Duration)
- func (m *Manager) SendNotification(scheduledNotification models.ScheduledSLANotification) error
- func (m *Manager) SendNotifications(ctx context.Context) error
- func (m *Manager) SetLatestSLAEventMetAt(appliedSLAID int, metric string) (time.Time, error)
- func (m *Manager) Update(id int, name, description string, ...) (models.SLAPolicy, error)
- type Opts
Constants ¶
const ( MetricFirstResponse = "first_response" MetricResolution = "resolution" MetricNextResponse = "next_response" MetricAll = "all" NotificationTypeWarning = "warning" NotificationTypeBreach = "breach" )
Variables ¶
var ( ErrInvalidSLADuration = fmt.Errorf("invalid SLA duration") ErrMaxIterations = fmt.Errorf("sla: exceeded maximum iterations - check configuration") ErrInvalidTime = fmt.Errorf("invalid time") )
var ( ErrUnmetSLAEventAlreadyExists = errors.New("unmet SLA event already exists, cannot create a new one for the same applied SLA and metric") ErrLatestSLAEventNotFound = errors.New("latest SLA event not found for the applied SLA and metric") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func New ¶
func New( opts Opts, teamStore teamStore, appSettingsStore appSettingsStore, businessHrsStore businessHrsStore, template *template.Manager, userStore userStore, dispatcher *notifier.Dispatcher, ) (*Manager, error)
New creates a new SLA manager.
func (*Manager) ApplySLA ¶
func (m *Manager) ApplySLA(startTime time.Time, conversationID, assignedTeamID, slaPolicyID int) (models.SLAPolicy, error)
ApplySLA applies an SLA policy to a conversation by calculating and setting the deadlines.
func (*Manager) CalculateDeadline ¶
func (m *Manager) CalculateDeadline(start time.Time, slaMinutes int, businessHours models.BusinessHours, timeZone string) (time.Time, error)
CalculateDeadline computes the SLA deadline from a start time and SLA duration in minutes considering the provided holidays, working hours, and time zone.
func (*Manager) Create ¶
func (m *Manager) Create(name, description string, firstResponseTime, resolutionTime, nextResponseTime null.String, notifications models.SlaNotifications) (models.SLAPolicy, error)
Create creates a new SLA policy.
func (*Manager) CreateNextResponseSLAEvent ¶
func (m *Manager) CreateNextResponseSLAEvent(conversationID, appliedSLAID, slaPolicyID, assignedTeamID int) (time.Time, error)
CreateNextResponseSLAEvent creates a next response SLA event for a conversation.
func (*Manager) GetDeadlines ¶
func (m *Manager) GetDeadlines(startTime time.Time, slaPolicyID, assignedTeamID int) (Deadlines, error)
GetDeadlines returns the deadline for a given start time, sla policy and assigned team.
func (*Manager) SendNotification ¶
func (m *Manager) SendNotification(scheduledNotification models.ScheduledSLANotification) error
SendNotification sends a SLA notification to agents, a schedule notification is always linked to an applied SLA and optionally to a SLA event.
func (*Manager) SendNotifications ¶
SendNotifications picks scheduled SLA notifications from the database and sends them to agents as emails.
func (*Manager) SetLatestSLAEventMetAt ¶
SetLatestSLAEventMetAt marks the latest SLA event as met for a given applied SLA.