notifiers

package
v0.0.0-...-f17446d Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 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 service is configured using the 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 (
	// ErrMessage indicates an error converting a message to Mainflux message.
	ErrMessage = errors.New("failed to convert to Mainflux message")
)
View Source
var ErrNotify = errors.New("Error sending 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(from string, to []string, msg messaging.Message) error
}

Notifier represents an API for sending notification.

type Page

type Page struct {
	PageMetadata
	Total         uint
	Subscriptions []Subscription
}

Page represents page metadata with content.

type PageMetadata

type PageMetadata struct {
	Offset uint
	// Limit values less than 0 indicate no limit.
	Limit   int
	Topic   string
	Contact string
}

PageMetadata contains page metadata that helps navigation.

type Service

type Service interface {
	// CreateSubscription persists a subscription.
	// Successful operation is indicated by non-nil error response.
	CreateSubscription(ctx context.Context, token string, sub Subscription) (string, error)

	// ViewSubscription retrieves the subscription for the given user and id.
	ViewSubscription(ctx context.Context, token, id string) (Subscription, error)

	// ListSubscriptions lists subscriptions having the provided user token and search params.
	ListSubscriptions(ctx context.Context, token string, pm PageMetadata) (Page, error)

	// RemoveSubscription removes the subscription having the provided identifier.
	RemoveSubscription(ctx context.Context, token, id string) error

	consumers.Consumer
}

Service reprents a notification service.

func New

New instantiates the subscriptions service implementation.

type Subscription

type Subscription struct {
	ID      string
	OwnerID string
	Contact string
	Topic   string
}

Subscription represents a user Subscription.

type SubscriptionsRepository

type SubscriptionsRepository interface {
	// Save persists a subscription. Successful operation is indicated by non-nil
	// error response.
	Save(ctx context.Context, sub Subscription) (string, error)

	// Retrieve retrieves the subscription for the given id.
	Retrieve(ctx context.Context, id string) (Subscription, error)

	// RetrieveAll retrieves all the subscriptions for the given page metadata.
	RetrieveAll(ctx context.Context, pm PageMetadata) (Page, error)

	// Remove removes the subscription for the given ID.
	Remove(ctx context.Context, id string) error
}

SubscriptionsRepository specifies a Subscription persistence API.

Directories

Path Synopsis
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package postgres contains repository implementations using PostgreSQL as the underlying database.
Package postgres contains repository implementations using PostgreSQL as the underlying database.
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.
Package tracing contains middlewares that will add spans to existing traces.
Package tracing contains middlewares that will add spans to existing traces.

Jump to

Keyboard shortcuts

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