reply

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeNotification = "NOTIFICATION"
	EventTypeProgress     = "PROGRESS"
	EventTypeTaskResult   = "TASK_RESULT"
)
View Source
const (
	StateBefore = "BEFORE"
	StateAfter  = "AFTER"
)
View Source
const (
	EventDistroUpdate       = "distrobox.Update"
	EventDistroContainerAdd = "distrobox.ContainerAdd"

	EventDistroSavePackagesToDB = "distro.SavePackagesToDB"
	EventDistroGetContainerList = "distro.GetContainerList"
	EventDistroExportingApp     = "distro.ExportingApp"
	EventDistroGetContainerInfo = "distro.GetContainerOsInfo"
	EventDistroCreateContainer  = "distro.CreateContainer"
	EventDistroRemoveContainer  = "distro.RemoveContainer"
	EventDistroInstallPackage   = "distro.InstallPackage"
	EventDistroRemovePackage    = "distro.RemovePackage"
	EventDistroGetPackages      = "distro.GetPackages"
	EventDistroGetPackageOwner  = "distro.GetPackageOwner"
	EventDistroGetPathByPkg     = "distro.GetPathByPackageName"
	EventDistroGetInfoPackage   = "distro.GetInfoPackage"
	EventDistroUpdatePackages   = "distro.UpdatePackages"
	EventDistroGetPackagesQuery = "distro.GetPackagesQuery"

	EventSystemWorking              = "system.Working"
	EventSystemUpgrade              = "system.Upgrade"
	EventSystemCheck                = "system.Check"
	EventSystemUpdate               = "system.Update"
	EventSystemInstall              = "system.Install"
	EventSystemRemove               = "system.Remove"
	EventSystemCheckInstall         = "system.CheckInstall"
	EventSystemCheckRemove          = "system.CheckRemove"
	EventSystemCheckUpgrade         = "system.CheckUpgrade"
	EventSystemImageUpdate          = "system.ImageUpdate"
	EventSystemImageApply           = "system.ImageApply"
	EventSystemImageSwitch          = "system.ImageSwitch"
	EventSystemUpdateKernel         = "system.UpdateKernel"
	EventSystemUpdateSTPLR          = "system.UpdateSTPLR"
	EventSystemAptUpdate            = "system.AptUpdate"
	EventSystemSavePackagesToDB     = "system.SavePackagesToDB"
	EventSystemSaveImageToDB        = "system.SaveImageToDB"
	EventSystemBuildImage           = "system.BuildImage"
	EventSystemImageModule          = "system.imageModule"
	EventSystemSwitchImage          = "system.SwitchImage"
	EventSystemCheckUpdateBaseImage = "system.CheckAndUpdateBaseImage"
	EventSystemBootcUpgrade         = "system.bootcUpgrade"
	EventSystemPruneOldImages       = "system.pruneOldImages"
	EventSystemUpdateAllPackagesDB  = "system.updateAllPackagesDB"
	EventSystemUpdateApplications   = "system.UpdateApplications"
	EventSystemDownloadProgress     = "system.downloadProgress"
	EventSystemInstallProgress      = "system.installProgress"
	EventSystemPullImage            = "system.pullImage"
	EventSystemLintTmpfiles         = "system.LintTmpfiles"
	EventSystemLintSysusers         = "system.LintSysusers"
	EventSystemLintRunTmp           = "system.LintRunTmp"

	EventApplicationUpdate   = "application.Update"
	EventApplicationSaveToDB = "application.SaveToDB"

	EventBootcLayers   = "service.bootc-layers"
	EventBootcDownload = "service.bootc-download"

	EventKernelCurrent          = "kernel.CurrentKernel"
	EventKernelList             = "kernel.ListKernels"
	EventKernelListModules      = "kernel.ListKernelModules"
	EventKernelInstall          = "kernel.InstallKernel"
	EventKernelCheckInstall     = "kernel.CheckInstallKernel"
	EventKernelUpdate           = "kernel.UpdateKernel"
	EventKernelCheckUpdate      = "kernel.CheckUpdateKernel"
	EventKernelClean            = "kernel.CleanOldKernels"
	EventKernelCheckClean       = "kernel.CheckCleanOldKernels"
	EventKernelInstallMods      = "kernel.InstallKernelModules"
	EventKernelCheckInstallMods = "kernel.CheckInstallKernelModules"
	EventKernelRemoveMods       = "kernel.RemoveKernelModules"
	EventKernelCheckRemoveMods  = "kernel.CheckRemoveKernelModules"
	EventKernelRemove           = "kernel.RemovePackage"
	EventKernelCheckRemove      = "kernel.CheckRemovePackage"
)

