Add lock and close check on cassandra as well

This commit is contained in:
Jeff Mitchell 2017-12-19 10:26:46 -05:00
parent 3cf61a5d8f
commit 15df4d1f36

View file

@ -116,12 +116,15 @@ func (c *cassandraConnectionProducer) Initialize(ctx context.Context, conf map[s
}
func (c *cassandraConnectionProducer) Connection(_ context.Context) (interface{}, error) {
c.Lock()
defer c.Unlock()
if !c.Initialized {
return nil, connutil.ErrNotInitialized
}
// If we already have a DB, return it
if c.session != nil {
if c.session != nil && !c.session.Closed() {
return c.session, nil
}