30 lines
395 B
Go
30 lines
395 B
Go
package api
|
|
|
|
import (
|
|
"database/sql"
|
|
"sync"
|
|
|
|
"github.com/stephenafamo/bob"
|
|
"github.com/tigorlazuardi/bluemage/go/gen/reddit"
|
|
)
|
|
|
|
type API struct {
|
|
mu sync.Mutex
|
|
Executor bob.Executor
|
|
DB *sql.DB
|
|
Reddit *reddit.Client
|
|
}
|
|
|
|
func (api *API) lockf(f func()) {
|
|
api.mu.Lock()
|
|
defer api.mu.Unlock()
|
|
f()
|
|
}
|
|
|
|
type Sort string
|
|
|
|
const (
|
|
SortAsc Sort = "asc"
|
|
SortDesc Sort = "desc"
|
|
)
|