bolt

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: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSourceID it the default source identifier
	DefaultSourceID = "020f755c3c082000"
	// DefaultSourceOrganizationID is the default source's organization identifier
	DefaultSourceOrganizationID = "50616e67652c206c"
)
View Source
const OpPrefix = "bolt/"

OpPrefix is the prefix for bolt ops

Variables

View Source
var DefaultSource = platform.Source{
	Default: true,
	Name:    "autogen",
	Type:    platform.SelfSourceType,
}

DefaultSource is the default source.

View Source
var HashCost = bcrypt.DefaultCost

HashCost currently using the default cost of bcrypt

Functions

This section is empty.

Types

type Bucket

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

Bucket implements kv.Bucket.

func (*Bucket) Cursor

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

Cursor retrieves a cursor for iterating through the entries in the key value store.

func (*Bucket) Delete

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

Delete removes the provided key.

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 value at the provided key.

type Client

type Client struct {
	Path string

	Logger *zap.Logger

	IDGenerator    platform.IDGenerator
	TokenGenerator platform.TokenGenerator
	// contains filtered or unexported fields
}

Client is a client for the boltDB data store.

func NewClient

func NewClient() *Client

NewClient returns an instance of a Client.

func (*Client) AddDashboardCell

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

AddDashboardCell adds a cell to a dashboard and sets the cells ID.

func (*Client) AddLogEntry

func (c *Client) AddLogEntry(ctx context.Context, k, v []byte, t time.Time) error

LogKeyValue logs an keyValue for a particular resource type ID pairing.

func (*Client) AddTarget

func (c *Client) AddTarget(ctx context.Context, target *platform.ScraperTarget) (err error)

AddTarget add a new scraper target into storage.

func (*Client) Close

func (c *Client) Close() error

Close the connection to the bolt database

func (*Client) CompareAndSetPassword

func (c *Client) 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 (*Client) ComparePassword

func (c *Client) ComparePassword(ctx context.Context, name string, password string) error

ComparePassword compares a provided password with the stored password hash.

func (*Client) CreateAuthorization

func (c *Client) CreateAuthorization(ctx context.Context, a *platform.Authorization) error

CreateAuthorization creates a platform authorization and sets b.ID, and b.UserID if not provided.

func (*Client) CreateBucket

func (c *Client) CreateBucket(ctx context.Context, b *platform.Bucket) error

CreateBucket creates a platform bucket and sets b.ID.

func (*Client) CreateDashboard

func (c *Client) CreateDashboard(ctx context.Context, d *platform.Dashboard) error

CreateDashboard creates a platform dashboard and sets d.ID.

func (*Client) CreateLabel

func (c *Client) CreateLabel(ctx context.Context, l *platform.Label) error

func (*Client) CreateMacro

func (c *Client) CreateMacro(ctx context.Context, macro *platform.Macro) error

CreateMacro creates a new macro and assigns it an ID

func (*Client) CreateOrganization

func (c *Client) CreateOrganization(ctx context.Context, o *platform.Organization) error

CreateOrganization creates a platform organization and sets b.ID.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, user string) (*platform.Session, error)

CreateSession creates a session for a user with the users maximal privileges.

func (*Client) CreateSource

func (c *Client) CreateSource(ctx context.Context, s *platform.Source) error

CreateSource creates a platform source and sets s.ID.

func (*Client) CreateTelegrafConfig

func (c *Client) 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 (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, u *platform.User) error

CreateUser creates a platform user and sets b.ID.

func (*Client) CreateUserResourceMapping

func (c *Client) CreateUserResourceMapping(ctx context.Context, m *platform.UserResourceMapping) error

func (*Client) CreateView

func (c *Client) CreateView(ctx context.Context, d *platform.View) error

CreateView creates a platform view and sets d.ID.

func (*Client) DB

func (c *Client) DB() *bolt.DB

DB returns the clients DB.

func (*Client) DefaultSource

func (c *Client) DefaultSource(ctx context.Context) (*platform.Source, error)

DefaultSource retrieves the default source.

func (*Client) DeleteAuthorization

func (c *Client) DeleteAuthorization(ctx context.Context, id platform.ID) error

DeleteAuthorization deletes a authorization and prunes it from the index.

func (*Client) DeleteBucket

func (c *Client) DeleteBucket(ctx context.Context, id platform.ID) error

