Files
x/database/actor.go
Colin Henry fe49018479
Some checks failed
Go / build (1.19) (push) Failing after 22s
added new check capability and added assets to a few other packages
2024-09-28 15:19:00 -07:00

28 lines
390 B
Go

package database
import (
"context"
"database/sql"
"git.sdf.org/jchenry/x"
)
type Func func(db *sql.DB)
type Actor struct {
DB *sql.DB
ActionChan chan Func
}
func (a *Actor) Run(ctx context.Context) error {
x.Assert(ctx != nil, "Actor.Run: context cannot be nil")
for {
select {
case f := <-a.ActionChan:
f(a.DB)
case <-ctx.Done():
return ctx.Err()
}
}
}