notifications

package
v0.0.0-...-7b61fee Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

README

README

This package contains the notifications client written in the Go programming language. The notifications client is used by Go services or other Go code to communicate with the EdgeX support-notifications microservice (regardless of underlying implemenation type) by sending REST requests to the service's API endpoints.

How To Use

To use the support-notifications client package you first need to import the library into your project:

import "github.com/Circutor/edgex/pkg/clients/notifications"

To send a notification you first need to get a NotificationsClient and then send a Notification struct:

		notification := notifications.Notification{
			Slug:        configuration.NotificationsSlug + strconv.FormatInt((time.Now().UnixNano()/int64(time.Millisecond)), 10),
			Content:     configuration.NotificationContent + name + "-" + string(action),
			Category:    notifications.SW_HEALTH,
			Description: configuration.NotificationDescription,
			Labels:      []string{configuration.NotificationLabel},
			Sender:      configuration.NotificationSender,
			Severity:    notifications.NORMAL,
		}

		notifications.GetNotificationsClient().SendNotification(notification)

This will send the notification to the notifications service.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CategoryEnum

type CategoryEnum string
const (
	SECURITY  CategoryEnum = "SECURITY"
	HW_HEALTH CategoryEnum = "HW_HEALTH"
	SW_HEALTH CategoryEnum = "SW_HEALTH"
)

type Notification

type Notification struct {
	Id          string       `json:"id,omitempty"` // Generated by the system, users can ignore
	Slug        string       `json:"slug"`         // A meaningful identifier provided by client
	Sender      string       `json:"sender"`
	Category    CategoryEnum `json:"category"`
	Severity    SeverityEnum `json:"severity"`
	Content     string       `json:"content"`
	Description string       `json:"description,omitempty"`
	Status      StatusEnum   `json:"status,omitempty"`
	Labels      []string     `json:"labels,omitempty"`
	Created     int          `json:"created,omitempty"`  // The creation timestamp
	Modified    int          `json:"modified,omitempty"` // The last modification timestamp
}

Struct to represent a notification being sent to the notifications service

type NotificationsClient

type NotificationsClient interface {
	SendNotification(n Notification, ctx context.Context) error
}

Interface defining behavior for the notifications client

func NewNotificationsClient

func NewNotificationsClient(url string) NotificationsClient

type SeverityEnum

type SeverityEnum string
const (
	CRITICAL SeverityEnum = "CRITICAL"
	NORMAL   SeverityEnum = "NORMAL"
)

type StatusEnum

type StatusEnum string
const (
	NEW       StatusEnum = "NEW"
	PROCESSED StatusEnum = "PROCESSED"
	ESCALATED StatusEnum = "ESCALATED"
)

Jump to

Keyboard shortcuts

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