inmem

package
v0.0.0-...-d500d3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const HashCost = bcrypt.DefaultCost

HashCost is currently using bcrypt defaultCost

View Source
const OpPrefix = "inmem/"

OpPrefix is the op prefix.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

Bucket is a btree that implements kv.Bucket.

func (*Bucket) Cursor

func (b *Bucket) Cursor() (kv.Cursor, error)

Cursor creates a static cursor from all entries in the database.

func (*Bucket) Delete

func (b *Bucket) Delete(key []byte) error

Delete removes the key provided.

func (*Bucket) Get

func (b *Bucket) Get(key []byte) ([]byte, error)

Get retrieves the value at the provided key.

func (*Bucket) Put

func (b *Bucket) Put(key []byte, value []byte) error

Put sets the key value pair provided.

type KVStore

type KVStore struct {
	// contains filtered or unexported fields
}

KVStore is an in memory btree backed kv.Store.

func NewKVStore

func NewKVStore() *KVStore

NewKVStore creates an instance of a KVStore.

func (*KVStore) Update

func (s *KVStore) Update(fn func(kv.Tx) error) error

Update opens up a transaction with a write lock.

func (*KVStore) View

func (s *KVStore) View(fn func(kv.Tx) error) error

View opens up a transaction with a read lock.

type Service

type Service struct {
	TokenGenerator platform.TokenGenerator
	IDGenerator    platform.IDGenerator
	// contains filtered or unexported fields
}

Service implements various top level services.

func NewService

func NewService() *Service

NewService creates an instance of a Service.

func (*Service) AddDashboardCell

func (s *Service) AddDashboardCell(ctx context.Context, id platform.ID, cell *platform.Cell, opts platform.AddDashboardCellOptions) error

AddDashboardCell adds a new cell to the dashboard.

func (*Service) AddTarget

func (s *Service) AddTarget(ctx context.Context, target *platform.ScraperTarget) (err error)

AddTarget add a new scraper target into storage.

func (*Service) CompareAndSetPassword

func (s *Service) CompareAndSetPassword(ctx context.Context, name string, old string, new string) error

CompareAndSetPassword replaces the old password with the new password if thee old password is correct.

func (*Service) ComparePassword

func (s *Service) ComparePassword(ctx context.Context, name string, password string) error

ComparePassword compares a provided password with the stored password hash.

func (*Service) Create

func (s *Service) Create(ctx context.Context, m *platform.DBRPMapping) error

Create creates a new dbrp mapping.

func (*Service) CreateAuthorization

func (s *Service) CreateAuthorization(ctx context.Context, a *platform.Authorization) error

CreateAuthorization sets a.Token and a.ID and creates an platform.Authorization

func (*Service) CreateBucket

func (s *Service) CreateBucket(ctx context.Context, b *platform.Bucket) error

CreateBucket creates a new bucket and sets b.ID with the new identifier.

func (*Service) CreateDashboard

func (s *Service) CreateDashboard(ctx context.Context, d *platform.Dashboard) error

CreateDashboard implements platform.DashboardService interface.

func (*Service) CreateLabel

func (s *Service) CreateLabel(ctx context.Context, l *platform.Label) error

func (*Service) CreateMacro

func (s *Service) CreateMacro(ctx context.Context, m *platform.Macro) error

CreateMacro implements the platform.MacroService interface

func (*Service) CreateOrganization

func (s *Service) CreateOrganization(ctx context.Context, o *platform.Organization) error

CreateOrganization creates a new organization and sets b.ID with the new identifier.

func (*Service) CreateTelegrafConfig

func (s *Service) CreateTelegrafConfig(ctx context.Context, tc *platform.TelegrafConfig, userID platform.ID) error

CreateTelegrafConfig creates a new telegraf config and sets b.ID with the new identifier.

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, u *platform.User) error

CreateUser will create an user into storage.

func (*Service) CreateUserResourceMapping

func (s *Service) CreateUserResourceMapping(ctx context.Context, m *platform.UserResourceMapping) error

func (*Service) CreateView

func (s *Service) CreateView(ctx context.Context, c *platform.View) error

CreateView implements platform.ViewService interface.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, cluster, db, rp string) error

Delete removes a dbrp mapping

func (*Service) DeleteAuthorization

func (s *Service) DeleteAuthorization(ctx context.Context, id platform.ID) error

DeleteAuthorization deletes an authorization associated with id.

func (*Service) DeleteBucket

func (s *Service) DeleteBucket(ctx context.Context, id platform.ID) error

DeleteBucket removes a bucket by ID.

func (*Service) DeleteDashboard

func (s *Service) DeleteDashboard(ctx context.Context, id platform.ID) error

DeleteDashboard implements platform.DashboardService interface.

func (*Service) DeleteLabel

