notifiers

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 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 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 Magistrala notifications functionality.

Index

Constants

This section is empty.

Variables

View Source
var ErrMessage = errors.New("failed to convert to Magistrala message")

ErrMessage indicates an error converting a message to Magistrala 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.BlockingConsumer
}

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 mocks contains mocks for testing purposes.
Package mocks contains mocks for testing purposes.
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 Magistrala SMS notifications.
Package smpp contains the domain concept definitions needed to support Magistrala SMS notifications.
Package smtp contains the domain concept definitions needed to support Magistrala SMTP notifications.
Package smtp contains the domain concept definitions needed to support Magistrala SMTP notifications.
Package tracing provides tracing instrumentation for Magistrala WebSocket adapter service.
Package tracing provides tracing instrumentation for Magistrala WebSocket adapter service.

Jump to

Keyboard shortcuts

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