Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeMessage(p []byte, ptr any) error
- func EncodeMessage(msg Message) ([]byte, error)
- func MustEncodeMessage(msg Message) []byte
- func RegisterTypesInGob()
- func RestrictProcessAccess(ctx *core.Context, config ProcessRestrictionConfig)
- type AckMsg
- type AllStoppedEvent
- type ControlClient
- type ControlServer
- type ControlServerConfig
- type ControlledProcess
- type ControlledProcessToken
- type ExternalFilesystem
- func (fls *ExternalFilesystem) Absolute(path string) (string, error)
- func (*ExternalFilesystem) Chroot(path string) (billy.Filesystem, error)
- func (*ExternalFilesystem) Create(filename string) (billy.File, error)
- func (*ExternalFilesystem) Join(elem ...string) string
- func (*ExternalFilesystem) Lstat(filename string) (fs.FileInfo, error)
- func (*ExternalFilesystem) MkdirAll(filename string, perm fs.FileMode) error
- func (*ExternalFilesystem) Open(filename string) (billy.File, error)
- func (*ExternalFilesystem) OpenFile(filename string, flag int, perm fs.FileMode) (billy.File, error)
- func (*ExternalFilesystem) ReadDir(path string) ([]fs.FileInfo, error)
- func (*ExternalFilesystem) Readlink(link string) (string, error)
- func (*ExternalFilesystem) Remove(filename string) error
- func (*ExternalFilesystem) Rename(oldpath string, newpath string) error
- func (*ExternalFilesystem) Root() string
- func (*ExternalFilesystem) Stat(filename string) (fs.FileInfo, error)
- func (*ExternalFilesystem) Symlink(target string, link string) error
- func (*ExternalFilesystem) TempFile(dir string, prefix string) (billy.File, error)
- type LaunchAppResponse
- type LaunchApplicationRequest
- type Message
- type ProcessRestrictionConfig
- type StopAllRequest
- type StopAllResponse
Constants ¶
const ( HEARTBEAT_INTERVAL = 100 * time.Millisecond MAX_RECONNECT_ATTEMPT_COUNT = 10 LOCAL_WS_HANDSHAKE_TIMEOUT = time.Second INIT_PROCESS_PID = 1 )
const ( CONTROL_SERVER_LOG_SRC = "control-server" PROCESS_TOKEN_HEADER = "Process-Token" PROCESS_TOKEN_BYTE_LENGTH = 32 CONTROLLED_SUBCMD = "controlled" //maximum time the control server will wait for the controlled process to connect. MAX_CONTROLLED_PROCESS_CONNECTION_WAITING_TIME = time.Second )
const (
GRACEFUL_CANCELLATION_TIMEOUT = 5 * time.Second
)
Variables ¶
var ( ErrControlLoopEnd = errors.New("control loop end") ErrTooManyReconnectAttempts = errors.New("too many reconnect attemps") ErrOrphanProcess = errors.New("orphan process") )
var ( PROCESS_TOKEN_ENCODED_BYTE_LENGTH = hex.EncodedLen(PROCESS_TOKEN_BYTE_LENGTH) ErrProcessDidNotConnect = errors.New("controlled process did not connect to the control server") ErrProcessAlreadyConnected = errors.New("controlled process is already connected to the control server") )
var (
ErrAlreadyExecuting = errors.New("already executing")
)
Functions ¶
func DecodeMessage ¶
func EncodeMessage ¶
func MustEncodeMessage ¶
func RegisterTypesInGob ¶
func RegisterTypesInGob()
func RestrictProcessAccess ¶
func RestrictProcessAccess(ctx *core.Context, config ProcessRestrictionConfig)
RestrictProcessAccess uses Landlock to restrict what files the process has access to. The function does nothing on non-Linux systems. Landlock: - https://landlock.io/ - https://www.man7.org/linux/man-pages/man7/landlock.7.html
Types ¶
type AllStoppedEvent ¶
type AllStoppedEvent struct { }
type ControlClient ¶
type ControlClient struct {
// contains filtered or unexported fields
}
func ConnectToProcessControlServer ¶
func ConnectToProcessControlServer(ctx *core.Context, u *url.URL, token ControlledProcessToken) (*ControlClient, error)
func (*ControlClient) Conn ¶
func (c *ControlClient) Conn() *ws_ns.WebsocketConnection
func (*ControlClient) StartControl ¶
func (c *ControlClient) StartControl() error
type ControlServer ¶
type ControlServer struct {
// contains filtered or unexported fields
}
A ControlServer creates and controls Inox processes, each created process connects to the control server with a WebSocket.
func NewControlServer ¶
func NewControlServer(ctx *core.Context, config ControlServerConfig) (*ControlServer, error)
NewControlServer creates a ControlServer, the Start method should be called to start it.
func (*ControlServer) CreateControlledProcess ¶
func (s *ControlServer) CreateControlledProcess(grantedPerms, forbiddenPerms []core.Permission) (*ControlledProcess, error)
CreateClientProcess create an Inox process that connects to the server.
func (*ControlServer) Start ¶
func (s *ControlServer) Start() error
Start starts the HTTP server, it returns when the server is closed.
type ControlServerConfig ¶
func (ControlServerConfig) Check ¶
func (c ControlServerConfig) Check() error
type ControlledProcess ¶
type ControlledProcess struct {
// contains filtered or unexported fields
}
A ControlledProcess is an Inox process controlled by the control server, it is not necessarily running on the same machine.
func (*ControlledProcess) Stop ¶
func (p *ControlledProcess) Stop(ctx *core.Context)
Stop gracefully stops the process or directly kills it, Stop does not wait for the process to exit.
type ControlledProcessToken ¶
type ControlledProcessToken string
func ControlledProcessTokenFrom ¶
func ControlledProcessTokenFrom(s string) (ControlledProcessToken, bool)
func MakeControlledProcessToken ¶
func MakeControlledProcessToken() ControlledProcessToken
type ExternalFilesystem ¶
type ExternalFilesystem struct {
// contains filtered or unexported fields
}
A ExternalFilesystem is a filesystem provided by another process.
func (*ExternalFilesystem) Absolute ¶
func (fls *ExternalFilesystem) Absolute(path string) (string, error)
func (*ExternalFilesystem) Chroot ¶
func (*ExternalFilesystem) Chroot(path string) (billy.Filesystem, error)
func (*ExternalFilesystem) Create ¶
func (*ExternalFilesystem) Create(filename string) (billy.File, error)
Create implements afs.Filesystem.
func (*ExternalFilesystem) Join ¶
func (*ExternalFilesystem) Join(elem ...string) string
Join implements afs.Filesystem.
func (*ExternalFilesystem) Lstat ¶
func (*ExternalFilesystem) Lstat(filename string) (fs.FileInfo, error)
Lstat implements afs.Filesystem.
func (*ExternalFilesystem) MkdirAll ¶
func (*ExternalFilesystem) MkdirAll(filename string, perm fs.FileMode) error
MkdirAll implements afs.Filesystem.
func (*ExternalFilesystem) Open ¶
func (*ExternalFilesystem) Open(filename string) (billy.File, error)
Open implements afs.Filesystem.
func (*ExternalFilesystem) OpenFile ¶
func (*ExternalFilesystem) OpenFile(filename string, flag int, perm fs.FileMode) (billy.File, error)
OpenFile implements afs.Filesystem.
func (*ExternalFilesystem) ReadDir ¶
func (*ExternalFilesystem) ReadDir(path string) ([]fs.FileInfo, error)
ReadDir implements afs.Filesystem.
func (*ExternalFilesystem) Readlink ¶
func (*ExternalFilesystem) Readlink(link string) (string, error)
Readlink implements afs.Filesystem.
func (*ExternalFilesystem) Remove ¶
func (*ExternalFilesystem) Remove(filename string) error
Remove implements afs.Filesystem.
func (*ExternalFilesystem) Rename ¶
func (*ExternalFilesystem) Rename(oldpath string, newpath string) error
Rename implements afs.Filesystem.
func (*ExternalFilesystem) Root ¶
func (*ExternalFilesystem) Root() string
Root implements afs.Filesystem.
func (*ExternalFilesystem) Stat ¶
func (*ExternalFilesystem) Stat(filename string) (fs.FileInfo, error)
Stat implements afs.Filesystem.
type LaunchAppResponse ¶
type LaunchAppResponse struct { Request ulid.ULID Error error //can be empty }
type LaunchApplicationRequest ¶
type LaunchApplicationRequest struct {
AppDir string
}
type StopAllRequest ¶
type StopAllRequest struct { }
type StopAllResponse ¶
type StopAllResponse struct {
AlreadyStopped bool
}