Documentation
¶
Index ¶
- Constants
- type Dependency
- type Repository
- func (r *Repository) DecrementPendingDeps(ctx context.Context, unitID string) error
- func (r *Repository) FindSignalUnit(ctx context.Context, blueprintID, signalKey string) (ledger.Unit, error)
- func (r *Repository) Get(ctx context.Context, unitID string) (ledger.Unit, error)
- func (r *Repository) Insert(ctx context.Context, units []*Unit) error
- func (r *Repository) InsertDependencies(ctx context.Context, deps []*Dependency) error
- func (r *Repository) SelectUnblocked(ctx context.Context, unitID string) ([]ledger.Unit, error)
- type Unit
Constants ¶
const ( UnitTypeTask = "task" UnitTypeSignal = "signal" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dependency ¶
type Dependency struct {
bun.BaseModel `bun:"table:blueprint_unit_dependencies"`
UnitID string `bun:"unit_id,pk"`
DependsOnID string `bun:"depends_on_id,pk"`
}
Dependency is the bun model for blueprint_unit_dependencies.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func New ¶
func New(db *bun.DB) *Repository
func (*Repository) DecrementPendingDeps ¶
func (r *Repository) DecrementPendingDeps(ctx context.Context, unitID string) error
DecrementPendingDeps decrements pending_deps for all direct successors of unitID. Must be called within a transaction — uses bunutil.IDB to pick up the tx from ctx.
func (*Repository) FindSignalUnit ¶
func (r *Repository) FindSignalUnit(ctx context.Context, blueprintID, signalKey string) (ledger.Unit, error)
FindSignalUnit returns the signal unit for (blueprintID, signalKey) if it has not yet been completed. Returns sql.ErrNoRows if not found or already completed.
func (*Repository) InsertDependencies ¶
func (r *Repository) InsertDependencies(ctx context.Context, deps []*Dependency) error
func (*Repository) SelectUnblocked ¶
SelectUnblocked returns task units that became ready after unitID completed: pending_deps = 0, no prior dispatch or completion event, not signal units. FOR UPDATE prevents double-dispatch when two deps complete concurrently. Must be called within a transaction — uses bunutil.IDB to pick up the tx from ctx.
type Unit ¶
type Unit struct {
bun.BaseModel `bun:"table:blueprint_units"`
ID string `bun:"id,pk,type:uuid"`
BlueprintID string `bun:"blueprint_id,notnull"`
Key string `bun:"key,notnull"`
UnitType string `bun:"unit_type,notnull,default:'task'"`
PendingDeps int `bun:"pending_deps,notnull"`
CreatedAt time.Time `bun:"created_at,notnull,default:now()"`
UpdatedAt time.Time `bun:"updated_at,notnull,default:now()"`
}
Unit is the bun model for blueprint_units.