Documentation ¶
Overview ¶
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2017 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func IsNoKeys(e error) bool
- type DBStore
- func (db *DBStore) Close() error
- func (db *DBStore) OpenRead(name string) (io.ReadCloser, error)
- func (db *DBStore) OpenWrite(name string) (WriteCloserCommitter, error)
- func (db *DBStore) ReadAll(name string) ([]byte, error)
- func (db *DBStore) ReadTransaction(txnFunc func(txn Transaction) error) error
- func (db *DBStore) Remove(name string) error
- func (db *DBStore) WriteAll(name string, data []byte) error
- func (db *DBStore) WriteTransaction(txnFunc func(txn Transaction) error) error
- type DBStoreWrite
- type DirFile
- type DirStore
- func (d DirStore) Close() error
- func (d DirStore) CommitFile(name string) error
- func (d DirStore) OpenRead(name string) (io.ReadCloser, error)
- func (d DirStore) OpenWrite(name string) (WriteCloserCommitter, error)
- func (d DirStore) ReadAll(name string) ([]byte, error)
- func (d *DirStore) ReadTransaction(txnFunc func(txn Transaction) error) error
- func (d DirStore) Remove(name string) error
- func (d DirStore) WriteAll(name string, data []byte) error
- func (d *DirStore) WriteTransaction(txnFunc func(txn Transaction) error) error
- type Keystore
- func (k *Keystore) Generate() error
- func (k *Keystore) GetKeyName() string
- func (k *Keystore) GetPrivateKey() *rsa.PrivateKey
- func (k *Keystore) GetStore() Store
- func (k *Keystore) Load() error
- func (k *Keystore) Private() *rsa.PrivateKey
- func (k *Keystore) Public() crypto.PublicKey
- func (k *Keystore) PublicPEM() (string, error)
- func (k *Keystore) Save() error
- func (k *Keystore) Sign(data []byte) ([]byte, error)
- type MemStore
- func (ms *MemStore) Close() error
- func (ms *MemStore) Commit(name string, data []byte) error
- func (ms *MemStore) Disable(disable bool)
- func (ms *MemStore) OpenRead(name string) (io.ReadCloser, error)
- func (ms *MemStore) OpenWrite(name string) (WriteCloserCommitter, error)
- func (ms *MemStore) ReadAll(name string) ([]byte, error)
- func (ms *MemStore) ReadOnly(ro bool)
- func (ms *MemStore) ReadTransaction(txnFunc func(txn Transaction) error) error
- func (ms *MemStore) Remove(name string) error
- func (ms *MemStore) WriteAll(name string, data []byte) error
- func (ms *MemStore) WriteTransaction(txnFunc func(txn Transaction) error) error
- type MemStoreData
- type MemStoreWriter
- type MockStore
- func (ms *MockStore) Close() error
- func (ms *MockStore) OpenRead(name string) (io.ReadCloser, error)
- func (ms *MockStore) OpenWrite(name string) (WriteCloserCommitter, error)
- func (ms *MockStore) ReadAll(name string) ([]byte, error)
- func (ms *MockStore) ReadTransaction(txnFunc func(txn Transaction) error) error
- func (ms *MockStore) Remove(name string) error
- func (ms *MockStore) WriteAll(name string, data []byte) error
- func (ms *MockStore) WriteTransaction(txnFunc func(txn Transaction) error) error
- type Store
- type Transaction
- type WriteCloserCommitter
Constants ¶
const (
DBStoreName = "mender-store"
)
const (
RsaKeyLength = 3072
)
Variables ¶
var (
ErrDBStoreNotInitialized = errors.New("DB store not initialized")
)
var LmdbNoSync bool = false
Can be set by tests to avoid expensive sync'ing.
var NoTransactionSupport error = errors.New("No transaction support in this Store")
Functions ¶
Types ¶
type DBStore ¶
type DBStore struct {
// contains filtered or unexported fields
}
DBStore is an opaque structure representing a database backed storage. Implements `Store` interface.
func NewDBStore ¶
NewDBStore creates an instance of Store backed by LMDB database. DBStore uses a single file for DB data (named `DBStoreName`). Parameter `dirpath` is a directory where the file will be stored. Returns nil if initialization failed.
func (*DBStore) ReadTransaction ¶
func (db *DBStore) ReadTransaction(txnFunc func(txn Transaction) error) error
func (*DBStore) WriteTransaction ¶
func (db *DBStore) WriteTransaction(txnFunc func(txn Transaction) error) error
type DBStoreWrite ¶
type DBStoreWrite struct { io.WriteCloser // contains filtered or unexported fields }
func (*DBStoreWrite) Close ¶
func (dbw *DBStoreWrite) Close() error
func (*DBStoreWrite) Commit ¶
func (dbw *DBStoreWrite) Commit() error
type DirFile ¶
type DirFile struct { io.WriteCloser // contains filtered or unexported fields }
type DirStore ¶
type DirStore struct {
// contains filtered or unexported fields
}
func NewDirStore ¶
func (DirStore) CommitFile ¶
Commit a file from temporary copy to the actual name. Under the hood, does a os.Rename() from a temp file (one with ~ suffix) to the actual name
func (DirStore) OpenRead ¶
func (d DirStore) OpenRead(name string) (io.ReadCloser, error)
Open an entry for reading.
func (DirStore) OpenWrite ¶
func (d DirStore) OpenWrite(name string) (WriteCloserCommitter, error)
Open an entry for writing. Under the hood, opens a temporary file (with 'name~' name) using os.O_WRONLY|os.O_CREAT flags, with default mode 0600. Once writing to temp file is done, the caller should run Commit() method of the WriteCloserCommitter interface.
func (*DirStore) ReadTransaction ¶
func (d *DirStore) ReadTransaction(txnFunc func(txn Transaction) error) error
func (*DirStore) WriteTransaction ¶
func (d *DirStore) WriteTransaction(txnFunc func(txn Transaction) error) error
type Keystore ¶
type Keystore struct {
// contains filtered or unexported fields
}
func NewKeystore ¶
func (*Keystore) GetKeyName ¶
func (*Keystore) GetPrivateKey ¶
func (k *Keystore) GetPrivateKey() *rsa.PrivateKey
func (*Keystore) Private ¶
func (k *Keystore) Private() *rsa.PrivateKey
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
in-memory store for testing purposes
func NewMemStore ¶
func NewMemStore() *MemStore
func (*MemStore) OpenWrite ¶
func (ms *MemStore) OpenWrite(name string) (WriteCloserCommitter, error)
func (*MemStore) ReadTransaction ¶
func (ms *MemStore) ReadTransaction(txnFunc func(txn Transaction) error) error
func (*MemStore) WriteTransaction ¶
func (ms *MemStore) WriteTransaction(txnFunc func(txn Transaction) error) error
type MemStoreData ¶
type MemStoreData struct {
// contains filtered or unexported fields
}
type MemStoreWriter ¶
func (*MemStoreWriter) Close ¶
func (msw *MemStoreWriter) Close() error
func (*MemStoreWriter) Commit ¶
func (msw *MemStoreWriter) Commit() error
type MockStore ¶
func (*MockStore) OpenWrite ¶
func (ms *MockStore) OpenWrite(name string) (WriteCloserCommitter, error)
func (*MockStore) ReadTransaction ¶
func (ms *MockStore) ReadTransaction(txnFunc func(txn Transaction) error) error
func (*MockStore) WriteTransaction ¶
func (ms *MockStore) WriteTransaction(txnFunc func(txn Transaction) error) error
type Store ¶
type Store interface { // Works as a transaction interface as well, which auto-creates a // transaction for each operation. Transaction // open entry 'name' for reading OpenRead(name string) (io.ReadCloser, error) // open entry 'name' for writing, this may create a temporary entry for // writing data, once finished, one should call Commit() from // WriteCloserCommitter interface. OpenWrite(name string) (WriteCloserCommitter, error) // close the store Close() error // Runs the txnFunc function as one transaction by passing the // Transaction object to it. Stores that don't support transactions may // return NoTransactionSupport. Other errors may also be returned by the // txnFunc function, which will ultimately be returned by the // Transaction function. If an error is returned by txnFunc, the // transaction will be aborted instead of committed. WriteTransaction(txnFunc func(txn Transaction) error) error // Same as above, for read transactions. ReadTransaction(txnFunc func(txn Transaction) error) error }
Store is a wrapper for data store exposing a common set of methods. Errors returned by Store methods should preserve semantics of os I/O errors, for instance, OpenRead() on an entry that does not exist shall return os.ErrNotExist
type Transaction ¶
type WriteCloserCommitter ¶
type WriteCloserCommitter interface { io.WriteCloser // commit written data to data store Commit() error }
wrapper for io.WriteCloser with extra Commit() method