Documentation
¶
Overview ¶
Package escalation provides SLA escalation calculation and management.
Package escalation provides SLA escalation calculation and management.
Index ¶
- func InitGlobalEventHandler(db *sql.DB, logger *log.Logger) error
- func TriggerArticleCreate(ctx context.Context, ticketID, userID int)
- func TriggerTicketCreate(ctx context.Context, ticketID, userID int)
- func TriggerTicketUpdate(ctx context.Context, ticketID, userID int)
- type CalendarService
- func (s *CalendarService) AddWorkingTime(calendarName string, start time.Time, minutes int) time.Time
- func (s *CalendarService) GetCalendar(name string) *cal.BusinessCalendar
- func (s *CalendarService) IsWorkingTime(calendarName string, t time.Time) bool
- func (s *CalendarService) LoadCalendars(ctx context.Context) error
- func (s *CalendarService) WorkingTimeBetween(calendarName string, start, end time.Time) int64
- type CheckService
- type EscalatingTicket
- type EscalationEvent
- type EscalationInfo
- type EscalationPreferences
- type EventHandler
- func (h *EventHandler) Initialize(ctx context.Context) error
- func (h *EventHandler) OnArticleCreate(ctx context.Context, ticketID, userID int)
- func (h *EventHandler) OnTicketCreate(ctx context.Context, ticketID, userID int)
- func (h *EventHandler) OnTicketMerge(ctx context.Context, ticketID, userID int)
- func (h *EventHandler) OnTicketQueueUpdate(ctx context.Context, ticketID, userID int)
- func (h *EventHandler) OnTicketSLAUpdate(ctx context.Context, ticketID, userID int)
- func (h *EventHandler) OnTicketServiceUpdate(ctx context.Context, ticketID, userID int)
- func (h *EventHandler) OnTicketStateUpdate(ctx context.Context, ticketID, userID int)
- func (h *EventHandler) OnTicketUpdate(ctx context.Context, ticketID, userID int)
- type Service
- type TicketInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitGlobalEventHandler ¶
InitGlobalEventHandler initializes the global event handler. Should be called during application startup.
func TriggerArticleCreate ¶
TriggerArticleCreate triggers escalation index rebuild after article creation. Safe to call even if handler not initialized (will be a no-op).
func TriggerTicketCreate ¶
TriggerTicketCreate triggers escalation index build for a new ticket. Safe to call even if handler not initialized (will be a no-op).
func TriggerTicketUpdate ¶
TriggerTicketUpdate triggers escalation index rebuild for an updated ticket. Safe to call even if handler not initialized (will be a no-op).
Types ¶
type CalendarService ¶
type CalendarService struct {
// contains filtered or unexported fields
}
CalendarService manages business calendars, wrapping rickar/cal with OTRS sysconfig.
func NewCalendarService ¶
func NewCalendarService(db *sql.DB) *CalendarService
NewCalendarService creates a new calendar service.
func (*CalendarService) AddWorkingTime ¶
func (s *CalendarService) AddWorkingTime(calendarName string, start time.Time, minutes int) time.Time
AddWorkingTime adds working time (in minutes) to a start time and returns the destination time. This wraps rickar/cal's AddWorkHours for OTRS compatibility (minutes instead of Duration).
func (*CalendarService) GetCalendar ¶
func (s *CalendarService) GetCalendar(name string) *cal.BusinessCalendar
GetCalendar returns a calendar by name. Name can be empty (default), "1"-"9", or "Calendar1"-"Calendar9".
func (*CalendarService) IsWorkingTime ¶
func (s *CalendarService) IsWorkingTime(calendarName string, t time.Time) bool
IsWorkingTime checks if a given time is within working hours.
func (*CalendarService) LoadCalendars ¶
func (s *CalendarService) LoadCalendars(ctx context.Context) error
LoadCalendars loads all calendars from sysconfig.
func (*CalendarService) WorkingTimeBetween ¶
func (s *CalendarService) WorkingTimeBetween(calendarName string, start, end time.Time) int64
WorkingTimeBetween calculates working time in seconds between two times.
type CheckService ¶
type CheckService struct {
// contains filtered or unexported fields
}
CheckService handles escalation event triggering, matching OTRS EscalationCheck.
func NewCheckService ¶
func NewCheckService(db *sql.DB, calendarService *CalendarService, logger *log.Logger) *CheckService
NewCheckService creates a new escalation check service.
func (*CheckService) CheckEscalations ¶
func (s *CheckService) CheckEscalations(ctx context.Context) ([]EscalationEvent, error)
CheckEscalations finds tickets that are escalating and triggers events. This matches OTRS Maint::Ticket::EscalationCheck.
func (*CheckService) SetDecayTime ¶
func (s *CheckService) SetDecayTime(minutes int)
SetDecayTime sets the decay time (minutes between repeat notifications).
type EscalatingTicket ¶
EscalatingTicket holds basic ticket info for escalation check.
type EscalationEvent ¶
EscalationEvent represents an escalation event to trigger.
type EscalationInfo ¶
type EscalationInfo struct {
FirstResponseTimeEscalation bool
FirstResponseTimeNotification bool
UpdateTimeEscalation bool
UpdateTimeNotification bool
SolutionTimeEscalation bool
SolutionTimeNotification bool
}
EscalationInfo holds ticket escalation state.
type EscalationPreferences ¶
type EscalationPreferences struct {
FirstResponseTime int // Minutes until first response required
FirstResponseNotify int // Percentage for warning notification
UpdateTime int // Minutes between updates required
UpdateNotify int // Percentage for warning notification
SolutionTime int // Minutes until solution required
SolutionNotify int // Percentage for warning notification
Calendar string // Calendar name (empty = default, "1"-"9" = named)
}
EscalationPreferences holds escalation settings from SLA or Queue.
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
EventHandler handles ticket events that require escalation index updates. This matches OTRS Kernel::System::Ticket::Event::TicketEscalationIndex.
func GetEventHandler ¶
func GetEventHandler() *EventHandler
GetEventHandler returns the global event handler. Returns nil if not initialized.
func NewEventHandler ¶
func NewEventHandler(db *sql.DB, logger *log.Logger) *EventHandler
NewEventHandler creates a new escalation event handler.
func (*EventHandler) Initialize ¶
func (h *EventHandler) Initialize(ctx context.Context) error
Initialize loads calendars and prepares the handler.
func (*EventHandler) OnArticleCreate ¶
func (h *EventHandler) OnArticleCreate(ctx context.Context, ticketID, userID int)
OnArticleCreate handles new article events. Should be called when an article is added (may affect update escalation).
func (*EventHandler) OnTicketCreate ¶
func (h *EventHandler) OnTicketCreate(ctx context.Context, ticketID, userID int)
OnTicketCreate handles ticket creation events. Should be called after a new ticket is created.
func (*EventHandler) OnTicketMerge ¶
func (h *EventHandler) OnTicketMerge(ctx context.Context, ticketID, userID int)
OnTicketMerge handles ticket merge events. The merged ticket should have escalation cleared.
func (*EventHandler) OnTicketQueueUpdate ¶
func (h *EventHandler) OnTicketQueueUpdate(ctx context.Context, ticketID, userID int)
OnTicketQueueUpdate handles queue change events. Should be called when ticket is moved to different queue (escalation settings may differ).
func (*EventHandler) OnTicketSLAUpdate ¶
func (h *EventHandler) OnTicketSLAUpdate(ctx context.Context, ticketID, userID int)
OnTicketSLAUpdate handles SLA change events. Should be called when ticket SLA is changed.
func (*EventHandler) OnTicketServiceUpdate ¶
func (h *EventHandler) OnTicketServiceUpdate(ctx context.Context, ticketID, userID int)
OnTicketServiceUpdate handles service change events.
func (*EventHandler) OnTicketStateUpdate ¶
func (h *EventHandler) OnTicketStateUpdate(ctx context.Context, ticketID, userID int)
OnTicketStateUpdate handles ticket state change events. Should be called when ticket state changes (may clear escalation for closed tickets).
func (*EventHandler) OnTicketUpdate ¶
func (h *EventHandler) OnTicketUpdate(ctx context.Context, ticketID, userID int)
OnTicketUpdate is a generic handler for any ticket update. Use this when you're not sure which specific event occurred.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles ticket escalation index calculation matching OTRS behavior.
func NewService ¶
NewService creates a new escalation service.
func (*Service) Initialize ¶
Initialize loads calendars from sysconfig.
func (*Service) RebuildAllTicketEscalations ¶
RebuildAllTicketEscalations rebuilds escalation index for all open tickets. This is useful for bulk updates after SLA/Queue changes.