service

package
v0.1.0-dev.20260223223859 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package service provides platform-agnostic service management actions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(reg *op.ActionRegistry)

Register registers all service actions with the given registry.

Types

type Disable

type Disable struct{ Impl *Provider }

Disable — Disable disables a service from starting at boot. Returns compensation state with pre-action enabled status.

func (*Disable) Do

func (o *Disable) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Disable) Name

func (o *Disable) Name() string

func (*Disable) Undo

func (o *Disable) Undo(ctx *op.Context, state op.UndoState) error

type Enable

type Enable struct{ Impl *Provider }

Enable — Enable enables a service to start at boot. Returns compensation state with pre-action enabled status.

func (*Enable) Do

func (o *Enable) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Enable) Name

func (o *Enable) Name() string

func (*Enable) Undo

func (o *Enable) Undo(ctx *op.Context, state op.UndoState) error

type Enabled

type Enabled struct{ Impl *Provider }

Enabled — Enabled returns true if the named service is enabled to start at boot.

func (*Enabled) Do

func (o *Enabled) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Enabled) Name

func (o *Enabled) Name() string

type Exists

type Exists struct{ Impl *Provider }

Exists — Exists returns true if the named service exists on the system.

func (*Exists) Do

func (o *Exists) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Exists) Name

func (o *Exists) Name() string

type Provider

type Provider struct{}

Provider provides platform-agnostic service management. All platform-specific behavior is delegated to the ServiceManagerProvider injected via op.Context.Host.

Compensable Forward methods return (string, map[string]any, error): the service name, the compensation receipt, and an error. The map is opaque to the executor, meaningful only to the corresponding Compensate* Backward method.

func (*Provider) CompensateDisable

func (p *Provider) CompensateDisable(svc op.ServiceManagerProvider, state any) error

CompensateDisable undoes a Disable by enabling the service if it was enabled before.

func (*Provider) CompensateEnable

func (p *Provider) CompensateEnable(svc op.ServiceManagerProvider, state any) error

CompensateEnable undoes an Enable by disabling the service if it wasn't enabled before.

func (*Provider) CompensateRestart

func (p *Provider) CompensateRestart(_ any) error

CompensateRestart is a no-op. A restarted service was already running; the service is still running after restart — nothing to undo.

func (*Provider) CompensateStart

func (p *Provider) CompensateStart(svc op.ServiceManagerProvider, state any) error

CompensateStart undoes a Start by stopping the service if it wasn't running before.

func (*Provider) CompensateStop

func (p *Provider) CompensateStop(svc op.ServiceManagerProvider, state any) error

CompensateStop undoes a Stop by starting the service if it was running before.

func (*Provider) Disable

func (p *Provider) Disable(svc op.ServiceManagerProvider, name string, output io.Writer) (result string, state map[string]any, retErr error)

Disable disables a service from starting at boot. Returns compensation state with pre-action enabled status.

Parameters:

  • name: Service name (e.g., launchd label, systemd unit, Windows service)

+devlore:access=planned

func (*Provider) Enable

func (p *Provider) Enable(svc op.ServiceManagerProvider, name string, output io.Writer) (result string, state map[string]any, retErr error)

Enable enables a service to start at boot. Returns compensation state with pre-action enabled status.

Parameters:

  • name: Service name (e.g., launchd label, systemd unit, Windows service)

+devlore:access=planned

func (*Provider) Enabled

func (p *Provider) Enabled(svc op.ServiceManagerProvider, name string) (bool, error)

Enabled returns true if the named service is enabled to start at boot.

Parameters:

  • name: Service name to check

+devlore:access=both

func (*Provider) Exists

func (p *Provider) Exists(svc op.ServiceManagerProvider, name string) (bool, error)

Exists returns true if the named service exists on the system.

Parameters:

  • name: Service name to check

+devlore:access=both

func (*Provider) Restart

func (p *Provider) Restart(svc op.ServiceManagerProvider, name string, output io.Writer) (result string, state map[string]any, retErr error)

Restart restarts a service. Returns compensation state. Compensation is a no-op — if the service was restarted, it was already running.

Parameters:

  • name: Service name (e.g., launchd label, systemd unit, Windows service)

+devlore:access=planned

func (*Provider) Running

func (p *Provider) Running(svc op.ServiceManagerProvider, name string) (bool, error)

Running returns true if the named service is currently running.

Parameters:

  • name: Service name to check

+devlore:access=both

func (*Provider) Start

func (p *Provider) Start(svc op.ServiceManagerProvider, name string, output io.Writer) (result string, state map[string]any, retErr error)

Start starts a service. Returns compensation state with pre-action running status.

Parameters:

  • name: Service name (e.g., launchd label, systemd unit, Windows service)

+devlore:access=planned

func (*Provider) Stop

func (p *Provider) Stop(svc op.ServiceManagerProvider, name string, output io.Writer) (result string, state map[string]any, retErr error)

Stop stops a service. Returns compensation state with pre-action running status.

Parameters:

  • name: Service name (e.g., launchd label, systemd unit, Windows service)

+devlore:access=planned

type Restart

type Restart struct{ Impl *Provider }

Restart — Restart restarts a service. Returns compensation state. Compensation is a no-op — if the service was restarted, it was already running.

func (*Restart) Do

func (o *Restart) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Restart) Name

func (o *Restart) Name() string

func (*Restart) Undo

func (o *Restart) Undo(_ *op.Context, state op.UndoState) error

type Running

type Running struct{ Impl *Provider }

Running — Running returns true if the named service is currently running.

func (*Running) Do

func (o *Running) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Running) Name

func (o *Running) Name() string

type Start

type Start struct{ Impl *Provider }

Start — Start starts a service. Returns compensation state with pre-action running status.

func (*Start) Do

func (o *Start) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Start) Name

func (o *Start) Name() string

func (*Start) Undo

func (o *Start) Undo(ctx *op.Context, state op.UndoState) error

type Stop

type Stop struct{ Impl *Provider }

Stop — Stop stops a service. Returns compensation state with pre-action running status.

func (*Stop) Do

func (o *Stop) Do(ctx *op.Context, slots map[string]any) (op.Result, op.UndoState, error)

func (*Stop) Name

func (o *Stop) Name() string

func (*Stop) Undo

func (o *Stop) Undo(ctx *op.Context, state op.UndoState) error

Jump to

Keyboard shortcuts

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