71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package workerruntime
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
ErrInvalidStore = errors.New("invalid worker runtime store")
|
|
ErrInvalidSession = errors.New("invalid worker runtime session")
|
|
ErrInvalidReport = errors.New("invalid worker runtime report")
|
|
ErrInvalidQuery = errors.New("invalid worker runtime query")
|
|
ErrStaleSession = errors.New("stale worker runtime session")
|
|
ErrStaleReport = errors.New("stale worker runtime report")
|
|
ErrConflictingReport = errors.New("conflicting worker runtime report")
|
|
)
|
|
|
|
type Session struct {
|
|
WorkerID string
|
|
InstanceID string
|
|
SessionID string
|
|
AckedSnapshotVersion uint64
|
|
AckedOwnershipEpoch uint64
|
|
}
|
|
|
|
type Counter struct {
|
|
ProxyID string
|
|
Active int64
|
|
Reserved int64
|
|
Draining bool
|
|
}
|
|
|
|
// Report is a complete sparse replacement. Missing counters are zero for the
|
|
// reported Worker snapshot; callers must increase Sequence for every update.
|
|
type Report struct {
|
|
WorkerID string
|
|
SessionID string
|
|
Sequence uint64
|
|
SnapshotVersion uint64
|
|
OwnershipEpoch uint64
|
|
ObservedAt time.Time
|
|
Counters []Counter
|
|
}
|
|
|
|
type OwnedProxy struct {
|
|
ProxyID string
|
|
WorkerID string
|
|
OwnershipEpoch uint64
|
|
}
|
|
|
|
type Snapshot struct {
|
|
ProxyID string
|
|
Active int64
|
|
Reserved int64
|
|
Draining bool
|
|
Fresh bool
|
|
}
|
|
|
|
type SessionWriter interface {
|
|
ReplaceSession(context.Context, Session, time.Duration) error
|
|
}
|
|
|
|
type ReportWriter interface {
|
|
ReplaceRuntime(context.Context, Report, time.Duration) error
|
|
}
|
|
|
|
type RuntimeReader interface {
|
|
ReadRuntime(context.Context, []OwnedProxy) ([]Snapshot, error)
|
|
}
|