Documentation
¶
Index ¶
- func NewNotifier(id NotifierID, supportsHTML bool, bufferSize int) notifier
- type DefaultNotifierFactory
- type NotifierConfigProcessor
- type NotifierFactory
- type NotifierHandler
- type NotifierID
- type Sender
- type Service
- func (s *Service) Notify(taskCtx task.TaskContext, notifierID string, message string) bool
- func (s *Service) NotifyDefault(message string) bool
- func (s *Service) NotifyDefaultWithError(message string) bool
- func (s *Service) NotifyWithTitle(notifierID string, title string, message string, errorOccurred bool) bool
- func (s *Service) SetNotifierFactory(factory NotifierFactory)
- func (s *Service) Start(serviceStopCtx context.Context, serviceStopWG *sync.WaitGroup) error
- func (s *Service) SupportsHTML(notifierID string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNotifier ¶ added in v1.0.1
func NewNotifier(id NotifierID, supportsHTML bool, bufferSize int) notifier
NewNotifier Notifier를 생성하고 초기화합니다.
Types ¶
type DefaultNotifierFactory ¶ added in v1.0.1
type DefaultNotifierFactory struct {
// contains filtered or unexported fields
}
DefaultNotifierFactory 기본 NotifierFactory 구현체입니다.
func NewNotifierFactory ¶ added in v1.0.1
func NewNotifierFactory() *DefaultNotifierFactory
NewNotifierFactory 새로운 DefaultNotifierFactory를 생성합니다.
func (*DefaultNotifierFactory) CreateNotifiers ¶ added in v1.0.1
func (f *DefaultNotifierFactory) CreateNotifiers(appConfig *config.AppConfig, executor task.Executor) ([]NotifierHandler, error)
CreateNotifiers 설정을 기반으로 활성화된 모든 Notifier를 생성하여 반환합니다.
func (*DefaultNotifierFactory) RegisterProcessor ¶ added in v1.0.1
func (f *DefaultNotifierFactory) RegisterProcessor(processor NotifierConfigProcessor)
RegisterProcessor 새로운 설정 프로세서를 등록합니다.
type NotifierConfigProcessor ¶ added in v1.0.1
type NotifierConfigProcessor func(appConfig *config.AppConfig, executor task.Executor) ([]NotifierHandler, error)
NotifierConfigProcessor 설정에서 특정 알림 타입(예: Telegram)을 생성하는 함수 타입입니다.
func NewTelegramConfigProcessor ¶ added in v1.0.1
func NewTelegramConfigProcessor(creator telegramNotifierCreatorFunc) NotifierConfigProcessor
NewTelegramConfigProcessor 텔레그램 Notifier 설정을 처리하는 NotifierConfigProcessor를 생성하여 반환합니다. 이 처리기는 애플리케이션 설정에 따라 텔레그램 Notifier 인스턴스들을 초기화합니다.
type NotifierFactory ¶ added in v1.0.1
type NotifierFactory interface {
CreateNotifiers(appConfig *config.AppConfig, executor task.Executor) ([]NotifierHandler, error)
}
NotifierFactory 알림 핸들러 생성을 담당하는 팩토리 인터페이스입니다.
type NotifierHandler ¶ added in v1.0.0
type NotifierHandler interface {
ID() NotifierID
// Run Notifier의 메인 루프를 실행합니다.
// 메시지 큐를 소비하여 실제 발송 작업을 수행합니다.
Run(notificationStopCtx context.Context)
// Notify 알림 발송 요청을 처리합니다.
// 실제 발송은 비동기 큐를 통해 처리될 수 있습니다.
//
// 반환값:
// - succeeded: 요청이 정상적으로 접수되었는지 여부
Notify(taskCtx task.TaskContext, message string) (succeeded bool)
SupportsHTML() bool
}
NotifierHandler 개별 알림 채널(예: Telegram, Slack) 구현을 위한 인터페이스입니다. Service는 이 인터페이스를 통해 다양한 알림 수단을 일관된 방식으로 관리하고 사용합니다. 주로 notification 패키지 내부에서 사용되나, 통합 테스트 및 외부 확장을 위해 공개되어 있습니다.
type Sender ¶ added in v1.0.1
type Sender interface {
// NotifyWithTitle 지정된 NotifierID로 제목(Title)이 포함된 알림 메시지를 발송합니다.
// 일반 메시지뿐만 아니라 제목을 명시하여 알림의 맥락을 명확히 전달할 수 있습니다.
// errorOccurred 플래그를 통해 해당 알림이 오류 상황에 대한 것인지 명시할 수 있습니다.
//
// 파라미터:
// - notifierID: 메시지를 발송할 대상 Notifier의 고유 ID
// - title: 알림 메시지의 제목 (강조 표시 등에 활용)
// - message: 전송할 알림 메시지의 본문
// - errorOccurred: 오류 발생 여부 (true일 경우 오류 상황으로 처리되어 시각적 강조 등이 적용될 수 있음)
//
// 반환값:
// - bool: 발송 요청이 성공적으로 큐에 등록되었는지 여부 (실제 전송 결과와는 무관)
NotifyWithTitle(notifierID string, title string, message string, errorOccurred bool) bool
// NotifyDefault 시스템에 설정된 기본(Default) 알림 채널로 일반 메시지를 발송합니다.
// 주로 시스템 전반적인 알림이나, 특정 대상을 지정하지 않은 일반적인 정보 전달에 사용됩니다.
//
// 파라미터:
// - message: 전송할 메시지 내용
//
// 반환값:
// - bool: 발송 요청이 성공적으로 큐에 등록되었는지 여부
NotifyDefault(message string) bool
// NotifyDefaultWithError 시스템 기본 알림 채널로 "오류" 성격의 알림 메시지를 발송합니다.
// 시스템 내부 에러, 작업 실패 등 관리자의 주의가 필요한 긴급 상황 알림에 적합합니다.
// 내부적으로 오류 플래그가 설정되어 발송되므로, 수신 측에서 이를 인지하여 처리할 수 있습니다.
//
// 파라미터:
// - message: 전송할 오류 메시지 내용
//
// 반환값:
// - bool: 발송 요청이 성공적으로 큐에 등록되었는지 여부
NotifyDefaultWithError(message string) bool
}
Sender 알림 발송 기능을 제공하는 인터페이스입니다. 외부 컴포넌트(API, 스케줄러 등)는 이 인터페이스를 통해 알림 서비스를 사용합니다.
type Service ¶ added in v1.0.1
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Notify ¶ added in v1.0.1
Notify 지정된 Notifier를 통해 알림 메시지를 발송합니다. TaskContext를 직접 생성하여 알림을 보낼 때 사용합니다.
파라미터:
- taskCtx: 알림 발송 시 함께 전달할 TaskContext
- notifierID: 알림 채널 ID
- message: 전송할 메시지 내용
반환값:
- bool: 발송 요청이 성공적으로 큐에 등록되었는지 여부 (실제 전송 성공 여부는 아님)
func (*Service) NotifyDefault ¶ added in v1.0.1
NotifyDefault 시스템 기본 알림 채널로 알림 메시지를 발송합니다.
파라미터:
- message: 전송할 메시지 내용
반환값:
- bool: 발송 요청이 성공적으로 큐에 등록되었는지 여부 (실제 전송 성공 여부는 아님)
func (*Service) NotifyDefaultWithError ¶ added in v1.0.1
NotifyDefaultWithError 시스템 기본 알림 채널로 "에러" 알림 메시지를 발송합니다. 시스템 오류, 작업 실패 등 관리자의 주의가 필요한 상황에서 사용합니다. 내부적으로 TaskContext에 Error 속성을 추가하여 Notifier가 이를 인지할 수 있게 합니다.
파라미터:
- message: 전송할 메시지 내용
반환값:
- bool: 발송 요청이 성공적으로 큐에 등록되었는지 여부 (실제 전송 성공 여부는 아님)
func (*Service) NotifyWithTitle ¶ added in v1.0.1
func (s *Service) NotifyWithTitle(notifierID string, title string, message string, errorOccurred bool) bool
NotifyWithTitle 지정된 Notifier를 통해 알림 메시지를 발송합니다. API 핸들러 등 외부에서 특정 채널을 통하여 알림을 보내고 싶을 때 사용합니다.
파라미터:
- notifierID: 알림 채널 ID
- title: 알림 메시지의 제목 (TaskContext에 저장됨)
- message: 전송할 메시지 내용
- errorOccurred: 에러 발생 여부
반환값:
- bool: 발송 요청이 성공적으로 큐에 등록되었는지 여부 (실제 전송 성공 여부는 아님)
func (*Service) SetNotifierFactory ¶ added in v1.0.1
func (s *Service) SetNotifierFactory(factory NotifierFactory)
func (*Service) SupportsHTML ¶ added in v1.0.1
SupportsHTML 해당 Notifier가 HTML 포맷을 지원하는지 확인합니다.