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
- Variables
- func CheckActiveService(ctx context.Context, options ServiceOptions, executor Executor) error
- func CheckService(ctx context.Context, options ServiceOptions, executor Executor) error
- func DefaultRoot(platform string) string
- func DefaultUserRoot(platform string) (string, error)
- func DeploymentClient(job Job) (*publisherdeployment.Client, error)
- func InstallService(ctx context.Context, options ServiceOptions, executor Executor) error
- func JobKey(server, kind, resourceID string) string
- func ServiceJobKey(server, serviceID string) string
- func ServiceUnit(platform, binary, root string) ([]byte, error)
- func StartService(ctx context.Context, options ServiceOptions, executor Executor) error
- func ValidateTrust(pem []byte) error
- func VerifyServiceReadiness(ctx context.Context, run httpaccess.ReadinessRun, path string, ...) error
- func WithCertificateState(ctx context.Context, job Job, profile *clientstate.Store, ...) error
- type AWSBinding
- type ClientFactory
- type Command
- type DeploymentBinding
- type DeploymentInstall
- type DeploymentRunner
- type DeploymentScope
- type DiscoveryBinding
- type Engine
- type Executor
- type ExecutorFunc
- type HostExecutor
- type Job
- type JobState
- type Kind
- type OpenOptions
- type OperationLimiter
- type PublisherClients
- type Registry
- func (r *Registry) Close() error
- func (r *Registry) Credential(ctx context.Context, job Job) (credentialfile.File, error)
- func (r *Registry) DeploymentIdentity(ctx context.Context, job Job) (controlv1.DeploymentPublisherIdentity, ed25519.PrivateKey, *clientstate.Store, ...)
- func (r *Registry) Install(ctx context.Context, job Job, identity authorityv1.PublisherEnrollmentResult, ...) error
- func (r *Registry) InstallConnector(ctx context.Context, job Job) error
- func (r *Registry) InstallDeployment(ctx context.Context, job Job, member controlv1.DeploymentPublisherIdentity, ...) error
- func (r *Registry) List(ctx context.Context) (jobs []Job, err error)
- func (r *Registry) Profile(ctx context.Context, server string) (*clientstate.Store, error)
- func (r *Registry) Remove(ctx context.Context, id string) error
- func (r *Registry) ReplaceDeployments(ctx context.Context, inputs []DeploymentInstall) error
- func (r *Registry) ResolveJob(ctx context.Context, selected string) (Job, error)
- func (r *Registry) Root() string
- func (r *Registry) Start(ctx context.Context, id string) error
- func (r *Registry) Stop(ctx context.Context, id string) error
- func (r *Registry) WaitStopped(ctx context.Context, id string) error
- type ServiceOptions
- type Status
- type UserJobRunner
Constants ¶
const ServiceLabel = "dev.tnl.publisher"
const SystemdUnit = "tnl-publisher.service"
const UserServiceLabel = "dev.tnl.service"
const UserSystemdUnit = "tnl.service"
Variables ¶
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")) )
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 DefaultUserRoot ¶
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 ServiceJobKey ¶
func ServiceUnit ¶
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 ¶
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 ClientFactory ¶
type ClientFactory func(Job) (PublisherClients, publisheridentity.EnrollmentAuthority, error)
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 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
}
type ExecutorFunc ¶
type HostExecutor ¶
type HostExecutor struct{}
HostExecutor never captures or forwards external command output into logs.
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) 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" )
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
type PublisherClients ¶
type PublisherClients struct {
publisheridentity.NativeControl
Discovery publisherdeployment.ServerDiscovery
}
func Clients ¶
func Clients(job Job) (PublisherClients, publisheridentity.EnrollmentAuthority, error)
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) Credential ¶
Credential exports only an installed job's exact scoped signing identity for a private installer handoff. control sessions are outside this representation.
func (*Registry) DeploymentIdentity ¶
func (r *Registry) DeploymentIdentity(ctx context.Context, job Job) (controlv1.DeploymentPublisherIdentity, ed25519.PrivateKey, *clientstate.Store, error)
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 ¶
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) Remove ¶
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 ¶
ResolveJob requires an unambiguous ID or display name across all installed projects in this supervisor. no job changes before this selection succeeds.
type ServiceOptions ¶
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.