Documentation ¶
Overview ¶
Package storage provides storage for IC and DAM.
Index ¶
- Constants
- func BuildFilters(str string, fields map[string]func(p proto.Message) string) ([][]Filter, error)
- func ErrNotFound(err error) bool
- func GetHistory(store Store, datatype, realm, user, id string, r *http.Request) (*cpb.History, int, error)
- func MakeConfigHistory(desc, resType string, rev int64, ts float64, r *http.Request, user string, ...) proto.Message
- func MatchProtoFilters(cnfFilters [][]Filter, p proto.Message) bool
- func ReplaceContentVariables(content proto.Message, varValues map[string]string) error
- func UserFragment(user string) string
- type FileStorage
- func (f *FileStorage) Delete(datatype, realm, user, id string, rev int64) error
- func (f *FileStorage) DeleteTx(datatype, realm, user, id string, rev int64, tx Tx) error
- func (f *FileStorage) Exists(datatype, realm, user, id string, rev int64) (bool, error)
- func (f *FileStorage) Info() map[string]string
- func (f *FileStorage) LockTx(lockName string, minFrequency time.Duration, tx Tx) Tx
- func (f *FileStorage) MultiDeleteTx(datatype, realm, user string, tx Tx) error
- func (f *FileStorage) MultiReadTx(datatype, realm, user string, filters [][]Filter, offset, pageSize int, ...) (int, error)
- func (f *FileStorage) Read(datatype, realm, user, id string, rev int64, content proto.Message) error
- func (f *FileStorage) ReadHistory(datatype, realm, user, id string, content *[]proto.Message) error
- func (f *FileStorage) ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx Tx) (ferr error)
- func (f *FileStorage) ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, tx Tx) (ferr error)
- func (f *FileStorage) Tx(update bool) (Tx, error)
- func (f *FileStorage) Wipe(realm string) error
- func (f *FileStorage) Write(datatype, realm, user, id string, rev int64, content proto.Message, ...) error
- func (f *FileStorage) WriteTx(datatype, realm, user, id string, rev int64, content proto.Message, ...) error
- type FileTx
- type Filter
- type MemTx
- type MemoryStorage
- func (m *MemoryStorage) Delete(datatype, realm, user, id string, rev int64) error
- func (m *MemoryStorage) DeleteTx(datatype, realm, user, id string, rev int64, tx Tx) (ferr error)
- func (m *MemoryStorage) Exists(datatype, realm, user, id string, rev int64) (bool, error)
- func (m *MemoryStorage) Info() map[string]string
- func (m *MemoryStorage) LockTx(lockName string, minFrequency time.Duration, tx Tx) Tx
- func (m *MemoryStorage) MultiDeleteTx(datatype, realm, user string, tx Tx) (ferr error)
- func (m *MemoryStorage) MultiReadTx(datatype, realm, user string, filters [][]Filter, offset, pageSize int, ...) (_ int, ferr error)
- func (m *MemoryStorage) Read(datatype, realm, user, id string, rev int64, content proto.Message) error
- func (m *MemoryStorage) ReadHistory(datatype, realm, user, id string, content *[]proto.Message) error
- func (m *MemoryStorage) ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx Tx) (ferr error)
- func (m *MemoryStorage) ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, tx Tx) (ferr error)
- func (m *MemoryStorage) Tx(update bool) (Tx, error)
- func (m *MemoryStorage) Wipe(realm string) error
- func (m *MemoryStorage) Write(datatype, realm, user, id string, rev int64, content proto.Message, ...) error
- func (m *MemoryStorage) WriteTx(datatype, realm, user, id string, rev int64, content proto.Message, ...) (ferr error)
- type StorageCache
- func (s *StorageCache) Backup()
- func (s *StorageCache) DeleteEntity(id string)
- func (s *StorageCache) DeleteHistory(id string)
- func (s *StorageCache) Entities() map[string]proto.Message
- func (s *StorageCache) GetEntity(id string) (proto.Message, bool)
- func (s *StorageCache) GetHistory(id string) ([]proto.Message, bool)
- func (s *StorageCache) PutEntity(id string, msg proto.Message)
- func (s *StorageCache) PutHistory(id string, msg []proto.Message)
- func (s *StorageCache) Restore()
- type Store
- type Tx
Constants ¶
const ( LatestRev = int64(-1) LatestRevName = "latest" HistoryRevName = "history" DefaultRealm = "master" DefaultUser = "" DefaultID = "main" AllRealms = "" AccountDatatype = "account" AccountLookupDatatype = "acct_lookup" CliAuthDatatype = "cli_auth" ClientDatatype = "client" ConfigDatatype = "config" GroupDatatype = "group" GroupMemberDatatype = "member" LockDatatype = "lock" LoginStateDatatype = "login_state" ProcessDataType = "process" PermissionsDatatype = "permissions" SecretsDatatype = "secrets" TokensDatatype = "tokens" PendingDeleteTokenDatatype = "pending_delete_token" ResourceTokenRequestStateDataType = "resource_token_state" RememberedConsentDatatype = "remembered_consent" // StateActive indicates an object is active. StateActive = "ACTIVE" // StateDeleted indicates an object is deleted (can still be referenced by an admin). StateDeleted = "DELETED" // StateDisabled indicates an object is disabled (may be reactived later). StateDisabled = "DISABLED" // DefaultPageSize is the default number of entries returned by a list. DefaultPageSize = 50 // MaxPageSize is the maximum number of entries returned by a list. MaxPageSize = 1000 )
Variables ¶
This section is empty.
Functions ¶
func BuildFilters ¶
BuildFilters creates a set of filters based on an input string. Within the field map, SCIM path names are expected to be lowercase. Example:
BuildFilters(`name.formatted eq "Joe" or name.familyName sw "Smith"`, map[string]func(p proto.Message) string { "name.formatted": func(p proto.Message) string { return myProtoCast(p).Profile.Name }, "name.familyname": func(p proto.Message) string { return myProtoCast(p).Profile.FamilyName }, })
The filters generated by this method can be evaluated with a proto input using MatchProtoFilters(filters, myProto).
func ErrNotFound ¶
func GetHistory ¶
func GetHistory(store Store, datatype, realm, user, id string, r *http.Request) (*cpb.History, int, error)
GetHistory returns a History object based on the input parameters.
func MakeConfigHistory ¶
func MatchProtoFilters ¶
MatchProtoFilters returns true if any of the filter conditions are met (i.e. evaluates a Conjunctive Normal Form (CNF) of this array of filters). Simplified version of: https://tools.ietf.org/html/rfc7644#section-3.4.2.2
func ReplaceContentVariables ¶ added in v0.8.4
ReplaceContentVariables does simple string replacement of variable names to values. If varValues is nil, then it only checks that `content` is JSON.
func UserFragment ¶
Types ¶
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
func NewFileStorage ¶
func NewFileStorage(service, path string) *FileStorage
func (*FileStorage) Delete ¶
func (f *FileStorage) Delete(datatype, realm, user, id string, rev int64) error
Delete a record.
func (*FileStorage) DeleteTx ¶
func (f *FileStorage) DeleteTx(datatype, realm, user, id string, rev int64, tx Tx) error
DeleteTx delete a record with transaction.
func (*FileStorage) Exists ¶
func (f *FileStorage) Exists(datatype, realm, user, id string, rev int64) (bool, error)
func (*FileStorage) Info ¶
func (f *FileStorage) Info() map[string]string
func (*FileStorage) LockTx ¶
LockTx returns a storage-wide lock by the given name. Only one such lock should be requested at a time. If Tx is provided, it must be an update Tx.
func (*FileStorage) MultiDeleteTx ¶
func (f *FileStorage) MultiDeleteTx(datatype, realm, user string, tx Tx) error
MultiDeleteTx deletes all records of a certain data type within a realm.
func (*FileStorage) MultiReadTx ¶
func (f *FileStorage) MultiReadTx(datatype, realm, user string, filters [][]Filter, offset, pageSize int, content map[string]map[string]proto.Message, typ proto.Message, tx Tx) (int, error)
MultiReadTx reads a set of objects matching the input parameters and filters
func (*FileStorage) ReadHistory ¶
func (f *FileStorage) ReadHistory(datatype, realm, user, id string, content *[]proto.Message) error
func (*FileStorage) ReadHistoryTx ¶
func (f *FileStorage) ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx Tx) (ferr error)
ReadHistoryTx reads hisotry inside a transaction.
func (*FileStorage) ReadTx ¶
func (f *FileStorage) ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, tx Tx) (ferr error)
ReadTx reads inside a transaction.
func (*FileStorage) Wipe ¶
func (f *FileStorage) Wipe(realm string) error
Wipe deletes all records within a realm.
type FileTx ¶
type FileTx struct {
// contains filtered or unexported fields
}
func (*FileTx) MakeUpdate ¶ added in v0.8.8
MakeUpdate will upgrade a read-only transaction to an update transaction.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a means to filter which entries are returned from MultiReadTx.
type MemTx ¶
type MemTx struct {
// contains filtered or unexported fields
}
func (*MemTx) MakeUpdate ¶ added in v0.8.8
MakeUpdate will upgrade a read-only transaction to an update transaction.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage is designed as a single threading storage. Will throw exception if multiple TX request.
func NewMemoryStorage ¶
func NewMemoryStorage(service, path string) *MemoryStorage
func (*MemoryStorage) Delete ¶
func (m *MemoryStorage) Delete(datatype, realm, user, id string, rev int64) error
Delete a record.
func (*MemoryStorage) DeleteTx ¶
func (m *MemoryStorage) DeleteTx(datatype, realm, user, id string, rev int64, tx Tx) (ferr error)
DeleteTx delete a record with transaction.
func (*MemoryStorage) Exists ¶
func (m *MemoryStorage) Exists(datatype, realm, user, id string, rev int64) (bool, error)
func (*MemoryStorage) Info ¶
func (m *MemoryStorage) Info() map[string]string
func (*MemoryStorage) LockTx ¶
LockTx returns a storage-wide lock by the given name. Only one such lock should be requested at a time. If Tx is provided, it must be an update Tx.
func (*MemoryStorage) MultiDeleteTx ¶
func (m *MemoryStorage) MultiDeleteTx(datatype, realm, user string, tx Tx) (ferr error)
MultiDeleteTx deletes all records of a certain data type within a realm.
func (*MemoryStorage) MultiReadTx ¶
func (m *MemoryStorage) MultiReadTx(datatype, realm, user string, filters [][]Filter, offset, pageSize int, content map[string]map[string]proto.Message, typ proto.Message, tx Tx) (_ int, ferr error)
MultiReadTx reads a set of objects matching the input parameters and filters
func (*MemoryStorage) ReadHistory ¶
func (m *MemoryStorage) ReadHistory(datatype, realm, user, id string, content *[]proto.Message) error
func (*MemoryStorage) ReadHistoryTx ¶
func (m *MemoryStorage) ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx Tx) (ferr error)
ReadHistoryTx reads history inside a transaction.
func (*MemoryStorage) ReadTx ¶
func (m *MemoryStorage) ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, tx Tx) (ferr error)
ReadTx reads inside a transaction.
func (*MemoryStorage) Wipe ¶
func (m *MemoryStorage) Wipe(realm string) error
type StorageCache ¶
type StorageCache struct {
// contains filtered or unexported fields
}
func NewStorageCache ¶
func NewStorageCache() *StorageCache
func (*StorageCache) Backup ¶
func (s *StorageCache) Backup()
func (*StorageCache) DeleteEntity ¶
func (s *StorageCache) DeleteEntity(id string)
func (*StorageCache) DeleteHistory ¶
func (s *StorageCache) DeleteHistory(id string)
func (*StorageCache) Entities ¶ added in v0.8.6
func (s *StorageCache) Entities() map[string]proto.Message
Entities returns the map of entity names to content.
func (*StorageCache) GetHistory ¶
func (s *StorageCache) GetHistory(id string) ([]proto.Message, bool)
func (*StorageCache) PutHistory ¶
func (s *StorageCache) PutHistory(id string, msg []proto.Message)
func (*StorageCache) Restore ¶
func (s *StorageCache) Restore()
type Store ¶
type Store interface { Info() map[string]string Exists(datatype, realm, user, id string, rev int64) (bool, error) Read(datatype, realm, user, id string, rev int64, content proto.Message) error ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, tx Tx) error // MultiReadTx reads a set of objects matching the input parameters and filters. Returns total count and error. MultiReadTx(datatype, realm, user string, filters [][]Filter, offset, pageSize int, content map[string]map[string]proto.Message, typ proto.Message, tx Tx) (int, error) ReadHistory(datatype, realm, user, id string, content *[]proto.Message) error ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx Tx) error Write(datatype, realm, user, id string, rev int64, content proto.Message, history proto.Message) error WriteTx(datatype, realm, user, id string, rev int64, content proto.Message, history proto.Message, tx Tx) error Delete(datatype, realm, user, id string, rev int64) error DeleteTx(datatype, realm, user, id string, rev int64, tx Tx) error MultiDeleteTx(datatype, realm, user string, tx Tx) error Wipe(realm string) error Tx(update bool) (Tx, error) LockTx(lockName string, minFrequency time.Duration, tx Tx) Tx }
Store is an interface to the storage layer.