Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (30 sloc) 650 Bytes
package main
import (
"log"
"time"
"github.com/kelseyhightower/envconfig"
"github.com/tinrab/retry"
"github.com/tinrab/spidey/account"
)
type Config struct {
DatabaseURL string `envconfig:"DATABASE_URL"`
}
func main() {
var cfg Config
err := envconfig.Process("", &cfg)
if err != nil {
log.Fatal(err)
}
var r account.Repository
retry.ForeverSleep(2*time.Second, func(_ int) (err error) {
r, err = account.NewPostgresRepository(cfg.DatabaseURL)
if err != nil {
log.Println(err)
}
return
})
defer r.Close()
log.Println("Listening on port 8080...")
s := account.NewService(r)
log.Fatal(account.ListenGRPC(s, 8080))
}