Skip to content

Commit

Permalink
feat(fxgcppubsub): Added schemas support
Browse files Browse the repository at this point in the history
  • Loading branch information
ekkinox committed Jun 5, 2024
1 parent 57aec98 commit abb6ea5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions fxgcppubsub/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var FxGcpPubSubModule = fx.Module(
fx.Provide(
NewFxGcpPubSubClient,
NewFxGcpPubSubSchemaClient,
schema.NewSchemaRegistry,
NewFxGcpPubSubSchemaRegistry,
),
)

Expand Down Expand Up @@ -53,7 +53,7 @@ func createClient(p FxGcpPubSubClientParam) (*pubsub.Client, error) {
}

p.LifeCycle.Append(fx.Hook{
OnStop: func(ctx context.Context) error {
OnStop: func(context.Context) error {
return client.Close()
},
})
Expand All @@ -79,7 +79,7 @@ func createTestClient(p FxGcpPubSubClientParam) (*pubsub.Client, error) {
}

p.LifeCycle.Append(fx.Hook{
OnStop: func(ctx context.Context) error {
OnStop: func(context.Context) error {
err = client.Close()
if err != nil {
return err
Expand All @@ -104,3 +104,15 @@ func NewFxGcpPubSubSchemaClient(p FxGcpPubSubSchemaClientParam) (*pubsub.SchemaC
return pubsub.NewSchemaClient(p.Context, p.Config.GetString("modules.gcppubsub.project.id"))

}

// FxGcpPubSubSchemaRegistryParam allows injection of the required dependencies in [NewFxGcpPubSubSchemaRegistry].
type FxGcpPubSubSchemaRegistryParam struct {
fx.In
Client *pubsub.SchemaClient
}

// NewFxGcpPubSubSchemaRegistry returns a [schema.SchemaRegistry].
func NewFxGcpPubSubSchemaRegistry(p FxGcpPubSubSchemaRegistryParam) *schema.SchemaRegistry {
return schema.NewSchemaRegistry(p.Client)

}

0 comments on commit abb6ea5

Please sign in to comment.