Documentation
¶
Index ¶
- func ConsumeReconnectToken(token string) (int, bool)
- func Execute(binaryPath string, extraArgs []string) error
- func IssueReconnectToken(userId int) (string, error)
- func Register(c Contributor)
- func ResetRegistry()
- func Restore(fd int) error
- func Save(w io.Writer) error
- type Contributor
- type Decoder
- type Encoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsumeReconnectToken ¶
ConsumeReconnectToken validates and consumes a token, returning the associated userId. Returns 0, false if the token is unknown or expired.
func Execute ¶
Execute serializes all registered contributors into a pipe, launches the new process image with the pipe fd passed via --copyover-fd, then exits. extraArgs are forwarded as-is to the child process. Returns an error on platforms where copyover is not supported.
func IssueReconnectToken ¶
IssueReconnectToken creates a one-time reconnect token for the given userId and returns it. The token expires after 2 minutes.
func Register ¶
func Register(c Contributor)
Register adds a contributor to the global registry. Must be called before copyover is triggered.
func ResetRegistry ¶
func ResetRegistry()
ResetRegistry clears all registered contributors. Intended for use in tests.
Types ¶
type Contributor ¶
type Contributor interface {
// CopyoverName returns a stable, unique key for this contributor.
CopyoverName() string
// CopyoverSave serializes state into the provided encoder.
CopyoverSave(enc *Encoder) error
// CopyoverRestore deserializes state from the provided decoder.
CopyoverRestore(dec *Decoder) error
}
Contributor is implemented by any subsystem that needs to save/restore state across a copyover.
func FuncContributor ¶
func FuncContributor(name string, save func(*Encoder) error, restore func(*Decoder) error) Contributor
FuncContributor returns a Contributor implemented by the provided functions. Intended for use in tests.
func TokenContributor ¶
func TokenContributor() Contributor
TokenContributor returns the Contributor that persists reconnect tokens across a copyover. Register it in main alongside the other contributors.