Documentation ¶
Overview ¶
A simple kernel service wich provides access to a single github.com/etcd-io/bbolt object store
Index ¶
- type BoltService
- func (s *BoltService) Batch(fn func(*Tx) error) error
- func (s *BoltService) Init(k *kernel.Kernel) error
- func (s *BoltService) Name() string
- func (s *BoltService) PostInit() error
- func (s *BoltService) Start() error
- func (s *BoltService) Stop()
- func (s *BoltService) Update(fn func(*Tx) error) error
- func (s *BoltService) View(fn func(*Tx) error) error
- type Bucket
- func (b *Bucket) Bucket(name string) *Bucket
- func (b *Bucket) CreateBucket(name string) (*Bucket, error)
- func (b *Bucket) CreateBucketIfNotExists(name string) (*Bucket, error)
- func (b *Bucket) Cursor() *Cursor
- func (b *Bucket) Delete(key string) error
- func (b *Bucket) DeleteBucket(name string) error
- func (b *Bucket) ForEach(fn func(k string, v []byte) error) error
- func (b *Bucket) Get(key string) []byte
- func (b *Bucket) GetJSON(key string, val interface{}) bool
- func (b *Bucket) NextSequence() (uint64, error)
- func (b *Bucket) Put(key string, value []byte) error
- func (b *Bucket) PutJSON(key string, value interface{}) error
- func (b *Bucket) Sequence() uint64
- func (b *Bucket) SetSequence(v uint64) error
- func (b *Bucket) Tx() *Tx
- type Cursor
- func (c *Cursor) Bucket() *Bucket
- func (c *Cursor) Delete() error
- func (c *Cursor) First() (key string, value []byte)
- func (c *Cursor) Last() (key string, value []byte)
- func (c *Cursor) Next() (key string, value []byte)
- func (c *Cursor) Prev() (key string, value []byte)
- func (c *Cursor) Seek(seek string) (key string, value []byte)
- type Tx
- func (t *Tx) Bucket(name string) *Bucket
- func (t *Tx) CreateBucket(name string) (*Bucket, error)
- func (t *Tx) CreateBucketIfNotExists(name string) (*Bucket, error)
- func (t *Tx) DeleteBucket(name string) error
- func (t *Tx) ForEach(fn func(k string, v *Bucket) error) error
- func (t *Tx) OnCommit(fn func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoltService ¶
type BoltService struct { FileName string // contains filtered or unexported fields }
func (*BoltService) Batch ¶
func (s *BoltService) Batch(fn func(*Tx) error) error
Batch calls fn as part of a batch. It behaves similar to Update, except:
1. concurrent Batch calls can be combined into a single Bolt transaction.
2. the function passed to Batch may be called multiple times, regardless of whether it returns error or not.
This means that Batch function side effects must be idempotent and take permanent effect only after a successful return is seen in caller.
The maximum batch size and delay can be adjusted with DB.MaxBatchSize and DB.MaxBatchDelay, respectively.
Batch is only useful when there are multiple goroutines calling it.
func (*BoltService) Name ¶
func (s *BoltService) Name() string
func (*BoltService) PostInit ¶
func (s *BoltService) PostInit() error
func (*BoltService) Start ¶
func (s *BoltService) Start() error
func (*BoltService) Stop ¶
func (s *BoltService) Stop()
func (*BoltService) Update ¶
func (s *BoltService) Update(fn func(*Tx) error) error
Update executes a function within the context of a read-write managed transaction. If no error is returned from the function then the transaction is committed. If an error is returned then the entire transaction is rolled back. Any error that is returned from the function or returned from the commit is returned from the Update() method.
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
func (*Bucket) Bucket ¶
Bucket retrieves a nested bucket by name. Returns nil if the bucket does not exist. The bucket instance is only valid for the lifetime of the transaction.
func (*Bucket) CreateBucket ¶
CreateBucket creates a new bucket at the given key and returns the new bucket. Returns an error if the key already exists, if the bucket name is blank, or if the bucket name is too long. The bucket instance is only valid for the lifetime of the transaction.
func (*Bucket) CreateBucketIfNotExists ¶
CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it. Returns an error if the bucket name is blank, or if the bucket name is too long. The bucket instance is only valid for the lifetime of the transaction.
func (*Bucket) Cursor ¶
Cursor creates a cursor associated with the bucket. The cursor is only valid as long as the transaction is open. Do not use a cursor after the transaction is closed.
func (*Bucket) Delete ¶
Delete removes a key from the bucket. If the key does not exist then nothing is done and a nil error is returned. Returns an error if the bucket was created from a read-only transaction.
func (*Bucket) DeleteBucket ¶
DeleteBucket deletes a bucket at the given key. Returns an error if the bucket does not exists, or if the key represents a non-bucket value.
func (*Bucket) ForEach ¶
ForEach executes a function for each key/value pair in a bucket. If the provided function returns an error then the iteration is stopped and the error is returned to the caller. The provided function must not modify the bucket; this will result in undefined behavior.
func (*Bucket) Get ¶
Get retrieves the value for a key in the bucket. Returns a nil value if the key does not exist or if the key is a nested bucket. The returned value is only valid for the life of the transaction.
func (*Bucket) GetJSON ¶
Get retrieves the value for a key in the bucket. Returns a nil value if the key does not exist or if the key is a nested bucket. The returned value is only valid for the life of the transaction.
func (*Bucket) NextSequence ¶
NextSequence returns an autoincrementing integer for the bucket.
func (*Bucket) Put ¶
Put sets the value for a key in the bucket. If the key exist then its previous value will be overwritten. Supplied value must remain valid for the life of the transaction. Returns an error if the bucket was created from a read-only transaction, if the key is blank, if the key is too large, or if the value is too large.
func (*Bucket) PutJSON ¶
Put sets the value for a key in the bucket. If the key exist then its previous value will be overwritten. Supplied value must remain valid for the life of the transaction. Returns an error if the bucket was created from a read-only transaction, if the key is blank, if the key is too large, or if the value is too large.
func (*Bucket) Sequence ¶
Sequence returns the current integer for the bucket without incrementing it.
func (*Bucket) SetSequence ¶
SetSequence updates the sequence number for the bucket.
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
func (*Cursor) Delete ¶
Delete removes the current key/value under the cursor from the bucket. Delete fails if current key/value is a bucket or if the transaction is not writable.
func (*Cursor) First ¶
First moves the cursor to the first item in the bucket and returns its key and value. If the bucket is empty then a nil key and value are returned. The returned key and value are only valid for the life of the transaction.
func (*Cursor) Last ¶
Last moves the cursor to the last item in the bucket and returns its key and value. If the bucket is empty then a nil key and value are returned. The returned key and value are only valid for the life of the transaction.
func (*Cursor) Next ¶
Next moves the cursor to the next item in the bucket and returns its key and value. If the cursor is at the end of the bucket then a nil key and value are returned. The returned key and value are only valid for the life of the transaction.
func (*Cursor) Prev ¶
Prev moves the cursor to the previous item in the bucket and returns its key and value. If the cursor is at the beginning of the bucket then a nil key and value are returned. The returned key and value are only valid for the life of the transaction.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) Bucket ¶
Bucket retrieves a bucket by name. Returns nil if the bucket does not exist. The bucket instance is only valid for the lifetime of the transaction.
func (*Tx) CreateBucket ¶
CreateBucket creates a new bucket. Returns an error if the bucket already exists, if the bucket name is blank, or if the bucket name is too long. The bucket instance is only valid for the lifetime of the transaction.
func (*Tx) CreateBucketIfNotExists ¶
CreateBucketIfNotExists creates a new bucket if it doesn't already exist. Returns an error if the bucket name is blank, or if the bucket name is too long. The bucket instance is only valid for the lifetime of the transaction.
func (*Tx) DeleteBucket ¶
DeleteBucket deletes a bucket. Returns an error if the bucket cannot be found or if the key represents a non-bucket value.