notifications

package
v0.0.0-...-7578c0e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MaxProcessingTime = time.Second * 10
View Source
const NotificationType refs.IdentifiableType = "notification"

Variables

View Source
var AllTargets = []Target{TargetMail, TargetScript}

Functions

func NewDispatcher

func NewDispatcher(repository store) dispatcher

Types

type Consumer

type Consumer interface {
	Process(ctx context.Context, details NotificationDetails) (string, error)
	Target() Target
}

type ContentType

type ContentType string

ContentType represents a content type for the Msg

const (
	ContentTypeTextPlain ContentType = "text/plain"
	ContentTypeTextHTML  ContentType = "text/html"
	ContentTypeTextJSON  ContentType = "text/json"
)

func (ContentType) Valid

func (t ContentType) Valid() error

type Dispatcher

type Dispatcher interface {
	Dispatch(ctx context.Context, refID refs.Identifiable, notification NotificationData) (refs.Identifiable, error)
}

type NotificationData

type NotificationData struct {
	Target      string      `json:"target"`
	Recipients  []string    `json:"recipients"`
	Subject     string      `json:"subject"`
	Content     string      `json:"content"`
	ContentType ContentType `json:"content_type"`
}

type NotificationDetails

type NotificationDetails struct {
	RefID  refs.Identifiable
	Data   NotificationData
	State  ProcessingState
	ID     refs.Identifiable
	Out    string
	Target Target
	Err    string
}

type NotificationID

type NotificationID refs.Identifiable

type NotificationSummary

type NotificationSummary struct {
	State          ProcessingState `db:"state"`
	NotificationID string          `db:"notification_id"`
	Transport      string          `db:"transport"`
	Timestamp      string          `db:"timestamp"`
	Out            string          `db:"out"`
	Err            string          `db:"err"`
}

type ProcessingState

type ProcessingState string
const ProcessingStateDispatching ProcessingState = "dispatching"
const ProcessingStateDone ProcessingState = "done"
const ProcessingStateError ProcessingState = "error"
const ProcessingStateQueued ProcessingState = "queued"

type Processor

type Processor interface {
	Close() error
}

func NewProcessor

func NewProcessor(logger *logger.Logger, store Store, consumers ...Consumer) Processor

type Store

type Store interface {
	Create(ctx context.Context, details NotificationDetails) error
	SetDone(ctx context.Context, details NotificationDetails, out string) error
	SetError(ctx context.Context, details NotificationDetails, out, err string) error
	NotificationStream(target Target) chan NotificationDetails
	Close() error
}

type Target

type Target string
const TargetMail Target = "smtp"
const TargetScript Target = "script"

func FigureOutTarget

func FigureOutTarget(target string) Target

func (Target) Valid

func (t Target) Valid() bool

Directories

Path Synopsis
channels
repository

Jump to

Keyboard shortcuts

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