Documentation
¶
Index ¶
Constants ¶
const ( AppName string = "notify-server" AppConfigFileName = AppName + ".json" )
애플리케이션 기본 정보
const ( // DefaultMaxRetries HTTP 요청 실패 시 최대 재시도 횟수 기본값 DefaultMaxRetries = 3 // DefaultRetryDelay 재시도 사이의 대기 시간 기본값 DefaultRetryDelay = "2s" )
HTTP 재시도 기본값
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
type AppConfig struct {
Debug bool `json:"debug"`
HTTPRetry HTTPRetryConfig `json:"http_retry"`
Notifiers NotifierConfig `json:"notifiers"`
Tasks []TaskConfig `json:"tasks"`
NotifyAPI NotifyAPIConfig `json:"notify_api"`
}
AppConfig 애플리케이션 전체 설정 구조체 JSON to Go struct 변환 도구: mholt.github.io/json-to-go
func InitAppConfig ¶
func InitAppConfigWithFile ¶
InitAppConfigWithFile 지정된 파일에서 설정을 로드합니다. 이 함수는 테스트에서 사용할 수 있도록 파일명을 인자로 받습니다.
func (*AppConfig) SetDefaults ¶ added in v1.0.1
func (c *AppConfig) SetDefaults()
type ApplicationConfig ¶
type ApplicationConfig struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
DefaultNotifierID string `json:"default_notifier_id"`
AppKey string `json:"app_key"`
}
ApplicationConfig 애플리케이션 설정 구조체
type CORSConfig ¶ added in v1.0.1
type CORSConfig struct {
AllowOrigins []string `json:"allow_origins"`
}
CORSConfig CORS 설정 구조체
func (*CORSConfig) Validate ¶ added in v1.0.1
func (c *CORSConfig) Validate() error
Validate CORS 설정의 유효성을 검사합니다.
type CommandConfig ¶ added in v1.0.1
type CommandConfig struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Scheduler struct {
Runnable bool `json:"runnable"`
TimeSpec string `json:"time_spec"`
} `json:"scheduler"`
Notifier struct {
Usable bool `json:"usable"`
} `json:"notifier"`
DefaultNotifierID string `json:"default_notifier_id"`
Data map[string]interface{} `json:"data"`
}
CommandConfig Task 명령 설정 구조체
type HTTPRetryConfig ¶
type HTTPRetryConfig struct {
MaxRetries int `json:"max_retries"`
RetryDelay string `json:"retry_delay"`
}
HTTPRetryConfig HTTP 재시도 설정 구조체
func (*HTTPRetryConfig) Validate ¶ added in v1.0.1
func (c *HTTPRetryConfig) Validate() error
Validate HTTPRetryConfig의 유효성을 검사합니다.
type NotifierConfig ¶
type NotifierConfig struct {
DefaultNotifierID string `json:"default_notifier_id"`
Telegrams []TelegramConfig `json:"telegrams"`
}
NotifierConfig 알림 설정 구조체
func (*NotifierConfig) Validate ¶
func (c *NotifierConfig) Validate() ([]string, error)
Validate NotifierConfig의 유효성을 검사하고, 정의된 모든 Notifier의 ID 목록을 반환합니다. 반환된 ID 목록은 Task 및 Application 설정에서 참조하는 NotifierID의 유효성을 검증하는 데 사용됩니다.
type NotifyAPIConfig ¶
type NotifyAPIConfig struct {
WS WSConfig `json:"ws"`
CORS CORSConfig `json:"cors"`
Applications []ApplicationConfig `json:"applications"`
}
NotifyAPIConfig 알림 API 설정 구조체
func (*NotifyAPIConfig) Validate ¶
func (c *NotifyAPIConfig) Validate(notifierIDs []string) error
Validate NotifyAPIConfig의 유효성을 검사합니다.
type TaskConfig ¶
type TaskConfig struct {
ID string `json:"id"`
Title string `json:"title"`
Commands []CommandConfig `json:"commands"`
Data map[string]interface{} `json:"data"`
}
TaskConfig Task 설정 구조체
type TelegramConfig ¶
type TelegramConfig struct {
ID string `json:"id"`
BotToken string `json:"bot_token"`
ChatID int64 `json:"chat_id"`
}
TelegramConfig 텔레그램 알림 설정 구조체