carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package activator
2
3import (
4 "context"
5 "fmt"
6 "os"
7 "os/exec"
8
9 "github.com/carlosframework/platform/internal/cgroup"
10 "github.com/carlosframework/platform/internal/hostbox"
11 "github.com/carlosframework/platform/internal/hostguard"
12 "github.com/carlosframework/platform/internal/hostwrite"
13)
14
15// ErrClaimIsolationUnavailable blocks every current launch shape until the
16// root instance-control protocol can validate a durable role reservation.
17var ErrClaimIsolationUnavailable = fmt.Errorf("%w: isolated root launcher cannot carry claim reservations", hostbox.ErrUnsupported)
18
19type RoleProducer struct {
20 Context context.Context
21 Finish func(error)
22}
23
24// RootRoleLauncher is the agent's client of the reservation-bearing
25// isolated root launch protocol (claim Plan 11, R10). Root, not the agent,
26// executes the role, in main's isolated instance unit.
27type RootRoleLauncher interface {
28 Capability(context.Context) (string, error)
29 Launch(context.Context, hostbox.RoleLaunchRequest) (hostbox.RoleLaunchGrant, error)
30 Stop(context.Context, hostbox.RoleLaunchRequest) error
31}
32
33type RoleLaunch struct {
34 Unit *hostbox.UnitLaunchInputs
35 Spec *hostbox.LaunchSpec
36 // Root carries a reservation to root's isolated launcher. Nil keeps
37 // every claimed launch refused.
38 Root RootRoleLauncher
39 // LaunchDir is the instance directory the isolated unit binds and runs
40 // in; RunDir holds the app socket; LogSocket is the unit's stdout
41 // socket; MemoryMax is the host slice tier.
42 LaunchDir, RunDir, LogSocket string
43 MemoryMax int64
44 RegisterProducer func(context.Context, string) (RoleProducer, error)
45 Initialize func(context.Context) error
46 InitializeUnlocked func(context.Context) error
47 Parent *cgroup.Prepared
48 ParentPath string
49 CgroupRoot string
50 Target hostguard.FenceTarget
51 Work hostwrite.Work
52 Identity hostwrite.Identity
53 Journal *hostbox.LaunchJournal
54 Executable func(context.Context, *exec.Cmd) (*os.File, error)
55}
56