Имена событий — константы для использования в WithEventName.

Variables

This section is empty.

Functions

func CreateSpinner

func CreateSpinner(appConfig *app.Config)

CreateSpinner создание и запуск спиннера.

func IsInteractive

func IsInteractive(appConfig *app.Config) bool

IsInteractive возвращает true если формат text и терминал интерактивный (для TUI и других штук)

func IsTTY

func IsTTY() bool

func MessageWithHint

func MessageWithHint(message string, full bool) string

MessageWithHint дополняет message подсказкой об использовании --full

func RegisterFieldFormatter

func RegisterFieldFormatter(fn func(key string, value interface{}) (string, bool))

RegisterFieldFormatter добавляет форматтер значения поля для текстового вывода

func SetWebSocketHub

func SetWebSocketHub(hub WebSocketBroadcaster)

SetWebSocketHub устанавливает WebSocket hub для отправки событий

func StopSpinner

func StopSpinner(appConfig *app.Config)

StopSpinner останавливает активный спиннер.

func TranslateKey

func TranslateKey(key string) string

TranslateKey принимает ключ и возвращает английский текст.

func UnmarshalField

func UnmarshalField(body map[string]json.RawMessage, key string, target interface{}) error

UnmarshalField извлекает и десериализует поле из тела запроса

func WriteHTTPError

func WriteHTTPError(rw http.ResponseWriter, err error)

WriteHTTPError записывает классифицированную ошибку в HTTP-ответ. Если ошибка является APMError, используется соответствующий HTTP-статус. Иначе возвращается 500 Internal Server Error.

Types

type APIError

type APIError struct {
	ErrorCode string `json:"errorCode"`
	Message   string `json:"message"`
}

type APIResponse

type APIResponse struct {
	Data        interface{} `json:"data"`
	Error       *APIError   `json:"error"`
	Transaction string      `json:"transaction,omitempty"`
}

func ErrorResponseFromError

func ErrorResponseFromError(err error) APIResponse

func OK

func OK(data interface{}) APIResponse

type EventData

type EventData struct {
	Name            string  `json:"name"`
	View            string  `json:"message"`
	State           string  `json:"state"`
	Type            string  `json:"type"`
	ProgressPercent float64 `json:"progress"`
	ProgressDone    string  `json:"progressDone"`
	Transaction     string  `json:"transaction"`
}

EventData содержит данные события.

type NotificationOption

type NotificationOption func(*EventData)

NotificationOption определяет функцию-опцию для настройки EventData.

func WithEventName

func WithEventName(name string) NotificationOption

WithEventName задаёт имя события.

func WithEventView

func WithEventView(name string) NotificationOption

WithEventView задаёт текст отображения события

func WithProgress

func WithProgress(isProgress bool) NotificationOption

WithProgress указывает, что событие является прогрессом.

func WithProgressDoneText

func WithProgressDoneText(text string) NotificationOption

WithProgressDoneText задаёт текст в конце прогресса.

func WithProgressPercent

func WithProgressPercent(percent float64) NotificationOption

WithProgressPercent задаёт процент выполнения.

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

Reporter инкапсулирует доставку ответов и событий приложения.

func NewReporter

func NewReporter(appConfig *app.Config) *Reporter

NewReporter создаёт Reporter поверх appConfig.

func (*Reporter) CliResponse

func (r *Reporter) CliResponse(ctx context.Context, resp APIResponse) error

CliResponse рендерит APIResponse в выбранном формате (text/json/dbus/http).

func (*Reporter) CreateEventNotification

func (r *Reporter) CreateEventNotification(ctx context.Context, state string, opts ...NotificationOption)

CreateEventNotification создаёт EventData и отправляет через dispatchEvent.

func (*Reporter) SendTaskResult

func (r *Reporter) SendTaskResult(ctx context.Context, taskName string, data interface{}, taskErr error)

SendTaskResult отправляет результат фоновой задачи через DBus или WebSocket.

type TaskResultEvent

type TaskResultEvent struct {
	Type        string      `json:"type"`
	Name        string      `json:"name"`
	Transaction string      `json:"transaction,omitempty"`
	Data        interface{} `json:"data"`
	Error       *APIError   `json:"error"`
}

TaskResultEvent содержит результат фоновой задачи

type WebSocketBroadcaster

type WebSocketBroadcaster interface {
	BroadcastEvent(event interface{})
}

WebSocketBroadcaster интерфейс для отправки событий через WebSocket

Jump to

Keyboard shortcuts

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