Documentation
¶
Index ¶
- Constants
- func Close(catalog MessageCatalog) error
- func Reload(catalog MessageCatalog) error
- func ResetStats(catalog MessageCatalog) error
- type Config
- type ContextKey
- type DefaultError
- type DefaultMessageCatalog
- func (dmc *DefaultMessageCatalog) Close()
- func (dmc *DefaultMessageCatalog) GetErrorWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) error
- func (dmc *DefaultMessageCatalog) GetMessageWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) *Message
- func (dmc *DefaultMessageCatalog) LoadMessages(lang string, messages []RawMessage) error
- func (dmc *DefaultMessageCatalog) Reload() error
- func (dmc *DefaultMessageCatalog) ResetStats()
- func (dmc *DefaultMessageCatalog) SnapshotStats() MessageCatalogStats
- func (dmc *DefaultMessageCatalog) WrapErrorWithCtx(ctx context.Context, err error, msgCode int, msgParams ...interface{}) error
- type Error
- type Message
- type MessageCatalog
- type MessageCatalogStats
- type MessageParams
- type Messages
- type Observer
- type RawMessage
Constants ¶
View Source
const ( SystemMessageMinCode = 9000 SystemMessageMaxCode = 9999 CodeMissingMessage = 999999002 CodeMissingLanguage = 999999001 )
View Source
const MessageCatalogNotFound = "Unexpected error in message catalog, language [%s] not found. %s"
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close(catalog MessageCatalog) error
func Reload ¶
func Reload(catalog MessageCatalog) error
func ResetStats ¶
func ResetStats(catalog MessageCatalog) error
Types ¶
type ContextKey ¶
type ContextKey string
type DefaultError ¶
type DefaultError struct {
// contains filtered or unexported fields
}
func (DefaultError) Error ¶
func (ce DefaultError) Error() string
func (*DefaultError) ErrorCode ¶
func (ce *DefaultError) ErrorCode() int
func (*DefaultError) GetLongMessage ¶
func (ce *DefaultError) GetLongMessage() string
func (*DefaultError) GetShortMessage ¶
func (ce *DefaultError) GetShortMessage() string
func (*DefaultError) Unwrap ¶
func (ce *DefaultError) Unwrap() error
type DefaultMessageCatalog ¶
type DefaultMessageCatalog struct {
// contains filtered or unexported fields
}
func (*DefaultMessageCatalog) Close ¶
func (dmc *DefaultMessageCatalog) Close()
func (*DefaultMessageCatalog) GetErrorWithCtx ¶
func (dmc *DefaultMessageCatalog) GetErrorWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) error
func (*DefaultMessageCatalog) GetMessageWithCtx ¶
func (dmc *DefaultMessageCatalog) GetMessageWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) *Message
func (*DefaultMessageCatalog) LoadMessages ¶
func (dmc *DefaultMessageCatalog) LoadMessages(lang string, messages []RawMessage) error
func (*DefaultMessageCatalog) Reload ¶
func (dmc *DefaultMessageCatalog) Reload() error
func (*DefaultMessageCatalog) ResetStats ¶
func (dmc *DefaultMessageCatalog) ResetStats()
func (*DefaultMessageCatalog) SnapshotStats ¶
func (dmc *DefaultMessageCatalog) SnapshotStats() MessageCatalogStats
func (*DefaultMessageCatalog) WrapErrorWithCtx ¶
type MessageCatalog ¶
type MessageCatalog interface {
// Allows to load more messages (9000 - 9999 - reserved to system messages)
LoadMessages(lang string, messages []RawMessage) error
GetMessageWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) *Message
WrapErrorWithCtx(ctx context.Context, err error, msgCode int, msgParams ...interface{}) error
GetErrorWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) error
}
func NewMessageCatalog ¶
func NewMessageCatalog(cfg Config) (MessageCatalog, error)
type MessageCatalogStats ¶
type MessageCatalogStats struct {
LanguageFallbacks map[string]int
MissingLanguages map[string]int
MissingMessages map[string]int
TemplateIssues map[string]int
DroppedEvents map[string]int
LastReloadAt time.Time
}
func SnapshotStats ¶
func SnapshotStats(catalog MessageCatalog) (MessageCatalogStats, error)
type MessageParams ¶
type MessageParams struct {
Params map[string]interface{}
}
type Messages ¶
type Messages struct {
Group int `yaml:"group"`
Default RawMessage `yaml:"default"`
Set map[int]RawMessage `yaml:"set"`
}
type RawMessage ¶
Click to show internal directories.
Click to hide internal directories.