techmetrics

package
v0.0.0-...-8a398ea Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskStatusNone = iota
	TaskStatusRunning
	TaskStatusSucceeded
	TaskStatusFailed
	TaskStatusDisabled
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	GetSettings(c *gin.Context)
	UpdateSettings(c *gin.Context)
	StartExport(c *gin.Context)
	GetExport(c *gin.Context)
	DownloadExport(c *gin.Context)
}

func NewApi

func NewApi(
	taskExecutor TaskExecutor,
	store Store,
	timezoneConfigProvider config.TimezoneConfigProvider,
) API

type ExportResponse

type ExportResponse struct {
	// Possible values.
	//   * `0` - None
	//   * `1` - Running
	//   * `2` - Succeeded
	//   * `3` - Failed
	//   * `4` - Disabled
	Status   int               `json:"status"`
	Created  *datetime.CpsTime `json:"created,omitempty" swaggertype:"integer"`
	Duration *int              `json:"duration,omitempty"`
}

type Settings

type Settings struct {
	Enabled          bool   `bson:"enabled" json:"enabled"`
	DumpKeepInterval string `bson:"dumpkeepinterval" json:"-"`
}

type Store

type Store interface {
	GetSettings(ctx context.Context) (Settings, error)
	UpdateSettings(ctx context.Context, settings Settings) error
}

func NewStore

func NewStore(dbClient mongo.DbClient) Store

type Task

type Task struct {
	ID        int
	Status    int
	Filepath  string
	Created   time.Time
	LastPing  time.Time
	Started   *time.Time
	Completed *time.Time
}

type TaskExecutor

type TaskExecutor interface {
	Run(ctx context.Context)
	// StartExecute creates new export task.
	StartExecute(ctx context.Context) (Task, error)
	// GetStatus returns export task status.
	GetStatus(ctx context.Context) (Task, error)
}

TaskExecutor is used to implement export task executor.

func NewTaskExecutor

func NewTaskExecutor(
	store Store,
	logger zerolog.Logger,
) TaskExecutor

Jump to

Keyboard shortcuts

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