container: improve doc comments
Some checks failed
Test / Create distribution (push) Successful in 32s
Test / Hakurei (push) Failing after 58s
Test / Planterette (push) Failing after 1m11s
Test / Hakurei (race detector) (push) Failing after 1m35s
Test / Sandbox (push) Failing after 1m35s
Test / Sandbox (race detector) (push) Failing after 2m27s
Test / Flake checks (push) Has been skipped

Putting them on the builder methods is more useful.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-07-27 12:17:21 +09:00
parent bd3fa53a55
commit dcff0a8c3c
2 changed files with 77 additions and 55 deletions

View File

@@ -91,12 +91,13 @@ type (
}
)
// Start starts the container init. The init process blocks until Serve is called.
func (p *Container) Start() error {
if p.cmd != nil {
return errors.New("sandbox: already started")
return errors.New("container: already started")
}
if p.Ops == nil || len(*p.Ops) == 0 {
return errors.New("sandbox: starting an empty container")
return errors.New("container: starting an empty container")
}
ctx, cancel := context.WithCancel(p.ctx)
@@ -160,6 +161,8 @@ func (p *Container) Start() error {
return nil
}
// Serve serves [Container.Params] to the container init.
// Serve must only be called once.
func (p *Container) Serve() error {
if p.setup == nil {
panic("invalid serve")
@@ -213,6 +216,7 @@ func (p *Container) Serve() error {
return err
}
// Wait waits for the container init process to exit.
func (p *Container) Wait() error { defer p.cancel(); return p.cmd.Wait() }
func (p *Container) String() string {