func (s *Service) DeleteLabel(ctx context.Context, l platform.Label) error

func (*Service) DeleteMacro

func (s *Service) DeleteMacro(ctx context.Context, id platform.ID) error

DeleteMacro implements the platform.MacroService interface

func (*Service) DeleteOrganization

func (s *Service) DeleteOrganization(ctx context.Context, id platform.ID) error

DeleteOrganization deletes a organization and prunes it from the index.

func (*Service) DeleteOrganizationBuckets

func (s *Service) DeleteOrganizationBuckets(ctx context.Context, id platform.ID) error

DeleteOrganizationBuckets removes all the buckets for a given org

func (*Service) DeleteTelegrafConfig

func (s *Service) DeleteTelegrafConfig(ctx context.Context, id platform.ID) error

DeleteTelegrafConfig removes a telegraf config by ID.

func (*Service) DeleteUser

func (s *Service) DeleteUser(ctx context.Context, id platform.ID) error

DeleteUser remove a user from storage.

func (*Service) DeleteUserResourceMapping

func (s *Service) DeleteUserResourceMapping(ctx context.Context, resourceID, userID platform.ID) error

func (*Service) DeleteView

func (s *Service) DeleteView(ctx context.Context, id platform.ID) error

DeleteView implements platform.ViewService interface.

func (*Service) Find

Find returns the first dbrp mapping that matches filter.

func (*Service) FindAuthorizationByID

func (s *Service) FindAuthorizationByID(ctx context.Context, id platform.ID) (*platform.Authorization, error)

FindAuthorizationByID returns an authorization given an ID.

func (*Service) FindAuthorizationByToken

func (s *Service) FindAuthorizationByToken(ctx context.Context, t string) (*platform.Authorization, error)

FindAuthorizationByToken returns an authorization given a token.

func (*Service) FindAuthorizations

func (s *Service) FindAuthorizations(ctx context.Context, filter platform.AuthorizationFilter, opt ...platform.FindOptions) ([]*platform.Authorization, int, error)

FindAuthorizations returns all authorizations matching the filter.

func (*Service) FindBucket

func (s *Service) FindBucket(ctx context.Context, filter platform.BucketFilter) (*platform.Bucket, error)

FindBucket returns the first bucket that matches filter.

func (*Service) FindBucketByID

func (s *Service) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error)

FindBucketByID returns a single bucket by ID.

func (*Service) FindBuckets

func (s *Service) FindBuckets(ctx context.Context, filter platform.BucketFilter, opt ...platform.FindOptions) ([]*platform.Bucket, int, error)

FindBuckets returns a list of buckets that match filter and the total count of matching buckets. Additional options provide pagination & sorting.

func (*Service) FindBy

func (s *Service) FindBy(ctx context.Context, cluster, db, rp string) (*platform.DBRPMapping, error)

FindBy returns a single dbrp mapping by cluster, db and rp.

func (*Service) FindDashboardByID

func (s *Service) FindDashboardByID(ctx context.Context, id platform.ID) (*platform.Dashboard, error)

FindDashboardByID returns a single dashboard by ID.

func (*Service) FindDashboards

func (s *Service) FindDashboards(ctx context.Context, filter platform.DashboardFilter, opts platform.FindOptions) ([]*platform.Dashboard, int, error)

FindDashboards implements platform.DashboardService interface.

func (*Service) FindLabelBy

func (s *Service) FindLabelBy(ctx context.Context, resourceID platform.ID, name string) (*platform.Label, error)

func (*Service) FindLabels

func (s *Service) FindLabels(ctx context.Context, filter platform.LabelFilter, opt ...platform.FindOptions) ([]*platform.Label, error)

func (*Service) FindMacroByID

func (s *Service) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error)

FindMacroByID implements the platform.MacroService interface

func (*Service) FindMacros

func (s *Service) FindMacros(ctx context.Context) ([]*platform.Macro, error)

FindMacros implements the platform.MacroService interface

func (*Service) FindMany

FindMany returns a list of dbrpMappings that match filter and the total count of matching dbrp mappings. Additional options provide pagination & sorting.

func (*Service) FindOrganization

func (s *Service) FindOrganization(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error)

FindOrganization returns the first organization that matches a filter.

func (*Service) FindOrganizationByID

func (s *Service) FindOrganizationByID(ctx context.Context, id platform.ID) (*platform.Organization, error)

FindOrganizationByID returns a single organization by ID.

func (*Service) FindOrganizations

func (s *Service) FindOrganizations(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error)

FindOrganizations returns a list of organizations that match filter and the total count of matching organizations.

func (*Service) FindTelegrafConfig

func (s *Service) FindTelegrafConfig(ctx context.Context, filter platform.TelegrafConfigFilter) (*platform.TelegrafConfig, error)

