contextgraph

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending = "pending"
	StatusOngoing = "ongoing"
	StatusFailed  = "failed"
	StatusDone    = "done"
)

Variables

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

Functions

This section is empty.

Types

type API

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

func NewApi

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

type EventPublisher

type EventPublisher interface {
	SendImportResultEvent(ctx context.Context, uuid string, execTime time.Duration, state types.CpsNumber) error
	SendPerfDataEvent(ctx context.Context, uuid string, stats importcontextgraph.Stats, state types.CpsNumber) error
}

func NewEventPublisher

func NewEventPublisher(
	exchange, queue string,
	encoder encoding.Encoder,
	contentType string,
	amqpPublisher libamqp.Publisher,
) EventPublisher

type ImportJob

type ImportJob struct {
	ID       string     `bson:"_id" json:"_id"`
	Creation time.Time  `bson:"creation" json:"creation"`
	LastPing *time.Time `bson:"last_ping,omitempty" json:"last_ping"`
	Status   string     `bson:"status" json:"status"`
	Info     string     `bson:"info,omitempty" json:"info"`
	ExecTime string     `bson:"exec_time,omitempty" json:"exec_time"`
	Source   string     `bson:"source" json:"source"`

	Stats importcontextgraph.Stats `bson:"stats" json:"stats"`

	IsPartial bool `bson:"is_partial" json:"-"`
}

type ImportQuery

type ImportQuery struct {
	Source string `form:"source" binding:"required"`
}

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,
	publisher EventPublisher,
	reporter StatusReporter,
	importWorker importcontextgraph.Worker,
	logger zerolog.Logger,
) ImportWorker

type StatusReporter

type StatusReporter interface {
	GetStatus(ctx context.Context, id string) (ImportJob, error)
	GetFirst(ctx context.Context, abandonedInterval time.Duration) (ImportJob, error)
	ReportCreate(ctx context.Context, job *ImportJob) error
	ReportOngoing(ctx context.Context, job ImportJob) error
	ReportDone(ctx context.Context, job ImportJob, stats importcontextgraph.Stats) (bool, error)
	ReportError(ctx context.Context, job ImportJob, execDuration time.Duration, err error) (bool, error)
	Clean(ctx context.Context, interval time.Duration) 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