types

package
v0.0.0-...-4dfe32f Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package types contains declaration of various data types (usually structures) used elsewhere in the CCX Notification Service code.

Index

Constants

View Source
const (
	// DBDriverSQLite3 shows that db driver is sqlite
	DBDriverSQLite3 DBDriver = iota
	// DBDriverPostgres shows that db driver is postgres
	DBDriverPostgres
	// DBDriverGeneral general sql(used for mock now)
	DBDriverGeneral
	// NotificationBackendTarget matches the notification backend int code in the database (CCXDEV-8767)
	NotificationBackendTarget EventTarget = 1
	// ServiceLogTarget matches the service log int code in the database (CCXDEV-8767)
	ServiceLogTarget EventTarget = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountNumber

type AccountNumber uint32

AccountNumber represents account number for a given report.

type CliFlags

type CliFlags struct {
	InstantReports            bool
	WeeklyReports             bool
	ShowVersion               bool
	ShowAuthors               bool
	ShowConfiguration         bool
	PrintNewReportsForCleanup bool
	PerformNewReportsCleanup  bool
	PrintOldReportsForCleanup bool
	PerformOldReportsCleanup  bool
	CleanupOnStartup          bool
	Verbose                   bool
	MaxAge                    string
}

CliFlags represents structure holding all command line arguments/flags.

type ClusterEntry

type ClusterEntry struct {
	OrgID         OrgID
	AccountNumber AccountNumber
	ClusterName   ClusterName
	KafkaOffset   KafkaOffset
	UpdatedAt     Timestamp
}

ClusterEntry represents the entries retrieved from the DB

type ClusterName

type ClusterName string

ClusterName data type represents name of cluster in format c8590f31-e97e-4b85-b506-c45ce1911a12 (ie. in UUID format).

type ClusterOrgKey

type ClusterOrgKey struct {
	OrgID       OrgID
	ClusterName ClusterName
}

ClusterOrgKey is a slice with two items: an organization ID and a cluster UUID

type ClusterReport

type ClusterReport string

ClusterReport represents cluster report

type DBDriver

type DBDriver int

DBDriver type for db driver enum

type Digest

type Digest struct {
	ClustersAffected       int
	CriticalNotifications  int
	ImportantNotifications int
	Recommendations        int
	Incidents              int // We don't have this info, AFAIK
}

Digest is a structure containing the counters for weekly digest

type ErrorKey

type ErrorKey string

ErrorKey represents type for error key

type EvaluatedReportItem

type EvaluatedReportItem struct {
	ReportItem
	TotalRisk int
}

EvaluatedReportItem represents a report item with additional information after evaluation

type Event

type Event struct {
	Metadata EventMetadata `json:"metadata"`
	Payload  EventPayload  `json:"payload"`
}

Event is a structure containing the payload and its metadata.

type EventMetadata

type EventMetadata map[string]interface{}

EventMetadata represents the metadata of the sent payload. It is expected to be an empty struct as of today

type EventPayload

type EventPayload map[string]string

EventPayload is a JSON string containing all the data required by the app to compose the various messages (Email, webhook, ...).

type EventTarget

type EventTarget int8

EventTarget matches the backend int code in the database where the notifications are sent (CCXDEV-8767)

type EventType

type EventType int

EventType represents the allowed event types in notification messages

const (
	InstantNotif EventType = iota
)

Event types as enum

func (EventType) ToString

func (e EventType) ToString() string

ToString function returns string representation of given event type

type KafkaOffset

type KafkaOffset int64

KafkaOffset is a data type representing offset in Kafka topic.

type MissingMandatoryFile

type MissingMandatoryFile struct {
	FileName string
}

MissingMandatoryFile is an error raised while parsing, when a mandatory file is missing

func (MissingMandatoryFile) Error

func (err MissingMandatoryFile) Error() string

type ModuleName

type ModuleName string

ModuleName represents type for module name

type NotificationContext

type NotificationContext map[string]interface{}

NotificationContext represents the extra information that is common to all the events that are sent in this message as a JSON string (escaped)

type NotificationMessage

type NotificationMessage struct {
	Bundle      string              `json:"bundle"`
	Application string              `json:"application"`
	EventType   string              `json:"event_type"`
	Timestamp   string              `json:"timestamp"`
	AccountID   string              `json:"account_id"`
	OrgID       string              `json:"org_id"`
	Events      []Event             `json:"events"`
	Context     NotificationContext `json:"context"`
}

NotificationMessage represents content of messages sent to the notification platform topic in Kafka.

type NotificationRecord

type NotificationRecord struct {
	OrgID              OrgID
	AccountNumber      AccountNumber
	ClusterName        ClusterName
	UpdatedAt          Timestamp
	NotificationTypeID NotificationTypeID
	StateID            StateID
	Report             ClusterReport
	NotifiedAt         Timestamp
	ErrorLog           string
	EventTarget        EventTarget // this is the event_type_id (CCXDEV-8767)
}

NotificationRecord structure represents one record stored in `reported` table.

type NotificationType

type NotificationType struct {
	ID        NotificationTypeID
	Value     string
	Frequency string
	Comment   string
}

NotificationType represents one record from `notification_types` table.

type NotificationTypeID

type NotificationTypeID int

NotificationTypeID represents ID value in `notifiation_types` table.

type NotificationTypes

type NotificationTypes struct {
	Instant NotificationTypeID
	Weekly  NotificationTypeID
}

NotificationTypes contains all IDs for all possible notification types

type NotifiedRecordsPerCluster

type NotifiedRecordsPerCluster map[ClusterOrgKey]NotificationRecord

NotifiedRecordsPerCluster maps a string representation of ClusterOrgKey to a NotificationRecord

type NotifiedRecordsPerClusterByTarget

type NotifiedRecordsPerClusterByTarget map[EventTarget]NotifiedRecordsPerCluster

NotifiedRecordsPerClusterByTarget let us split the notified records by their target (CCXDEV-8767)

type OrgID

type OrgID uint32

OrgID data type represents organization ID.

type ProducerMessage

type ProducerMessage []byte

ProducerMessage is a byte array (typically converted JSON) to be processed by one of the Producer implementations

type RenderedReport

type RenderedReport struct {
	RuleID      RuleID   `json:"rule_id"`
	ErrorKey    ErrorKey `json:"error_key"`
	Resolution  string   `json:"resolution"`
	Reason      string   `json:"reason"`
	Description string   `json:"description"`
}

RenderedReport contains all rendered text fields for specific cluster report

type Report

type Report struct {
	Reports ReportContent `json:"reports"`
}

Report represents report send in a message consumed from any broker

type ReportContent

type ReportContent []*EvaluatedReportItem

ReportContent represents the array of items expected in a report

type ReportData

type ReportData struct {
	Clusters []ClusterName          `json:"clusters"`
	Reports  map[ClusterName]Report `json:"reports"`
}

ReportData is part of the request to content template renderer containing report data

type ReportItem

type ReportItem struct {
	Type     string          `json:"type"`
	Module   ModuleName      `json:"component"`
	ErrorKey ErrorKey        `json:"key"`
	Details  json.RawMessage `json:"details"`
}

ReportItem represents a single (hit) rule of the string encoded report

type RuleID

type RuleID string

RuleID represents type for rule id

type RuleName

type RuleName string

RuleName represents type for rule name

type Rules

type Rules []types.RuleContent

Rules is a slice of RuleContent objects

type RulesMap

type RulesMap map[string]types.RuleContent

RulesMap contains a map of RuleContent objects accesible indexed by rule names

type ServiceLogEntry

type ServiceLogEntry struct {
	ClusterUUID ClusterName `json:"cluster_uuid"`
	Description string      `json:"description"`
	ServiceName string      `json:"service_name"`
	Severity    string      `json:"severity"`
	Summary     string      `json:"summary"`
	CreatedBy   string      `json:"created_by"`
	Username    string      `json:"username"`
}

ServiceLogEntry is a structure to be sent to Service Log

type State

type State struct {
	ID      StateID
	Value   string
	Comment string
}

State represents one record from `states` table.

type StateID

type StateID int

StateID represents ID value in `states` table.

type States

type States struct {
	SameState       StateID
	SentState       StateID
	LowerIssueState StateID
	ErrorState      StateID
}

States contains all IDs for all possible states

type TagsSet

type TagsSet map[string]struct{}

TagsSet contains a set of tags

func MakeSetOfTags

func MakeSetOfTags(tags []string) TagsSet

MakeSetOfTags helper function makes set of tags from given list of tags

type TemplateRendererOutput

type TemplateRendererOutput struct {
	Clusters []ClusterName                    `json:"clusters"`
	Reports  map[ClusterName][]RenderedReport `json:"reports"`
}

TemplateRendererOutput is an output structure from content template renderer

type TemplateRendererRequestBody

type TemplateRendererRequestBody struct {
	Content    Rules      `json:"content"`
	ReportData ReportData `json:"report_data"`
}

TemplateRendererRequestBody is a structure to be sent in request body to content template renderer

type Timestamp

type Timestamp time.Time

Timestamp represents any timestamp in a form gathered from database TODO: need to be improved

Jump to

Keyboard shortcuts

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