DeleteBucket deletes a bucket and prunes it from the index.

func (*Client) DeleteDashboard

func (c *Client) DeleteDashboard(ctx context.Context, id platform.ID) error

DeleteDashboard deletes a dashboard and prunes it from the index.

func (*Client) DeleteLabel

func (c *Client) DeleteLabel(ctx context.Context, l platform.Label) error

DeleteLabel deletes a label.

func (*Client) DeleteMacro

func (c *Client) DeleteMacro(ctx context.Context, id platform.ID) error

DeleteMacro removes a single macro from the store by its ID

func (*Client) DeleteOrganization

func (c *Client) DeleteOrganization(ctx context.Context, id platform.ID) error

DeleteOrganization deletes a organization and prunes it from the index.

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(ctx context.Context, orgID platform.ID, ks ...string) error

DeleteSecret removes secrets from the secret store.

func (*Client) DeleteSource

func (c *Client) DeleteSource(ctx context.Context, id platform.ID) error

DeleteSource deletes a source and prunes it from the index.

func (*Client) DeleteTelegrafConfig

func (c *Client) DeleteTelegrafConfig(ctx context.Context, id platform.ID) error

DeleteTelegrafConfig removes a telegraf config by ID.

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, id platform.ID) error

DeleteUser deletes a user and prunes it from the index.

func (*Client) DeleteUserResourceMapping

func (c *Client) DeleteUserResourceMapping(ctx context.Context, resourceID platform.ID, userID platform.ID) error

DeleteUserResourceMapping deletes a user resource mapping.

func (*Client) DeleteView

func (c *Client) DeleteView(ctx context.Context, id platform.ID) error

DeleteView deletes a view and prunes it from the index.

func (*Client) ExpireSession

func (c *Client) ExpireSession(ctx context.Context, key string) error

ExpireSession expires the session at the provided key.

func (*Client) FindAuthorizationByID

func (c *Client) FindAuthorizationByID(ctx context.Context, id platform.ID) (*platform.Authorization, error)

FindAuthorizationByID retrieves a authorization by id.

func (*Client) FindAuthorizationByToken

func (c *Client) FindAuthorizationByToken(ctx context.Context, n string) (*platform.Authorization, error)

FindAuthorizationByToken returns a authorization by token for a particular authorization.

func (*Client) FindAuthorizations

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

FindAuthorizations retrives all authorizations that match an arbitrary authorization filter. Filters using ID, or Token should be efficient. Other filters will do a linear scan across all authorizations searching for a match.

func (*Client) FindBucket

func (c *Client) FindBucket(ctx context.Context, filter platform.BucketFilter) (*platform.Bucket, error)

FindBucket retrives a bucket using an arbitrary bucket filter. Filters using ID, or OrganizationID and bucket Name should be efficient. Other filters will do a linear scan across buckets until it finds a match.

func (*Client) FindBucketByID

func (c *Client) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error)

FindBucketByID retrieves a bucket by id.

func (*Client) FindBucketByName

func (c *Client) FindBucketByName(ctx context.Context, orgID platform.ID, n string) (*platform.Bucket, error)

FindBucketByName returns a bucket by name for a particular organization. TODO: have method for finding bucket using organization name and bucket name.

func (*Client) FindBuckets

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

FindBuckets retrives all buckets that match an arbitrary bucket filter. Filters using ID, or OrganizationID and bucket Name should be efficient. Other filters will do a linear scan across all buckets searching for a match.

func (*Client) FindDashboard

func (c *Client) FindDashboard(ctx context.Context, filter platform.DashboardFilter) (*platform.Dashboard, error)

FindDashboard retrieves a dashboard using an arbitrary dashboard filter.

func (*Client) FindDashboardByID

func (c *Client) FindDashboardByID(ctx context.Context, id platform.ID) (*platform.Dashboard, error)

FindDashboardByID retrieves a dashboard by id.

func (*Client) FindDashboards

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

FindDashboards retrives all dashboards that match an arbitrary dashboard filter.

func (*Client) FindLabels

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

FindLabels returns a list of labels that match a filter.

func (*Client) FindMacroByID

func (c *Client) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error)

FindMacroByID finds a single macro in the store by its ID

func (*Client) FindMacros

func (c *Client) FindMacros(ctx context.Context) ([]*platform.Macro, error)

