contextgraph

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultThdWarnMinPerImport = 30 * time.Minute
	DefaultThdCritMinPerImport = 60 * time.Minute

	BulkMaxSize = 1000
)

Variables

View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrNotImplemented = errors.New("not implemented")

Functions

This section is empty.

Types

type API

type API interface {
	Import(c *gin.Context)
	Status(c *gin.Context)
}

func NewApi

func NewApi(
	conf config.CanopsisConf,
	jobQueue JobQueue,
	reporter StatusReporter,
	logger zerolog.Logger,
) API

type ConfigurationItem

type ConfigurationItem struct {
	ID               string                     `json:"_id" bson:"-"`
	Name             *string                    `json:"name" bson:"name,omitempty"`
	Depends          []string                   `json:"-" bson:"depends"`
	Impact           []string                   `json:"-" bson:"impact"`
	EnableHistory    []string                   `json:"-" bson:"enable_history"`
	Measurements     []interface{}              `json:"measurements" bson:"measurements"`
	EntityPatterns   *pattern.EntityPatternList `bson:"entity_patterns,omitempty" json:"entity_patterns"`
	OutputTemplate   *string                    `bson:"output_template,omitempty" json:"output_template"`
	Infos            map[string]interface{}     `json:"infos" bson:"infos"`
	Type             *string                    `json:"type" bson:"type,omitempty"`
	Category         *string                    `json:"category" bson:"category,omitempty"`
	ImpactLevel      *int64                     `json:"impact_level" bson:"impact_level,omitempty"`
	Enabled          *bool                      `json:"enabled" bson:"enabled,omitempty"`
	Action           string                     `json:"action" bson:"-"`
	ActionProperties interface{}                `json:"action_properties" bson:"-"`
}

type EventPublisher

type EventPublisher interface {
	SendImportResultEvent(uuid string, execTime time.Duration, state types.CpsNumber) error
	SendPerfDataEvent(uuid string, stats JobStats, state types.CpsNumber) error
	SendUpdateEntityServiceEvent(serviceId string) error
}

func NewRMQPublisher

func NewRMQPublisher(
	encoder encoding.Encoder,
	amqpPublisher libamqp.Publisher,
) EventPublisher

type Graph

type Graph struct {
	Impact  *[]string
	Depends *[]string
}

type ImportJob

type ImportJob struct {
	ID       string    `bson:"_id"`
	Creation time.Time `bson:"creation"`
	Status   string    `bson:"status"`
	Info     string    `bson:"info,omitempty"`
	ExecTime string    `bson:"exec_time,omitempty"`
	Stats    JobStats  `bson:"stats"`
}

type ImportResponse

type ImportResponse struct {
	ID string `json:"_id"`
}

type ImportWorker

type ImportWorker interface {
	Run(ctx context.Context)
}

func NewImportWorker

func NewImportWorker(
	conf config.CanopsisConf,
	dbClient libmongo.DbClient,
	publisher EventPublisher,
	reporter StatusReporter,
	queue JobQueue,
	logger zerolog.Logger,
) ImportWorker

type JobQueue

type JobQueue interface {
	Push(job ImportJob)
	Pop() ImportJob
}

func NewJobQueue

func NewJobQueue() JobQueue

type JobStats

type JobStats struct {
	ExecTime time.Duration `bson:"-" json:"-"`
	Deleted  int64         `bson:"deleted" json:"deleted"`
	Updated  int64         `bson:"updated" json:"updated"`
}
type Link struct {
	ID               string                 `json:"_id"`
	To               string                 `json:"to"`
	From             []string               `json:"from"`
	Infos            map[string]interface{} `json:"infos"`
	Action           string                 `json:"action"`
	ActionProperties interface{}            `json:"action_properties" bson:"-"`
}

type Request

type Request struct {
	Json struct {
		Cis   []ConfigurationItem `json:"cis"`
		Links []Link              `json:"links"`
	} `json:"json"`
}

for swagger

type StatusReporter

type StatusReporter interface {
	GetStatus(id string) (ImportJob, error)
	ReportCreate(job *ImportJob) error
	ReportOngoing(job ImportJob) error
	ReportDone(job ImportJob, stats JobStats) error
	ReportError(job ImportJob, execDuration time.Duration, err error) error
}

func NewMongoStatusReporter

func NewMongoStatusReporter(client libmongo.DbClient) StatusReporter

Jump to

Keyboard shortcuts

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