notifiers

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Notifiers service

Notifiers service provides a service for sending notifications using Notifiers. Notifiers service can be configured to use different types of Notifiers to send different types of notifications such as SMS messages, emails, or push notifications. Service is extensible so that new implementations of Notifiers can be easily added. Notifiers are not standalone services but rather dependencies used by Notifiers service for sending notifications over specific protocols.

Configuration

The channel profile should include a list of contact emails. These emails are the recipients of the messages sent by the service. Configuration of the service is achieved through environment variables. The environment variables needed for service configuration depend on the underlying Notifier. An example of the service configuration for SMTP Notifier can be found in SMTP Notifier documentation. Note that any unset variables will be replaced with their default values.

Usage

Subscriptions service will start consuming messages and sending notifications when a message is received.

Documentation

Overview

Package notifiers contain the domain concept definitions needed to support Mainflux notifications functionality.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotify = errors.New("failed to send notification")

ErrNotify wraps sending notification errors,

Functions

This section is empty.

Types

type Notifier

type Notifier interface {
	// Notify method is used to send notification for the
	// received message to the provided list of receivers.
	Notify(to []string, msg protomfx.Message) error

	// ValidateContacts method is used to validate contacts
	// to which notifications will be sent.
	ValidateContacts(contacts []string) error
}

Notifier represents an API for sending notification.

type NotifierRepository

type NotifierRepository interface {
	// Save persists multiple notifiers. Notifiers are saved using a transaction.
	// If one notifier fails then none will be saved.
	// Successful operation is indicated by non-nil error response.
	Save(ctx context.Context, nfs ...things.Notifier) ([]things.Notifier, error)

	// RetrieveByGroupID retrieves notifiers related to a certain group identified by a given ID.
	RetrieveByGroupID(ctx context.Context, groupID string, pm things.PageMetadata) (things.NotifiersPage, error)

	// RetrieveByID retrieves the notifier having the provided identifier
	RetrieveByID(ctx context.Context, id string) (things.Notifier, error)

	// Update performs an update to the existing notifier. A non-nil error is
	// returned to indicate operation failure.
	Update(ctx context.Context, n things.Notifier) error

	// Remove removes the notifiers having the provided identifiers
	Remove(ctx context.Context, ids ...string) error
}

NotifierRepository specifies a notifier persistence API.

type Service

type Service interface {
	// CreateNotifiers creates notifiers for certain group identified by the provided ID
	CreateNotifiers(ctx context.Context, token string, notifiers ...things.Notifier) ([]things.Notifier, error)

	// ListNotifiersByGroup retrieves data about a subset of notifiers
	// related to a certain group identified by the provided ID.
	ListNotifiersByGroup(ctx context.Context, token string, groupID string, pm things.PageMetadata) (things.NotifiersPage, error)

	// ViewNotifier retrieves data about the notifier identified with the provided ID
	ViewNotifier(ctx context.Context, token, id string) (things.Notifier, error)

	// UpdateNotifier updates the notifier identified by the provided ID, that
	// belongs to the user identified by the provided key.
	UpdateNotifier(ctx context.Context, token string, notifier things.Notifier) error

	// RemoveNotifiers removes the notifiers identified with the provided IDs, that
	// belongs to the user identified by the provided key.
	RemoveNotifiers(ctx context.Context, token, groupID string, id ...string) error

	consumers.Consumer
}

Service represents a notification service.

func New

func New(idp uuid.IDProvider, notifier Notifier, notifierRepo NotifierRepository, things protomfx.ThingsServiceClient) Service

New instantiates the subscriptions service implementation.

Directories

Path Synopsis
api
Package smpp contains the domain concept definitions needed to support Mainflux SMS notifications.
Package smpp contains the domain concept definitions needed to support Mainflux SMS notifications.
Package smtp contains the domain concept definitions needed to support Mainflux SMTP notifications.
Package smtp contains the domain concept definitions needed to support Mainflux SMTP notifications.

Jump to

Keyboard shortcuts

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