@@ -25,7 +25,7 @@ import (
25
25
26
26
"go.infratographer.com/ipam-api/internal/config"
27
27
ent "go.infratographer.com/ipam-api/internal/ent/generated"
28
- "go.infratographer.com/ipam-api/internal/ent/generated/pubsubhooks "
28
+ "go.infratographer.com/ipam-api/internal/ent/generated/eventhooks "
29
29
"go.infratographer.com/ipam-api/internal/graphapi"
30
30
)
31
31
@@ -65,7 +65,7 @@ func init() {
65
65
serveCmd .Flags ().BoolVar (& enablePlayground , "playground" , false , "enable the graph playground" )
66
66
serveCmd .Flags ().StringVar (& pidFileName , "pid-file" , "" , "path to the pid file" )
67
67
68
- events .MustViperFlagsForPublisher (viper .GetViper (), serveCmd .Flags (), appName )
68
+ events .MustViperFlags (viper .GetViper (), serveCmd .Flags (), appName )
69
69
permissions .MustViperFlags (viper .GetViper (), serveCmd .Flags ())
70
70
}
71
71
@@ -79,11 +79,15 @@ func serve(ctx context.Context) error {
79
79
logger = loggingx .InitLogger (appName , config .AppConfig .Logging )
80
80
}
81
81
82
- pub , err := events .NewPublisher (config .AppConfig .Events . Publisher )
82
+ events , err := events .NewConnection (config .AppConfig .Events , events . WithLogger ( logger ) )
83
83
if err != nil {
84
- logger .Fatalw ("failed to create publisher " , "error" , err )
84
+ logger .Fatalw ("failed to create events connection " , "error" , err )
85
85
}
86
86
87
+ defer func () {
88
+ _ = events .Shutdown (ctx )
89
+ }()
90
+
87
91
err = otelx .InitTracer (config .AppConfig .Tracing , appName , logger )
88
92
if err != nil {
89
93
logger .Fatalw ("failed to initialize tracer" , "error" , err )
@@ -98,7 +102,7 @@ func serve(ctx context.Context) error {
98
102
99
103
entDB := entsql .OpenDB (dialect .Postgres , db )
100
104
101
- cOpts := []ent.Option {ent .Driver (entDB ), ent .EventsPublisher (pub )}
105
+ cOpts := []ent.Option {ent .Driver (entDB ), ent .EventsPublisher (events )}
102
106
103
107
if config .AppConfig .Logging .Debug {
104
108
cOpts = append (cOpts ,
@@ -110,7 +114,7 @@ func serve(ctx context.Context) error {
110
114
client := ent .NewClient (cOpts ... )
111
115
defer client .Close ()
112
116
113
- pubsubhooks . PubsubHooks (client )
117
+ eventhooks . EventHooks (client )
114
118
115
119
// Run the automatic migration tool to create all schema resources.
116
120
if err := client .Schema .Create (ctx ); err != nil {
@@ -130,14 +134,15 @@ func serve(ctx context.Context) error {
130
134
middleware = append (middleware , auth .Middleware ())
131
135
}
132
136
133
- srv , err := echox .NewServer (logger .Desugar (), config .AppConfig .Server , versionx .BuildDetails ())
137
+ srv , err := echox .NewServer (logger .Desugar (), config .AppConfig .Server , versionx .BuildDetails (), echox . WithLoggingSkipper ( echox . SkipDefaultEndpoints ) )
134
138
if err != nil {
135
139
logger .Error ("failed to create server" , zap .Error (err ))
136
140
}
137
141
138
142
perms , err := permissions .New (config .AppConfig .Permissions ,
139
143
permissions .WithLogger (logger ),
140
144
permissions .WithDefaultChecker (permissions .DefaultAllowChecker ),
145
+ permissions .WithEventsPublisher (events ),
141
146
)
142
147
if err != nil {
143
148
logger .Fatal ("failed to initialize permissions" , zap .Error (err ))
0 commit comments