2020-11-29 03:22:39 +05:00
|
|
|
package storage
|
|
|
|
|
2020-12-23 13:27:17 +05:00
|
|
|
import "go.dev.pztrn.name/metricator/internal/models"
|
|
|
|
|
2020-11-29 03:22:39 +05:00
|
|
|
// GenericStorage describes interface every other storage should embed
|
|
|
|
// and conform to as it contains essential things like context handling.
|
|
|
|
type GenericStorage interface {
|
|
|
|
// Get returns data from storage by key.
|
2020-12-23 13:27:17 +05:00
|
|
|
Get(string) (models.Metric, error)
|
2020-11-29 03:22:39 +05:00
|
|
|
// GetDoneChan returns a channel which should be used to block execution
|
|
|
|
// until storage's routines are completed.
|
|
|
|
GetDoneChan() chan struct{}
|
|
|
|
// Put puts passed data into storage.
|
2020-12-23 13:27:17 +05:00
|
|
|
Put(map[string]models.Metric)
|
2020-11-29 03:22:39 +05:00
|
|
|
// Start starts asynchronous things if needed.
|
|
|
|
Start()
|
|
|
|
}
|