mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Implement graceful shutdown of agent.DataAccess (#1008)
* Implements graceful shutdown of agent.DataAccess and underlying Datastore/Logstore/MessageQueue * adds tests for closing agent.DataAccess and Datastore
This commit is contained in:
@@ -347,3 +347,10 @@ func (mq *BoltDbMQ) Delete(ctx context.Context, job *models.Call) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Close shuts down the bolt db connection and
|
||||
// stops the goroutine associated with the ticker
|
||||
func (mq *BoltDbMQ) Close() error {
|
||||
mq.ticker.Stop()
|
||||
return mq.db.Close()
|
||||
}
|
||||
|
||||
@@ -192,3 +192,9 @@ func (mq *MemoryMQ) Delete(ctx context.Context, job *models.Call) error {
|
||||
log.Debugln("Deleted")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close stops the associated goroutines by stopping the ticker
|
||||
func (mq *MemoryMQ) Close() error {
|
||||
mq.Ticker.Stop()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -24,3 +24,7 @@ func (mock *Mock) Reserve(context.Context) (*models.Call, error) {
|
||||
func (mock *Mock) Delete(context.Context, *models.Call) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mock *Mock) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -60,3 +60,8 @@ func (m *metricMQ) Delete(ctx context.Context, t *models.Call) error {
|
||||
defer span.End()
|
||||
return m.mq.Delete(ctx, t)
|
||||
}
|
||||
|
||||
// Close closes the underlying message queue
|
||||
func (m *metricMQ) Close() error {
|
||||
return m.mq.Close()
|
||||
}
|
||||
|
||||
@@ -307,3 +307,10 @@ func (mq *RedisMQ) Delete(ctx context.Context, job *models.Call) error {
|
||||
_, err = conn.Do("HDEL", "timeout", resID)
|
||||
return err
|
||||
}
|
||||
|
||||
// Close shuts down the redis connection pool and
|
||||
// stops the goroutine associated with the ticker
|
||||
func (mq *RedisMQ) Close() error {
|
||||
mq.ticker.Stop()
|
||||
return mq.pool.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user