2020-11-29 03:22:39 +05:00
|
|
|
package storage
|
|
|
|
|
2020-12-24 23:06:13 +05:00
|
|
|
import "go.dev.pztrn.name/metricator/pkg/schema"
|
2020-12-23 13:27:17 +05:00
|
|
|
|
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-24 23:06:13 +05:00
|
|
|
Get(string) (schema.Metric, error)
|
2020-12-23 13:37:52 +05:00
|
|
|
// GetAsSlice returns all data from storage as slice.
|
2020-12-24 23:06:13 +05:00
|
|
|
GetAsSlice() []schema.Metric
|
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-24 23:06:13 +05:00
|
|
|
Put(map[string]schema.Metric)
|
2020-11-29 03:22:39 +05:00
|
|
|
// Start starts asynchronous things if needed.
|
|
|
|
Start()
|
|
|
|
}
|