googleinterns / knative-source-mongodb

Apache License 2.0
3 stars 2 forks source link

Controller + Reconciler #35

Closed selim5 closed 4 years ago

selim5 commented 4 years ago

Helps with #7 #8

Proposed Changes

nachocano commented 4 years ago

Thanks @selim5 for getting this first bits in. Some nits to address. Also, I think I'd rather put all the secret and connection to the database logic inside a helper method. Something like

func checkConnection(ctx context.Context, src *v1alpha1.MongoDbSource) error

which will return nil if all goes ok, otherwise will log as you are doing, and return an error... In the caller code you should check for err != nil, if it's not nil, then we call a method in our lifecycle, which we can call MarkConnectionFailed(err error), and you mark false a new condition that we can call "ConnectionEstablished" or something like that, and add the error there. If the connection succeeds, then you call MarkConnectionSuccess, and set that condition to true...

does it make sense?

nachocano commented 4 years ago

Nice! Thanks @selim5 !!!