Documentation
¶
Index ¶
- Variables
- type AdapterRegistry
- type ChannelAdapter
- type Engine
- type Repository
- type Service
- func (s *Service) Create(ctx context.Context, input domain.CreateChannelInput) (domain.Channel, error)
- func (s *Service) CreateRule(ctx context.Context, input domain.CreateRuleInput) (domain.Rule, error)
- func (s *Service) Delete(ctx context.Context, channelID uuid.UUID) error
- func (s *Service) DeleteRule(ctx context.Context, ruleID uuid.UUID) error
- func (s *Service) Get(ctx context.Context, channelID uuid.UUID) (domain.Channel, error)
- func (s *Service) GetRule(ctx context.Context, ruleID uuid.UUID) (domain.Rule, error)
- func (s *Service) List(ctx context.Context, organizationID uuid.UUID) ([]domain.Channel, error)
- func (s *Service) ListRules(ctx context.Context, projectID uuid.UUID) ([]domain.Rule, error)
- func (s *Service) MatchingRules(ctx context.Context, projectID uuid.UUID, eventType domain.RuleEventType) ([]domain.Rule, error)
- func (s *Service) SendRule(ctx context.Context, rule domain.Rule, message domain.Message) error
- func (s *Service) SendToProjectChannels(ctx context.Context, projectID uuid.UUID, message domain.Message) error
- func (s *Service) Test(ctx context.Context, channelID uuid.UUID) error
- func (s *Service) Update(ctx context.Context, input domain.UpdateChannelInput) (domain.Channel, error)
- func (s *Service) UpdateRule(ctx context.Context, input domain.UpdateRuleInput) (domain.Rule, error)
- type SlackAdapter
- type TelegramAdapter
- type WeComAdapter
- type WebhookAdapter
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnavailable = errors.New("notification service unavailable") // ErrOrganizationNotFound reports a missing organization. ErrOrganizationNotFound = domain.ErrOrganizationNotFound // ErrProjectNotFound reports a missing project. ErrProjectNotFound = domain.ErrProjectNotFound // ErrChannelNotFound reports a missing notification channel. ErrChannelNotFound = domain.ErrChannelNotFound // ErrChannelInUse reports a notification channel still referenced by rules. ErrChannelInUse = domain.ErrChannelInUse // ErrDuplicateChannelName reports duplicate channel names within the same organization. ErrDuplicateChannelName = domain.ErrDuplicateChannelName // ErrRuleNotFound reports a missing notification rule. ErrRuleNotFound = domain.ErrRuleNotFound // ErrDuplicateRuleName reports duplicate notification rule names within the same project. ErrDuplicateRuleName = domain.ErrDuplicateRuleName // ErrChannelProjectMismatch reports that the selected channel belongs to a different organization. ErrChannelProjectMismatch = errors.New("notification channel does not belong to the rule project organization") // ErrInvalidChannelConfig reports invalid persisted or patched channel config. ErrInvalidChannelConfig = errors.New("notification channel config is invalid") )
var ( ErrAdapterUnavailable = errors.New("notification channel adapter is not available") )
Functions ¶
This section is empty.
Types ¶
type AdapterRegistry ¶
type AdapterRegistry struct {
// contains filtered or unexported fields
}
AdapterRegistry resolves adapters by channel type.
func NewAdapterRegistry ¶
func NewAdapterRegistry(adapters ...ChannelAdapter) *AdapterRegistry
NewAdapterRegistry constructs a registry from explicit adapters.
func NewDefaultAdapterRegistry ¶
func NewDefaultAdapterRegistry(httpClient *http.Client) *AdapterRegistry
NewDefaultAdapterRegistry constructs the built-in adapter registry.
func (*AdapterRegistry) Get ¶
func (r *AdapterRegistry) Get(channelType domain.ChannelType) (ChannelAdapter, error)
Get resolves the adapter for the given channel type.
type ChannelAdapter ¶
type ChannelAdapter interface {
Type() domain.ChannelType
Send(ctx context.Context, cfg domain.ChannelConfig, msg domain.Message) error
Validate(ctx context.Context, cfg domain.ChannelConfig) error
}
ChannelAdapter provides transport-specific delivery logic.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine subscribes to runtime events and sends best-effort notifications.
type Repository ¶
type Repository interface {
OrganizationExists(ctx context.Context, organizationID uuid.UUID) (bool, error)
Project(ctx context.Context, projectID uuid.UUID) (domain.ProjectRef, error)
Channels(ctx context.Context, organizationID uuid.UUID, enabledOnly bool) ([]domain.Channel, error)
Channel(ctx context.Context, channelID uuid.UUID) (domain.Channel, error)
CreateChannel(ctx context.Context, input domain.CreateChannelInput) (domain.Channel, error)
UpdateChannel(ctx context.Context, channel domain.Channel) (domain.Channel, error)
DeleteChannel(ctx context.Context, channelID uuid.UUID) error
Rules(ctx context.Context, projectID uuid.UUID) ([]domain.Rule, error)
Rule(ctx context.Context, ruleID uuid.UUID) (domain.Rule, error)
CreateRule(ctx context.Context, input domain.CreateRuleInput) (domain.Rule, error)
UpdateRule(ctx context.Context, rule domain.Rule) (domain.Rule, error)
DeleteRule(ctx context.Context, ruleID uuid.UUID) error
MatchingRules(ctx context.Context, projectID uuid.UUID, eventType domain.RuleEventType) ([]domain.Rule, error)
}
Repository owns notification persistence behind the service boundary.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides notification channel CRUD plus adapter-backed delivery.
func NewService ¶
NewService constructs a notification service.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, input domain.CreateChannelInput) (domain.Channel, error)
Create validates and persists a new notification channel.
func (*Service) CreateRule ¶
func (s *Service) CreateRule(ctx context.Context, input domain.CreateRuleInput) (domain.Rule, error)
CreateRule validates and persists a new notification rule.
func (*Service) DeleteRule ¶
DeleteRule removes a persisted notification rule.
func (*Service) MatchingRules ¶
func (s *Service) MatchingRules(ctx context.Context, projectID uuid.UUID, eventType domain.RuleEventType) ([]domain.Rule, error)
MatchingRules resolves enabled notification rules for a project and event type.
func (*Service) SendToProjectChannels ¶
func (s *Service) SendToProjectChannels(ctx context.Context, projectID uuid.UUID, message domain.Message) error
SendToProjectChannels fans a message out to all enabled channels in the project's organization.
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, input domain.UpdateChannelInput) (domain.Channel, error)
Update applies a partial update to a notification channel.
func (*Service) UpdateRule ¶
func (s *Service) UpdateRule(ctx context.Context, input domain.UpdateRuleInput) (domain.Rule, error)
UpdateRule applies a partial update to a notification rule.
type SlackAdapter ¶
type SlackAdapter struct {
// contains filtered or unexported fields
}
SlackAdapter sends simple text payloads to incoming webhooks.
func (*SlackAdapter) Send ¶
func (a *SlackAdapter) Send(ctx context.Context, cfg domain.ChannelConfig, msg domain.Message) error
func (*SlackAdapter) Type ¶
func (a *SlackAdapter) Type() domain.ChannelType
func (*SlackAdapter) Validate ¶
func (a *SlackAdapter) Validate(_ context.Context, cfg domain.ChannelConfig) error
type TelegramAdapter ¶
type TelegramAdapter struct {
// contains filtered or unexported fields
}
TelegramAdapter sends plain-text Bot API messages.
func (*TelegramAdapter) Send ¶
func (a *TelegramAdapter) Send(ctx context.Context, cfg domain.ChannelConfig, msg domain.Message) error
func (*TelegramAdapter) Type ¶
func (a *TelegramAdapter) Type() domain.ChannelType
func (*TelegramAdapter) Validate ¶
func (a *TelegramAdapter) Validate(_ context.Context, cfg domain.ChannelConfig) error
type WeComAdapter ¶
type WeComAdapter struct {
// contains filtered or unexported fields
}
WeComAdapter sends markdown robot webhook messages.
func (*WeComAdapter) Send ¶
func (a *WeComAdapter) Send(ctx context.Context, cfg domain.ChannelConfig, msg domain.Message) error
func (*WeComAdapter) Type ¶
func (a *WeComAdapter) Type() domain.ChannelType
func (*WeComAdapter) Validate ¶
func (a *WeComAdapter) Validate(_ context.Context, cfg domain.ChannelConfig) error
type WebhookAdapter ¶
type WebhookAdapter struct {
// contains filtered or unexported fields
}
WebhookAdapter sends JSON payloads to arbitrary HTTP endpoints.
func (*WebhookAdapter) Send ¶
func (a *WebhookAdapter) Send(ctx context.Context, cfg domain.ChannelConfig, msg domain.Message) error
func (*WebhookAdapter) Type ¶
func (a *WebhookAdapter) Type() domain.ChannelType
func (*WebhookAdapter) Validate ¶
func (a *WebhookAdapter) Validate(_ context.Context, cfg domain.ChannelConfig) error