FindTelegrafConfig returns the first telegraf config that matches filter.

func (*Service) FindTelegrafConfigByID

func (s *Service) FindTelegrafConfigByID(ctx context.Context, id platform.ID) (tc *platform.TelegrafConfig, err error)

FindTelegrafConfigByID returns a single telegraf config by ID.

func (*Service) FindTelegrafConfigs

func (s *Service) FindTelegrafConfigs(ctx context.Context, filter platform.TelegrafConfigFilter, opt ...platform.FindOptions) (tcs []*platform.TelegrafConfig, n int, err error)

FindTelegrafConfigs returns a list of telegraf configs that match filter and the total count of matching telegraf configs. Additional options provide pagination & sorting.

func (*Service) FindUser

func (s *Service) FindUser(ctx context.Context, filter platform.UserFilter) (*platform.User, error)

FindUser returns the first user that matches a filter.

func (*Service) FindUserByID

func (s *Service) FindUserByID(ctx context.Context, id platform.ID) (u *platform.User, err error)

FindUserByID returns a single user by ID.

func (*Service) FindUserResourceBy

func (s *Service) FindUserResourceBy(ctx context.Context, resourceID, userID platform.ID) (*platform.UserResourceMapping, error)

func (*Service) FindUserResourceMappings

func (s *Service) FindUserResourceMappings(ctx context.Context, filter platform.UserResourceMappingFilter, opt ...platform.FindOptions) ([]*platform.UserResourceMapping, int, error)

func (*Service) FindUsers

func (s *Service) FindUsers(ctx context.Context, filter platform.UserFilter, opt ...platform.FindOptions) ([]*platform.User, int, error)

FindUsers will retrieve a list of users from storage.

func (*Service) FindViewByID

func (s *Service) FindViewByID(ctx context.Context, id platform.ID) (*platform.View, error)

FindViewByID returns a single view by ID.

func (*Service) FindViews

func (s *Service) FindViews(ctx context.Context, filter platform.ViewFilter) ([]*platform.View, int, error)

FindViews implements platform.ViewService interface.

func (*Service) Generate

Generate OnboardingResults from onboarding request, update storage so this request will be disabled for the second run.

func (*Service) GetDashboardCellView

func (s *Service) GetDashboardCellView(ctx context.Context, dashboardID, cellID platform.ID) (*platform.View, error)

GetDashboardCellView retrieves the view for a dashboard cell.

func (*Service) GetTargetByID

func (s *Service) GetTargetByID(ctx context.Context, id platform.ID) (target *platform.ScraperTarget, err error)

GetTargetByID retrieves a scraper target by id.

func (*Service) IsOnboarding

func (s *Service) IsOnboarding(ctx context.Context) (isOnboarding bool, err error)

IsOnboarding checks onboardingBucket to see if the onboarding key is true.

func (*Service) ListTargets

func (s *Service) ListTargets(ctx context.Context) (list []platform.ScraperTarget, err error)

ListTargets will list all scrape targets.

func (*Service) Name

func (s *Service) Name(ctx context.Context, resource platform.Resource, id platform.ID) (string, error)

Name returns the name for the resource and ID.

func (*Service) PutAuthorization

func (s *Service) PutAuthorization(ctx context.Context, a *platform.Authorization) error

PutAuthorization overwrites the authorization with the contents of a.

func (*Service) PutBucket

func (s *Service) PutBucket(ctx context.Context, b *platform.Bucket) error

PutBucket sets bucket with the current ID.

func (*Service) PutCellView

func (s *Service) PutCellView(ctx context.Context, cell *platform.Cell) error

PutCellView puts the view for a cell.

func (*Service) PutDBRPMapping

func (s *Service) PutDBRPMapping(ctx context.Context, m *platform.DBRPMapping) error

PutDBRPMapping sets dbrpMapping with the current ID.

func (*Service) PutDashboard

func (s *Service) PutDashboard(ctx context.Context, d *platform.Dashboard) error

PutDashboard implements platform.DashboardService interface.

func (*Service) PutDashboardCell

func (s *Service) PutDashboardCell(ctx context.Context, id platform.ID, cell *platform.Cell) error

PutDashboardCell replaces a dashboad cell with the cell contents.

func (*Service) PutDashboardWithMeta

func (s *Service) PutDashboardWithMeta(ctx context.Context, d *platform.Dashboard) error

PutDashboardWithMeta sets a dashboard while updating the meta field of a dashboard.

func (*Service) PutLabel

func (s *Service) PutLabel(ctx context.Context, l *platform.Label) error

func (*Service) PutOnboardingStatus

func (s *Service) PutOnboardingStatus(ctx context.Context, v bool) error

PutOnboardingStatus will put the isOnboarding to storage

func (*Service) PutOrganization

