Skip to content

Commit c5c19f6

Browse files
committed
[pubsub] add close on shutdown
1 parent c96b2b5 commit c5c19f6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/sms-gateway/pubsub/module.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package pubsub
22

33
import (
4+
"context"
5+
6+
"github.com/android-sms-gateway/server/pkg/pubsub"
47
"go.uber.org/fx"
58
"go.uber.org/zap"
69
)
@@ -12,5 +15,12 @@ func Module() fx.Option {
1215
return log.Named("pubsub")
1316
}),
1417
fx.Provide(New),
18+
fx.Invoke(func(pubsub pubsub.PubSub, lc fx.Lifecycle) {
19+
lc.Append(fx.Hook{
20+
OnStop: func(_ context.Context) error {
21+
return pubsub.Close()
22+
},
23+
})
24+
}),
1525
)
1626
}

0 commit comments

Comments
 (0)