You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
810 B

package main
import (
clientv3 "go.etcd.io/etcd/client/v3"
"sonet/internal/auth/data"
"sonet/internal/auth/logic"
"sonet/pkg/config"
"sonet/pkg/grpc/discovery"
"sonet/pkg/utils/shutdown"
)
type AuthConfig struct {
AesTokenKey string
}
func main() {
appConf := &AuthConfig{}
conf := config.LoadConfig(appConf, "cmd/auth")
// registry and run...
etcdClient, err := clientv3.New(conf.Etcd)
if err != nil {
panic(err)
}
shutdown.AddHook(func() { _ = etcdClient.Close() }, shutdown.WithOrderBack())
// user dao
userDao := data.NewUserDao(config.NewGorm(conf.Gorm))
authServer := logic.NewAuthServer(appConf.AesTokenKey, userDao)
dis := discovery.NewEtcdDiscovery(etcdClient)
go func() {
err = authServer.Run(conf.Grpc, dis)
if err != nil {
panic(err)
}
}()
shutdown.Await()
}