func (s *Service) PutOrganization(ctx context.Context, o *platform.Organization) error

PutOrganization will put a organization without setting an ID.

func (*Service) PutTarget

func (s *Service) PutTarget(ctx context.Context, target *platform.ScraperTarget) error

PutTarget will put a scraper target without setting an ID.

func (*Service) PutUser

func (s *Service) PutUser(ctx context.Context, o *platform.User) error

PutUser put a user into storage.

func (*Service) PutUserResourceMapping

func (s *Service) PutUserResourceMapping(ctx context.Context, m *platform.UserResourceMapping) error

func (*Service) PutView

func (s *Service) PutView(ctx context.Context, c *platform.View) error

PutView implements platform.ViewService interface.

func (*Service) RemoveDashboardCell

func (s *Service) RemoveDashboardCell(ctx context.Context, dashboardID platform.ID, cellID platform.ID) error

RemoveDashboardCell removes a dashboard cell from the dashboard.

func (*Service) RemoveTarget

func (s *Service) RemoveTarget(ctx context.Context, id platform.ID) error

RemoveTarget removes a scraper target from the bucket.

func (*Service) ReplaceDashboardCells

func (s *Service) ReplaceDashboardCells(ctx context.Context, id platform.ID, cs []*platform.Cell) error

ReplaceDashboardCells replaces many dashboard cells.

func (*Service) ReplaceMacro

func (s *Service) ReplaceMacro(ctx context.Context, m *platform.Macro) error

ReplaceMacro stores a Macro in the key value store

func (*Service) SetAuthorizationStatus

func (s *Service) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) error

SetAuthorizationStatus updates the status of an authorization associated with id.

func (*Service) SetPassword

func (s *Service) SetPassword(ctx context.Context, name string, password string) error

SetPassword stores the password hash associated with a user.

func (*Service) UpdateBucket

func (s *Service) UpdateBucket(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error)

UpdateBucket updates a single bucket with changeset. Returns the new bucket state after update.

func (*Service) UpdateDashboard

func (s *Service) UpdateDashboard(ctx context.Context, id platform.ID, upd platform.DashboardUpdate) (*platform.Dashboard, error)

UpdateDashboard implements platform.DashboardService interface.

func (*Service) UpdateDashboardCell

func (s *Service) UpdateDashboardCell(ctx context.Context, dashboardID platform.ID, cellID platform.ID, upd platform.CellUpdate) (*platform.Cell, error)

UpdateDashboardCell will remove a cell from a dashboard.

func (*Service) UpdateDashboardCellView

func (s *Service) UpdateDashboardCellView(ctx context.Context, dashboardID, cellID platform.ID, upd platform.ViewUpdate) (*platform.View, error)

UpdateDashboardCellView updates the view for a dashboard cell.

func (*Service) UpdateLabel

func (s *Service) UpdateLabel(ctx context.Context, l *platform.Label, upd platform.LabelUpdate) (*platform.Label, error)

func (*Service) UpdateMacro

func (s *Service) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error)

UpdateMacro implements the platform.MacroService interface

func (*Service) UpdateOrganization

func (s *Service) UpdateOrganization(ctx context.Context, id platform.ID, upd platform.OrganizationUpdate) (*platform.Organization, error)

UpdateOrganization updates a organization according the parameters set on upd.

func (*Service) UpdateTarget

func (s *Service) UpdateTarget(ctx context.Context, update *platform.ScraperTarget) (target *platform.ScraperTarget, err error)

UpdateTarget updates a scraper target.

func (*Service) UpdateTelegrafConfig

func (s *Service) UpdateTelegrafConfig(ctx context.Context, id platform.ID, tc *platform.TelegrafConfig, userID platform.ID) (*platform.TelegrafConfig, error)

UpdateTelegrafConfig updates a single telegraf config. Returns the new telegraf config after update.

func (*Service) UpdateUser

func (s *Service) UpdateUser(ctx context.Context, id platform.ID, upd platform.UserUpdate) (*platform.User, error)

UpdateUser update a user in storage.

func (*Service) UpdateView

func (s *Service) UpdateView(ctx context.Context, id platform.ID, upd platform.ViewUpdate) (*platform.View, error)

UpdateView implements platform.ViewService interface.

func (*Service) WithTime

func (s *Service) WithTime(fn func() time.Time)

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.

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx is an in memory transaction. TODO: make transactions actually transactional

func (*Tx) Bucket

func (t *Tx) Bucket(b []byte) (kv.Bucket, error)

Bucket retrieves the bucket at the provided key.

func (*Tx) Context

func (t *Tx) Context() context.Context

Context returns the context for the transaction.

func (*Tx) WithContext

func (t *Tx) WithContext(ctx context.Context)

WithContext sets the context for the transaction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL