mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
31 lines
549 B
Go
31 lines
549 B
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.uber.org/fx"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var Module = fx.Module(
|
|
"auth",
|
|
fx.Decorate(func(log *zap.Logger) *zap.Logger {
|
|
return log.Named("auth")
|
|
}),
|
|
fx.Provide(New),
|
|
fx.Provide(newRepository, fx.Private),
|
|
fx.Invoke(func(lc fx.Lifecycle, svc *Service) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
lc.Append(fx.Hook{
|
|
OnStart: func(_ context.Context) error {
|
|
go svc.Run(ctx)
|
|
return nil
|
|
},
|
|
OnStop: func(_ context.Context) error {
|
|
cancel()
|
|
return nil
|
|
},
|
|
})
|
|
}),
|
|
)
|