installed

package
v0.1.0-rc.45 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 66 Imported by: 0 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

Overview

package installed owns installed publisher and connector job definitions, operating-system service setup, reconciliation, supervision, and joined stop. it composes publisher operations and caller-supplied connector operations.

this is a process composition owner, not a shared client facility. auth, state, project, and control clients remain below it in client and must not import it. deployment job runners compose deployment-owned assignment publication; foreground callers can use that publisher operation without an installed job or registry.

package publisherjob owns installed publications and their private state.

Index

Constants

View Source
const ServiceLabel = "dev.tnl.publisher"
View Source
const SystemdUnit = "tnl-publisher.service"
View Source
const UserServiceLabel = "dev.tnl.service"
View Source
const UserSystemdUnit = "tnl.service"

Variables

View Source
var (
	ErrUnsafeState  = failure.Wrap("open installed publisher state", failure.ClientStateUnavailable, errors.New("installed publisher state is unsafe or has changed"))
	ErrScope        = target.ErrScope
	ErrJobExists    = failure.Wrap("install publication", failure.ServerConflict, errors.New("saved publication is already installed"))
	ErrJobNotFound  = failure.Wrap("read installed publication", failure.ServerResourceNotFound, errors.New("installed publisher job does not exist"))
	ErrJobAmbiguous = failure.Wrap("select installed publication", failure.InstalledJobAmbiguous, errors.New("more than one installed job has this name"))
)
View Source
var ErrServiceNotLoaded = errors.New("tnl service is not loaded")

Functions

func CheckActiveService

func CheckActiveService(ctx context.Context, options ServiceOptions, executor Executor) error

CheckActiveService also checks that the already installed service is running. registration must not succeed when there is no supervisor to pick up jobs.

func CheckService

func CheckService(ctx context.Context, options ServiceOptions, executor Executor) error

CheckService is read-only: in particular, it cannot initialize registry state or redeem an enrollment key when the requested supervisor is absent.

func DefaultRoot

func DefaultRoot(platform string) string

func DefaultUserRoot

func DefaultUserRoot(platform string) (string, error)

func DeploymentClient

func DeploymentClient(job Job) (*publisherdeployment.Client, error)

DeploymentClient uses the same selected control trust as native service clients. deployment HTTPS and discovered target TLS remain independent trust boundaries.

func InstallService

func InstallService(ctx context.Context, options ServiceOptions, executor Executor) error

InstallService atomically refreshes the running binary before restarting the system service. executor injection keeps tests away from the host manager.

func JobKey

func JobKey(server, kind, resourceID string) string

JobKey separates publisher, connector, and deployment jobs on the same server.

func ServiceJobKey

func ServiceJobKey(server, serviceID string) string

func ServiceUnit

func ServiceUnit(platform, binary, root string) ([]byte, error)

ServiceUnit contains only the stable binary and private state directory. system services run at boot with no login session or secret command arguments.

func StartService

func StartService(ctx context.Context, options ServiceOptions, executor Executor) error

func ValidateTrust

func ValidateTrust(pem []byte) error

ValidateTrust checks a copied CA snapshot before one-use enrollment starts.

func VerifyServiceReadiness

func VerifyServiceReadiness(ctx context.Context, run httpaccess.ReadinessRun, path string, proof *httpaccess.ReadinessProof) error

VerifyServiceReadiness requires both a successful public response and local consumption of this exact service run's one-use proof. it sends no user session.

func WithCertificateState

func WithCertificateState(ctx context.Context, job Job, profile *clientstate.Store, private ed25519.PrivateKey, client *publisherdeployment.Client, serve func(context.Context) error) error

WithCertificateState holds the durable replica writer lock across setup and serving. control's issuance history forbids silently replacing lost TLS keys.

Types

type AWSBinding

type AWSBinding struct {
	CredentialsFile string `json:"credentials_file"`
	RoleARN         string `json:"role_arn,omitempty"`
	RoleRegion      string `json:"role_region,omitempty"`
}

type Command

type Command struct {
	Program string
	Args    []string
}

type DeploymentBinding

