service

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 35 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultPipeName = "sofcat-service"

Variables

This section is empty.

Functions

func IsErrorCode

func IsErrorCode(err error, appCode string) bool

IsErrorCode reports whether err is a service error with data.code appCode.

func IsTerminalOperationState

func IsTerminalOperationState(state string) bool

func RunAction

func RunAction(_ config.Configuration, _ string) error

func ServiceStatus

func ServiceStatus(_ config.Configuration) (string, error)

Types

type AcceptedOperation

type AcceptedOperation struct {
	OperationID string `json:"operationId,omitempty"`
	Accepted    bool   `json:"accepted"`
	QueuedAtUTC string `json:"queuedAtUtc"`
	// RequestedBy is the user who called, as the service resolved it from the
	// connection: DOMAIN\user on Windows, "" when unresolved.
	RequestedBy string `json:"requestedBy"`
}

type Client

type Client struct {
	PipeName        string
	ConnectTimeout  time.Duration
	ResponseTimeout time.Duration
}

Client is the typed SofCat service client shared by command-line and UI callers. Timeouts default to five seconds for connecting and 30 seconds for ordinary responses and stream acknowledgements.

func NewClient

func NewClient(pipeName string) *Client

func (*Client) CancelOperation

func (c *Client) CancelOperation(ctx context.Context, operationID string) error

CancelOperation asks the service to cancel operationID. The service refuses with operation_not_cancelable once the item's install or removal has started, the operation has finished, or the operation is unknown.

func (*Client) GetBranding

func (c *Client) GetBranding(ctx context.Context) (branding.Branding, error)

GetBranding returns the organisation branding the service resolved from policy and config. Unset fields are empty strings.

func (*Client) GetServiceInfo

func (c *Client) GetServiceInfo(ctx context.Context) (ServiceInfo, error)

GetServiceInfo returns the service's version, protocol and capabilities, and whether a managed run is under way.

func (*Client) InstallItem

func (c *Client) InstallItem(ctx context.Context, itemName string) (AcceptedOperation, error)

func (*Client) ListOptionalInstalls

func (c *Client) ListOptionalInstalls(ctx context.Context) ([]OptionalInstallItem, error)

func (*Client) RemoveItem

func (c *Client) RemoveItem(ctx context.Context, itemName string) (AcceptedOperation, error)

func (*Client) StreamOperationStatus

func (c *Client) StreamOperationStatus(ctx context.Context, operationID string, callback func(OperationStatus) error) error

StreamOperationStatus calls callback with each of operationID's status records, from the first, until the terminal one.

type Command

type Command struct {
	Action string   `json:"action"`
	Items  []string `json:"items,omitempty"`
	// contains filtered or unexported fields
}

type CommandResponse

type CommandResponse struct {
	Status        string                `json:"status"`
	Message       string                `json:"message,omitempty"`
	Items         []string              `json:"items,omitempty"`
	OptionalItems []OptionalInstallItem `json:"optionalItems,omitempty"`
	OperationID   string                `json:"operationId,omitempty"`
	RequestedBy   string                `json:"requestedBy,omitempty"`
	Branding      *branding.Branding    `json:"branding,omitempty"`
	// contains filtered or unexported fields
}

func SendCommand

func SendCommand(cfg config.Configuration, spec string) (CommandResponse, error)

type Error

type Error struct {
	Code    int       `json:"code"`
	Message string    `json:"message"`
	Data    ErrorData `json:"data"`
}

Error is a JSON-RPC error object from the service. Data.Code is the stable application code (operation_not_cancelable, server_busy, ...).

func (*Error) Error

func (e *Error) Error() string

Error reads "<data.code>: <message>", the form the CLI prints and the UI strips the code from.

type ErrorData

type ErrorData struct {
	Code        string `json:"code"`
	OperationID string `json:"operationId,omitempty"`
}

type OperationStatus

type OperationStatus struct {
	OperationID     string `json:"operationId"`
	Seq             int    `json:"seq"`
	TimestampUTC    string `json:"timestampUtc"`
	ItemName        string `json:"itemName"`
	DisplayName     string `json:"displayName"`
	State           string `json:"state"`
	ProgressPercent int    `json:"progressPercent"`
	Message         string `json:"message"`
	ErrorCode       string `json:"errorCode,omitempty"`
	ErrorMessage    string `json:"errorMessage,omitempty"`
	CanceledBy      string `json:"canceledBy,omitempty"`
	RequestedBy     string `json:"requestedBy"`
}

OperationStatus is one status record, the params of an operationStatus notification. Seq numbers an operation's records from 1 in the order the service recorded them, so a client can order records that arrive out of order. RequestedBy is the user whose request started the operation, "" when the service could not resolve it. ProgressPercent is scoped to ItemName and may reset when the item changes; it is not aggregate operation progress. Only Succeeded, Failed, Deferred, and Canceled end an operation.

type OptionalInstallItem

type OptionalInstallItem struct {
	ItemName           string `json:"itemName"`
	DisplayName        string `json:"displayName"`
	Version            string `json:"version"`
	Catalog            string `json:"catalog"`
	Description        string `json:"description,omitempty"`
	Category           string `json:"category,omitempty"`
	Developer          string `json:"developer,omitempty"`
	IconName           string `json:"iconName,omitempty"`
	RestartAction      string `json:"restartAction,omitempty"`
	IsManaged          bool   `json:"isManaged"`
	IsRequired         bool   `json:"isRequired"`
	IsInstalled        bool   `json:"isInstalled"`
	Status             string `json:"status"`
	StatusUpdatedAtUTC string `json:"statusUpdatedAtUtc"`
	LastOperationID    string `json:"lastOperationId,omitempty"`
}

OptionalInstallItem is one offered self-service item. IsRequired is whether an admin manifest also lists it in managed_installs: it is installed for everyone and cannot be removed through self-service.

type ServiceInfo

type ServiceInfo struct {
	Version         string   `json:"version"`
	ProtocolVersion string   `json:"protocolVersion"`
	APIVersion      int      `json:"apiVersion"`
	Capabilities    []string `json:"capabilities"`
	Busy            bool     `json:"busy"`
	UptimeSeconds   int64    `json:"uptimeSeconds"`
}

ServiceInfo is getServiceInfo's result. It skips the command queue, so it doubles as a cheap health check.

Jump to

Keyboard shortcuts

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