FindMacros returns all macros in the store

func (*Client) FindOrganization

func (c *Client) FindOrganization(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error)

FindOrganization retrives a organization using an arbitrary organization filter. Filters using ID, or Name should be efficient. Other filters will do a linear scan across organizations until it finds a match.

func (*Client) FindOrganizationByID

func (c *Client) FindOrganizationByID(ctx context.Context, id platform.ID) (*platform.Organization, error)

FindOrganizationByID retrieves a organization by id.

func (*Client) FindOrganizationByName

func (c *Client) FindOrganizationByName(ctx context.Context, n string) (*platform.Organization, error)

FindOrganizationByName returns a organization by name for a particular organization.

func (*Client) FindOrganizations

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

FindOrganizations retrives all organizations that match an arbitrary organization filter. Filters using ID, or Name should be efficient. Other filters will do a linear scan across all organizations searching for a match.

func (*Client) FindSession

func (c *Client) FindSession(ctx context.Context, key string) (*platform.Session, error)

FindSession retrieves the session found at the provided key.

func (*Client) FindSourceByID

func (c *Client) FindSourceByID(ctx context.Context, id platform.ID) (*platform.Source, error)

FindSourceByID retrieves a source by id.

func (*Client) FindSources

func (c *Client) FindSources(ctx context.Context, opt platform.FindOptions) ([]*platform.Source, int, error)

FindSources retrives all sources that match an arbitrary source filter. Filters using ID, or OrganizationID and source Name should be efficient. Other filters will do a linear scan across all sources searching for a match.

func (*Client) FindTelegrafConfig

func (c *Client) FindTelegrafConfig(ctx context.Context, filter platform.TelegrafConfigFilter) (*platform.TelegrafConfig, error)

FindTelegrafConfig returns the first telegraf config that matches filter.

func (*Client) FindTelegrafConfigByID

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

FindTelegrafConfigByID returns a single telegraf config by ID.

func (*Client) FindTelegrafConfigs

func (c *Client) 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 (*Client) FindUser

func (c *Client) FindUser(ctx context.Context, filter platform.UserFilter) (*platform.User, error)

FindUser retrives a user using an arbitrary user filter. Filters using ID, or Name should be efficient. Other filters will do a linear scan across users until it finds a match.

func (*Client) FindUserByID

func (c *Client) FindUserByID(ctx context.Context, id platform.ID) (*platform.User, error)

FindUserByID retrieves a user by id.

func (*Client) FindUserByName

func (c *Client) FindUserByName(ctx context.Context, n string) (*platform.User, error)

FindUserByName returns a user by name for a particular user.

func (*Client) FindUserResourceMappings

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

FindUserResourceMappings returns a list of UserResourceMappings that match filter and the total count of matching mappings.

func (*Client) FindUsers

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

FindUsers retrives all users that match an arbitrary user filter. Filters using ID, or Name should be efficient. Other filters will do a linear scan across all users searching for a match.

func (*Client) FindView

func (c *Client) FindView(ctx context.Context, filter platform.ViewFilter) (*platform.View, error)

FindView retrieves a view using an arbitrary view filter.

func (*Client) FindViewByID

func (c *Client) FindViewByID(ctx context.Context, id platform.ID) (*platform.View, error)

FindViewByID retrieves a view by id.

func (*Client) FindViews

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

FindViews retrives all views that match an arbitrary view filter.

func (*Client) FirstLogEntry

func (c *Client) FirstLogEntry(ctx context.Context, k []byte) ([]byte, time.Time, error)

FirstLogEntry retrieves the first log entry for a key value log.

func (*Client) ForEachLogEntry

func (c *Client) ForEachLogEntry(ctx context.Context, k []byte, opts platform.FindOptions, fn func([]byte, time.Time) error) error

ForEachLogEntry retrieves the keyValue log for a resource type ID combination. KeyValues may be returned in ascending and descending order.

func (*Client) Generate

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

func (*Client) GetBucketOperationLog

func (c *Client) GetBucketOperationLog(ctx context.Context, id platform.ID, opts platform.FindOptions) ([]*platform.OperationLogEntry, int, error)

GetBucketOperationLog retrieves a buckets operation log.

func (*Client) GetDashboardCellView

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

GetDashboardCellView retrieves the view for a dashboard cell.