type DeploymentBinding struct {
	Version     int                                  `json:"version"`
	Scope       DeploymentScope                      `json:"identity"`
	ServerCAPEM string                               `json:"server_ca_pem,omitempty"`
	Discovery   []DiscoveryBinding                   `json:"discovery,omitempty"`
	AWS         *AWSBinding                          `json:"aws,omitempty"`
	Deployment  *controlv1.PublisherDeploymentReport `json:"deployment,omitempty"`
}

func ReadDeploymentBinding

func ReadDeploymentBinding(path string) (DeploymentBinding, error)

ReadDeploymentBinding accepts bounded, private operator input. identity documents remain identity-only; this file contains local permissions and source paths.

func (DeploymentBinding) GoString

func (DeploymentBinding) GoString() string

func (DeploymentBinding) String

func (DeploymentBinding) String() string

func (DeploymentBinding) Validate

func (b DeploymentBinding) Validate() error

type DeploymentInstall

type DeploymentInstall struct {
	Job     Job
	Private ed25519.PrivateKey
}

func (DeploymentInstall) GoString

func (DeploymentInstall) GoString() string

func (DeploymentInstall) String

func (DeploymentInstall) String() string

type DeploymentRunner

type DeploymentRunner struct {
	Telemetry *clienttelemetry.Collector

	Discovery  publisherdiscovery.Provider
	Deployment *controlv1.PublisherDeploymentReport
	// Startup bounds finite setup only, never a deployment's lease lifetime.
	Startup          *OperationLimiter
	ShutdownDeadline func() time.Time
	ShutdownContext  context.Context
	// contains filtered or unexported fields
}

DeploymentRunner assembles the same deployment lifecycle for foreground and supervised jobs. dependencies are explicit; nil discovery providers are rejected rather than selecting process credentials. providers must honor cancellation.

func ScopedDeploymentRunner

func ScopedDeploymentRunner(value credentialfile.DeploymentFile, binding *DeploymentBinding, startup, providers *OperationLimiter) (DeploymentRunner, []byte, error)

ScopedDeploymentRunner snapshots discovery permissions before workers start. AWS credentials refresh only from the selected private file; the SDK default config loader and process AWS environment are never consulted.

func (DeploymentRunner) Serve

func (r DeploymentRunner) Serve(ctx context.Context, job Job, profile *clientstate.Store, private ed25519.PrivateKey, observe func(int64, bool) error) (result error)

type DeploymentScope

type DeploymentScope struct {
	Server     string `json:"control_url"`
	Team       string `json:"team_id"`
	Deployment string `json:"deployment_id"`
	Publisher  string `json:"publisher_identity_id"`
}

DeploymentScope binds operator-owned dependencies to immutable authority, never to a friendly deployment/project name or a credential file's location.

func ScopeForDeployment

func ScopeForDeployment(value credentialfile.DeploymentFile) DeploymentScope

type DiscoveryBinding

type DiscoveryBinding struct {
	Type     string `json:"type"`
	Region   string `json:"region"`
	Cluster  string `json:"cluster,omitempty"`
	Instance string `json:"instance,omitempty"`
	Endpoint string `json:"endpoint,omitempty"`
	Protocol string `json:"protocol"`
	Account  string `json:"account,omitempty"`
}

type Engine

type Engine struct {
	Telemetry *clienttelemetry.Collector
	Registry  *Registry
	// UserJobs lets the user-login supervisor host another job kind with its
	// own registry and credentials. the system publisher service leaves it empty.
	UserJobs   []UserJobRunner
	Clients    ClientFactory
	Connect    func(context.Context, Job, *clienttelemetry.Collector, func() error, func() time.Time, context.Context) error
	Deployment func(context.Context, Job, *clienttelemetry.Collector, func(int64, bool) error, func() time.Time, context.Context) error
	Observe    func(Job, Status) error
	// Initialize runs local desired-state setup while holding service.lock,
	// before any worker starts. it must not contact remote services.
	Initialize       func(context.Context) error
	PollInterval     time.Duration
	RetryMin         time.Duration
	RetryMax         time.Duration
	DrainTime        time.Duration
	ShutdownDeadline func() time.Time
	// shutdown context is an expiry fence, not the canceled work context.
	// descendants inherit it before stopping so an earlier parent expiry can
	// interrupt already-active cleanup without another deadline getter call.
	ShutdownContext context.Context
}

