influxdb/inmem/service.go

50 lines
1.2 KiB
Go
Raw Normal View History

package inmem
import (
"sync"
"time"
"github.com/influxdata/platform"
"github.com/influxdata/platform/rand"
"github.com/influxdata/platform/snowflake"
)
2018-11-07 18:55:52 +00:00
// OpPrefix is the op prefix.
const OpPrefix = "inmem/"
// Service implements various top level services.
type Service struct {
authorizationKV sync.Map
organizationKV sync.Map
bucketKV sync.Map
userKV sync.Map
dashboardKV sync.Map
viewKV sync.Map
macroKV sync.Map
dbrpMappingKV sync.Map
userResourceMappingKV sync.Map
2018-09-07 15:45:28 +00:00
scraperTargetKV sync.Map
2018-10-15 19:17:01 +00:00
telegrafConfigKV sync.Map
onboardingKV sync.Map
basicAuthKV sync.Map
TokenGenerator platform.TokenGenerator
IDGenerator platform.IDGenerator
time func() time.Time
}
// NewService creates an instance of a Service.
func NewService() *Service {
return &Service{
TokenGenerator: rand.NewTokenGenerator(64),
IDGenerator: snowflake.NewIDGenerator(),
time: time.Now,
}
}
// WithTime sets the function for computing the current time. Used for updating meta data
// about objects stored. Should only be used in tests for mocking.
func (s *Service) WithTime(fn func() time.Time) {
s.time = fn
}