func (*Client) GetDashboardOperationLog

func (c *Client) GetDashboardOperationLog(ctx context.Context, id platform.ID, opts platform.FindOptions) ([]*platform.OperationLogEntry, int, error)

GetDashboardOperationLog retrieves a dashboards operation log.

func (*Client) GetOrganizationOperationLog

func (c *Client) GetOrganizationOperationLog(ctx context.Context, id platform.ID, opts platform.FindOptions) ([]*platform.OperationLogEntry, int, error)

GeOrganizationOperationLog retrieves a organization operation log.

func (*Client) GetSecretKeys

func (c *Client) GetSecretKeys(ctx context.Context, orgID platform.ID) ([]string, error)

GetSecretKeys retrieves all secret keys that are stored for the organization orgID.

func (*Client) GetTargetByID

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

GetTargetByID retrieves a scraper target by id.

func (*Client) GetUserOperationLog

func (c *Client) GetUserOperationLog(ctx context.Context, id platform.ID, opts platform.FindOptions) ([]*platform.OperationLogEntry, int, error)

GetUserOperationLog retrieves a user operation log.

func (*Client) IsOnboarding

func (c *Client) IsOnboarding(ctx context.Context) (isOnboarding bool, err error)

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

func (*Client) LastLogEntry

func (c *Client) LastLogEntry(ctx context.Context, k []byte) ([]byte, time.Time, error)

LastLogEntry retrieves the first log entry for a key value log.

func (*Client) ListTargets

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

ListTargets will list all scrape targets.

func (*Client) LoadSecret

func (c *Client) LoadSecret(ctx context.Context, orgID platform.ID, k string) (string, error)

LoadSecret retrieves the secret value v found at key k for organization orgID.

func (*Client) Name

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

Name returns the name for the resource and ID.

func (*Client) Open

func (c *Client) Open(ctx context.Context) error

Open / create boltDB file.

func (*Client) PatchSecrets

func (c *Client) PatchSecrets(ctx context.Context, orgID platform.ID, m map[string]string) error

PatchSecrets patches all provided secrets and updates any previous values.

func (*Client) PutAuthorization

func (c *Client) PutAuthorization(ctx context.Context, a *platform.Authorization) (err error)

PutAuthorization will put a authorization without setting an ID.

func (*Client) PutBucket

func (c *Client) PutBucket(ctx context.Context, b *platform.Bucket) error

PutBucket will put a bucket without setting an ID.

func (*Client) PutDashboard

func (c *Client) PutDashboard(ctx context.Context, d *platform.Dashboard) error

PutDashboard will put a dashboard without setting an ID.

func (*Client) PutOnboardingStatus

func (c *Client) PutOnboardingStatus(ctx context.Context, v bool) error

PutOnboardingStatus will update the flag, so future onboarding request will be denied.

func (*Client) PutOrganization

func (c *Client) PutOrganization(ctx context.Context, o *platform.Organization) error

PutOrganization will put a organization without setting an ID.

func (*Client) PutSecret

func (c *Client) PutSecret(ctx context.Context, orgID platform.ID, k, v string) error

PutSecret stores the secret pair (k,v) for the organization orgID.

func (*Client) PutSecrets

func (c *Client) PutSecrets(ctx context.Context, orgID platform.ID, m map[string]string) error

PutSecrets puts all provided secrets and overwrites any previous values.

func (*Client) PutSession

func (c *Client) PutSession(ctx context.Context, s *platform.Session) error

PutSession puts the session at key.

func (*Client) PutSource

func (c *Client) PutSource(ctx context.Context, s *platform.Source) error

PutSource will put a source without setting an ID.

func (*Client) PutTarget

func (c *Client) PutTarget(ctx context.Context, target *platform.ScraperTarget) error

PutTarget will put a scraper target without setting an ID.

func (*Client) PutTelegrafConfig

func (c *Client) PutTelegrafConfig(ctx context.Context, tc *platform.TelegrafConfig) error

PutTelegrafConfig put a telegraf config to storage.

func (*Client) PutUser

func (c *Client) PutUser(ctx context.Context, u *platform.User) error

PutUser will put a user without setting an ID.

func (*Client) PutView

func (c *Client) PutView(ctx context.Context, d *platform.View) error

PutView will put a view without setting an ID.