func (Engine) Serve

func (e Engine) Serve(ctx context.Context) (result error)

Serve runs every enabled job after boot. failures and drain waits belong to individual workers; the reconciler never waits on a target or control server. callers must keep Registry open until Serve returns, including its drain join.

type Executor

type Executor interface {
	Execute(context.Context, Command) error
}

type ExecutorFunc

type ExecutorFunc func(context.Context, Command) error

func (ExecutorFunc) Execute

func (f ExecutorFunc) Execute(ctx context.Context, command Command) error

type HostExecutor

type HostExecutor struct{}

HostExecutor never captures or forwards external command output into logs.

func (HostExecutor) Execute

func (HostExecutor) Execute(ctx context.Context, command Command) error

type Job

type Job struct {
	TelemetryDisabled   bool                                   `json:"telemetry_disabled,omitempty"`
	PreferredRegions    []string                               `json:"preferred_regions,omitempty"`
	DeploymentMember    *controlv1.DeploymentPublisherIdentity `json:"deployment_member,omitempty"`
	DeploymentInstance  string                                 `json:"deployment_instance,omitempty"`
	IdentityDir         string                                 `json:"identity_dir,omitempty"`
	Kind                Kind                                   `json:"kind,omitempty"`
	ServiceID           string                                 `json:"service_id,omitempty"`
	TrustRevision       int64                                  `json:"trust_revision,omitempty"`
	PublisherPool       bool                                   `json:"publisher_pool,omitempty"`
	IdentityID          string                                 `json:"identity_id,omitempty"`
	StateDir            string                                 `json:"state_dir,omitempty"`
	Project             *clientproject.Project                 `json:"project,omitempty"`
	ProjectService      string                                 `json:"project_service,omitempty"`
	Trust               *targettrust.Snapshot                  `json:"trust,omitempty"`
	Endpoint            *controlv1.ServiceEndpoint             `json:"endpoint,omitempty"`
	ID                  string                                 `json:"job_id"`
	Name                string                                 `json:"name,omitempty"`
	Server              string                                 `json:"server"`
	PublisherIdentityID string                                 `json:"publisher_identity_id"`
	GrantID             string                                 `json:"grant_id"`
	Target              string                                 `json:"target"`
	Protocol            config.ProtocolName                    `json:"protocol"`
	ReadinessPath       string                                 `json:"readiness_path,omitempty"`
	// target trust is captured in Trust; control-server roots are independent.
	ServerCAPEM    []byte                   `json:"server_ca_pem,omitempty"`
	StreamCapacity int32                    `json:"stream_capacity,omitempty"`
	Traffic        *trafficlimits.Selection `json:"traffic,omitempty"`
	Enabled        bool                     `json:"enabled"`
	Revision       uint64                   `json:"revision"`
	Status         Status                   `json:"status"`
}

func (Job) GoString

func (j Job) GoString() string

func (Job) String

func (j Job) String() string

String keeps private key material out of incidental diagnostic formatting.

func (Job) TargetPlan

func (j Job) TargetPlan() target.TargetPlan

type JobState

type JobState string

JobState is a finite local observation, independent of desired Enabled state.

const (
	JobUnobserved        JobState = ""
	JobStarting          JobState = "starting"
	JobStopping          JobState = "stopping"
	JobStopped           JobState = "stopped"
	JobProvisioning      JobState = "provisioning"
	JobReconciling       JobState = "reconciling"
	JobReady             JobState = "ready"
	JobDraining          JobState = "draining"
	JobRetrying          JobState = "retrying"
	JobBlocked           JobState = "blocked"
	JobTargetUnavailable JobState = "target unavailable"
)

func (JobState) Valid

func (s JobState) Valid() bool

type Kind

type Kind string
const (
	KindService    Kind = "service"
	KindConnector  Kind = "connector"
	KindDeployment Kind = "deployment"
)

type OpenOptions

type OpenOptions struct {
	Root string
	User bool
	// StandaloneDeployments permits identity-only deployment jobs under the current uid,
	// independently of user-session connector support.
	StandaloneDeployments bool
	// tests must explicitly select their uid for isolated system state.
	TestOwnerUID *int
}

type OperationLimiter

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

