usecase

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package usecase 는 알림 채널 관리와 발송이다.

Index

Constants

This section is empty.

Variables

View Source
var ErrOrgRequired = errors.New("organization is required")

ErrOrgRequired 는 조직 없이 채널을 다루려 한 경우다 — 채널은 조직마다 따로다.

Functions

This section is empty.

Types

type ChannelService

type ChannelService struct {
	// contains filtered or unexported fields
}

ChannelService 는 조직의 알림 채널을 만들고 고치고 지운다.

func NewChannelService

func NewChannelService(repo port.ChannelRepository) *ChannelService

func (*ChannelService) Create

func (*ChannelService) Delete

func (s *ChannelService) Delete(ctx context.Context, orgID, id string) error

func (*ChannelService) Get

func (s *ChannelService) Get(ctx context.Context, orgID, id string) (*domain.Channel, error)

func (*ChannelService) List

func (s *ChannelService) List(ctx context.Context, orgID string) ([]*domain.Channel, error)

func (*ChannelService) Update

func (s *ChannelService) Update(ctx context.Context, orgID, id string, u domain.ChannelUpdate) (*domain.Channel, error)

Update 는 바꿀 칸만 적용한다. 비밀을 비워 보내면 기존 값을 지킨다.

type CreateChannelInput

type CreateChannelInput struct {
	OrgID    string
	Name     string
	Type     domain.ChannelType
	Settings domain.Settings
	Secret   string
	Events   []sharednotify.EventType
	Active   *bool
}

CreateChannelInput 은 새 채널이다. Active 가 nil 이면 켠다.

type Deliverer

type Deliverer struct {
	// contains filtered or unexported fields
}

Deliverer 는 채널 하나로 메시지를 보내고(일시적 실패는 재시도) 결과를 발송 이력에 남긴다.

func NewDeliverer

func NewDeliverer(senders map[domain.ChannelType]port.Sender, deliveries port.DeliveryRepository) *Deliverer

func (*Deliverer) Deliver

func (d *Deliverer) Deliver(ctx context.Context, ch *domain.Channel, msg domain.Message) *domain.Delivery

Deliver 는 보낸 결과를 돌려준다. 이력 기록이 실패해도 발송 결과는 그대로다.

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher 는 생산자의 이벤트를 그 조직의 구독 채널로 보낸다(sharednotify.Publisher).

func NewDispatcher

func NewDispatcher(channels port.ChannelRepository, deliverer *Deliverer) *Dispatcher

func (*Dispatcher) Publish

func (d *Dispatcher) Publish(ctx context.Context, event sharednotify.Event) error

Publish 는 켜져 있고 그 이벤트를 구독한 채널마다 보낸다. 한 채널이 실패해도 나머지는 보내고, 실패를 모아 돌려준다. 구독한 채널이 없으면 할 일이 없다 — 오류가 아니다.

type ListDeliveries

type ListDeliveries struct {
	// contains filtered or unexported fields
}

ListDeliveries 는 조직의 최근 발송 이력이다.

func NewListDeliveries

func NewListDeliveries(deliveries port.DeliveryRepository) *ListDeliveries

func (*ListDeliveries) Execute

func (l *ListDeliveries) Execute(ctx context.Context, orgID string, limit int) ([]*domain.Delivery, error)

type SendTest

type SendTest struct {
	// contains filtered or unexported fields
}

SendTest 는 채널 설정을 확인하는 테스트 메시지를 보낸다. 꺼진 채널에도 보낸다 — 켜기 전에 확인하는 버튼이다. 결과는 발송 이력에도 남는다.

func NewSendTest

func NewSendTest(channels port.ChannelRepository, deliverer *Deliverer) *SendTest

func (*SendTest) Execute

func (s *SendTest) Execute(ctx context.Context, orgID, id string) (*domain.Delivery, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL