nativeturn

package
v1.0.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultTurnDeadline = 15 * time.Minute
	DefaultGraceWindow  = 60 * time.Second
	DefaultJournalSize  = 512
)
View Source
const (
	StateRunning  = "running"
	StateGrace    = "grace"
	StateFinished = "finished"
)

Variables

View Source
var ErrClosed = errors.New("nativeturn: registry is closed")

Functions

This section is empty.

Types

type Config

type Config struct {
	TurnDeadline time.Duration
	GraceWindow  time.Duration
	JournalSize  int
}

func ParseEnv

func ParseEnv(turnMax, turnGrace string) (Config, error)

type Event

type Event struct {
	Seq    uint64
	Update libacp.SessionNotification
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *Registry

func (*Registry) AttachIfRunning

func (r *Registry) AttachIfRunning(ctx context.Context, sid libacp.SessionID, viewer Viewer) (*Turn, bool, error)

func (*Registry) Cancel

func (r *Registry) Cancel(sid libacp.SessionID) bool

func (*Registry) Close

func (r *Registry) Close() error

func (*Registry) Get

func (r *Registry) Get(sid libacp.SessionID) (TurnStatus, bool)

func (*Registry) List

func (r *Registry) List() []TurnStatus

func (*Registry) ReapIdle

func (r *Registry) ReapIdle(_ context.Context) error

func (*Registry) Start

func (r *Registry) Start(sid libacp.SessionID, fn TurnFunc, viewer Viewer) (*Turn, bool, error)

func (*Registry) Stop

func (r *Registry) Stop(sid libacp.SessionID) bool

type Result

type Result struct {
	StopReason libacp.StopReason
	Err        error
}

type Turn

type Turn struct {
	// contains filtered or unexported fields
}

func (*Turn) Await

func (t *Turn) Await(ctx context.Context) (Result, bool)

func (*Turn) Cancel

func (t *Turn) Cancel()

func (*Turn) Detach

func (t *Turn) Detach(viewerID string)

func (*Turn) Done

func (t *Turn) Done() <-chan struct{}

func (*Turn) Result

func (t *Turn) Result() Result

func (*Turn) SessionID

func (t *Turn) SessionID() libacp.SessionID

type TurnFunc

type TurnFunc func(ctx context.Context, emit func(ctx context.Context, n libacp.SessionNotification)) Result

type TurnStatus

type TurnStatus struct {
	SessionID libacp.SessionID `json:"sessionId"`
	StartedAt time.Time        `json:"startedAt"`
	Deadline  time.Time        `json:"deadline"`
	Viewers   int              `json:"viewers"`
	State     string           `json:"state"`
}

type Viewer

type Viewer interface {
	ID() string

	Deliver(ctx context.Context, ev Event) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL