Kafka consumer and Mortar #42
-
With our mortar service we also start a kafka consumer and dynamoDB.
The
The problem is within the kafka
Can we use the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Making your DynamoClient lazy is a great choice in my opinion, but you should return a pointer to a wrapper. type dynamoWrapper struct {
LazyDynamoClient *dynamo.LazyDynamoClient
} Make sure your Dynamo constructor returns a pointer to this struct func CreateDynamoWrapper(lc fx.Lifecycle) *dynamoWrapper {
var wrapper *dynamoWrapper = &dynamoWrapper{}
lc.Append(
fx.Hook{
OnStart: func(ctx context.Context) (err error) {
wrapper.LazyDynamoClient, err = connectToDynamo(ctx)
return err
},
},
)
return wrapper
} Everywhere you inject In your example instead of injecting |
Beta Was this translation helpful? Give feedback.
Making your DynamoClient lazy is a great choice in my opinion, but you should return a pointer to a wrapper.
For example:
Make sure your Dynamo constructor returns a pointer to this struct
Everywhere you inject
*dynamoWrapper
during the constructors phase the client is not initialized, but once you start your Fx Application all th…