OperationLimiter bounds finite startup/provider operations. waiting callers queue in arrival order; cancellation removes a waiter without consuming a slot.

func NewOperationLimiter

func NewOperationLimiter(capacity int) *OperationLimiter

func (*OperationLimiter) Acquire

func (l *OperationLimiter) Acquire(ctx context.Context) (func(), error)

type PublisherClients

type PublisherClients struct {
	publisheridentity.NativeControl
	Discovery publisherdeployment.ServerDiscovery
}

func Clients

Clients creates isolated HTTP transports for one server's trust configuration. relay trust stays WebPKI, as required by the relay transport boundary.

type Registry

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

func Open

func Open(ctx context.Context, options OpenOptions) (*Registry, error)

Open uses a standalone database and file wrapping key, including on macOS.

func (*Registry) Close

func (r *Registry) Close() error

func (*Registry) Credential

func (r *Registry) Credential(ctx context.Context, job Job) (credentialfile.File, error)

Credential exports only an installed job's exact scoped signing identity for a private installer handoff. control sessions are outside this representation.

func (*Registry) Install

func (r *Registry) Install(ctx context.Context, job Job, identity authorityv1.PublisherEnrollmentResult, private ed25519.PrivateKey) error

Install binds a key to this job, server, and exact grant. a failed registry write can leave an unused encrypted key, but cannot publish a partial job.

func (*Registry) InstallConnector

func (r *Registry) InstallConnector(ctx context.Context, job Job) error

InstallConnector stores user desired state only. credentials remain in the signed-in profile, and the worker checks the exact identity at every start.

func (*Registry) InstallDeployment

func (r *Registry) InstallDeployment(ctx context.Context, job Job, member controlv1.DeploymentPublisherIdentity, private ed25519.PrivateKey) error

InstallDeployment captures the task's own signing identity. no person session or project checkout is required by the supervisor after installation.

func (*Registry) List

func (r *Registry) List(ctx context.Context) (jobs []Job, err error)

func (*Registry) Profile

func (r *Registry) Profile(ctx context.Context, server string) (*clientstate.Store, error)

Profile lets enrollment save its key before redeeming a one-use secret.

func (*Registry) Remove

func (r *Registry) Remove(ctx context.Context, id string) error

Remove drops local desired state and its job-scoped signing identity after the caller has stopped and joined the worker.

func (*Registry) ReplaceDeployments

func (r *Registry) ReplaceDeployments(ctx context.Context, inputs []DeploymentInstall) error

ReplaceDeployments installs the fixed startup list as one desired-state snapshot. it is available only to an identity-only standalone registry. an omitted job cannot accidentally resume from a previous invocation's list.

func (*Registry) ResolveJob

func (r *Registry) ResolveJob(ctx context.Context, selected string) (Job, error)

ResolveJob requires an unambiguous ID or display name across all installed projects in this supervisor. no job changes before this selection succeeds.

func (*Registry) Root

func (r *Registry) Root() string

func (*Registry) Start

func (r *Registry) Start(ctx context.Context, id string) error

func (*Registry) Stop

func (r *Registry) Stop(ctx context.Context, id string) error

Stop changes only local desired state. it never revokes a server grant.

func (*Registry) WaitStopped

func (r *Registry) WaitStopped(ctx context.Context, id string) error

WaitStopped waits for the service's joined worker observation after Stop.

type ServiceOptions

type ServiceOptions struct {
	Platform     string
	Root         string
	User         bool
	BinarySource string
	// unit directory and owner overrides exist for isolated service tests.
	TestUnitDir  string
	TestOwnerUID *int
}

type Status

type Status struct {
	Address          string   `json:"address,omitempty"`
	ObservedRevision int64    `json:"observed_revision,omitempty"`
	State            JobState `json:"state"`
	Failure          string   `json:"failure,omitempty"`
	Attempts         uint64   `json:"attempts,omitempty"`
	RunNumber        uint64   `json:"run_number,omitempty"`
}

status contains approved observations only; errors and tokens never enter it.

type UserJobRunner

type UserJobRunner interface {
	Serve(context.Context, func() time.Time, context.Context) error
}

UserJobRunner owns its own registry and reconciliation. Serve joins its workers before returning when the shared user-login context is canceled.

Jump to

Keyboard shortcuts

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