func (*Client) RemoveDashboardCell

func (c *Client) RemoveDashboardCell(ctx context.Context, dashboardID, cellID platform.ID) error

RemoveDashboardCell removes a cell from a dashboard.

func (*Client) RemoveTarget

func (c *Client) RemoveTarget(ctx context.Context, id platform.ID) error

RemoveTarget removes a scraper target from the bucket.

func (*Client) ReplaceDashboardCells

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

ReplaceDashboardCells updates the positions of each cell in a dashboard concurrently.

func (*Client) ReplaceMacro

func (c *Client) ReplaceMacro(ctx context.Context, macro *platform.Macro) error

ReplaceMacro puts a macro in the store

func (*Client) SetAuthorizationStatus

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

SetAuthorizationStatus updates the status of the authorization. Useful for setting an authorization to inactive or active.

func (*Client) SetPassword

func (c *Client) SetPassword(ctx context.Context, name string, password string) error

SetPassword stores the password hash associated with a user.

func (*Client) UpdateBucket

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

UpdateBucket updates a bucket according the parameters set on upd.

func (*Client) UpdateDashboard

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

UpdateDashboard updates a dashboard according the parameters set on upd.

func (*Client) UpdateDashboardCell

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

UpdateDashboardCell udpates a cell on a dashboard.

func (*Client) UpdateDashboardCellView

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

UpdateDashboardCellView updates the view for a dashboard cell.

func (*Client) UpdateLabel

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

UpdateLabel updates a label.

func (*Client) UpdateMacro

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

UpdateMacro updates a single macro in the store with a changeset

func (*Client) UpdateOrganization

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

UpdateOrganization updates a organization according the parameters set on upd.

func (*Client) UpdateSource

func (c *Client) UpdateSource(ctx context.Context, id platform.ID, upd platform.SourceUpdate) (*platform.Source, error)

UpdateSource updates a source according the parameters set on upd.

func (*Client) UpdateTarget

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

UpdateTarget updates a scraper target.

func (*Client) UpdateTelegrafConfig

func (c *Client) 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 (*Client) UpdateUser

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

UpdateUser updates a user according the parameters set on upd.

func (*Client) UpdateView

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

UpdateView updates a view according the parameters set on upd.

func (*Client) WithLogger

func (c *Client) WithLogger(l *zap.Logger)

WithLogger sets the logger an a client. It should not be called after the client has been open.

func (*Client) WithTime

func (c *Client) 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 Cursor

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

Cursor is a struct for iterating through the entries in the key value store.

func (*Cursor) First

func (c *Cursor) First() ([]byte, []byte)

First retrieves the first key value pair in the bucket.

func (*Cursor) Last

func (c *Cursor) Last() ([]byte, []byte)

Last retrieves the last key value pair in the bucket.

func (*Cursor) Next

func (c *Cursor) Next() ([]byte, []byte)

Next retrieves the next key in the bucket.

func (*Cursor) Prev

func (c *Cursor) Prev() ([]byte, []byte)

Prev retrieves the previous key in the bucket.

func (*Cursor) Seek

func (c *Cursor) Seek(prefix []byte) ([]byte, []byte)

Seek seeks for the first key that matches the prefix provided.

type KVStore

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

KVStore is a kv.Store backed by boltdb.

func NewKVStore

func NewKVStore(path string) *KVStore

NewKVStore returns an instance of KVStore with the file at the provided path.

func (*KVStore) Close

func (s *KVStore) Close() error

Close the connection to the bolt database

func (*KVStore) Open

func (s *KVStore) Open(ctx context.Context) error

Open creates boltDB file it doesn't exists and opens it otherwise.

func (*KVStore) Update

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

Update opens up an update transaction against the store.

func (*KVStore) View

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

View opens up a view transaction against the store.

func (*KVStore) WithDB

func (s *KVStore) WithDB(db *bolt.DB)

WithDB sets the boltdb on the store.

func (*KVStore) WithLogger

func (s *KVStore) WithLogger(l *zap.Logger)

WithLogger sets the logger on the store.

type Tx

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

Tx is a light wrapper around a boltdb transaction. It implements kv.Tx.

func (*Tx) Bucket

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

Bucket retrieves the bucket named b.

func (*Tx) Context

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

Context returns the context for the transaction.

func (*Tx) WithContext

func (tx *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