Documentation ¶
Overview ¶
Package storage provides field encryption for any driver. The encryption should be enabled using the driver options
Index ¶
- Constants
- type Closer
- type Conn
- type Creater
- type Encrypter
- type HeaderMap
- type Opener
- type Pinger
- type Releaser
- type Reseter
- type StorageDriver
- type Store
- func (s *Store) ClearErrors()
- func (s *Store) Close() error
- func (s *Store) CreateStore() error
- func (s *Store) FetchUserByEmail(domain, email string) (*tenant.User, error)
- func (s *Store) FetchUserByGUID(guid string) (*tenant.User, error)
- func (s *Store) FetchUserByLogin(domain, loginName string) (*tenant.User, error)
- func (s *Store) FetchUserByToken(token string) (*tenant.User, error)
- func (s *Store) GetDriverInterface() gdriver.DriverInterface
- func (s *Store) GetStorageConnector() Conn
- func (s *Store) GetStorageDriver() StorageDriver
- func (s *Store) Id() string
- func (s *Store) IsOpen() bool
- func (s *Store) LastError() error
- func (s *Store) LongHelp() string
- func (s *Store) Open(connect string, extraDriverOptions string) error
- func (s *Store) Ping() error
- func (s *Store) Release() error
- func (s *Store) Reset()
- func (s *Store) SetDriverInterface(x gdriver.DriverInterface)
- func (s *Store) SetLastError(err error) *Store
- func (s *Store) SetStorageDriver(x StorageDriver)
- func (s *Store) ShortHelp() string
- func (s *Store) UserFetch(domain, lookupKey, lookkupValue string) (*tenant.User, error)
- func (s *Store) UserInsert(user *tenant.User) error
- func (s *Store) UserUpdate(user *tenant.User) error
- type Storer
Constants ¶
const ( FieldEmail = `Email` FieldName = `FullName` FieldGUID = `Guid` FieldLogin = `LoginName` FieldToken = `Token` )
These are the names of fields we expect to occur in the database and will pass to database functions when performing UserFetch operations. You may map them in the driver-level routines in order to provide names that are more appropriate to the driver mechanism.
const DriverGroup = "storage"
DriverGroup defines a logical grouping for the drivers
const MatchAnyDomain = "*"
MatchAnyDomain is a special character that should be used to search ALL domains.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Closer ¶
type Closer interface {
Close() error
}
Closer is an optional interface. If this isn't implemented, no error is reported.
type Conn ¶
type Conn interface { UserUpdate(user *tenant.User) error UserInsert(user *tenant.User) error UserFetch(domain, key, value string) (*tenant.User, error) }
Conn has a minimum call set that every driver is required to implement
type Creater ¶
type Creater interface {
CreateStore() error
}
Creater is an optional Storge Creation interface
type HeaderMap ¶
func NewHeaderMap ¶
type Pinger ¶
type Pinger interface {
Ping() error
}
Pinger is an optional database 'ping' interface. This will check the database connection
type Releaser ¶
type Releaser interface {
Release() error
}
Releaser optional interface. This will release any locks/resources that a driver may have set For example, the MySQL will do a SELECT...FOR UPDATE for all of the FetchXXX calls. The release will cause an explicit commit. This, in the code, will be called by a 'defer' call after any fetch/insert operation. For other drivers, it can be ignored or perform any other operation required. Note that SQLITE doesn't do anything at this stage as it isn't really considered a robust, fully hardened storage mechanism. Document-style interfaces will probably not use it either.
type Reseter ¶
type Reseter interface {
Reset()
}
Reseter is an optional interface. This will reset any errors and cleanup any intermediate results
type StorageDriver ¶
StorageDriver interface defines very general, high level operations for retrieval and storage of data. The back-storage can be a flat file, database or document store. The interfaces specify NO sql methods and flatten out operations
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds the state for any storage driver. It allows you to have consistent returns, such as getting the last error, discovering how a connection was made (connectString) or the name of the driver (name)
func (*Store) ClearErrors ¶
func (s *Store) ClearErrors()
ClearErrors simply clears the last stored error
func (*Store) Close ¶
Close the connection to the storage mechanism. If there is no close routine ignore the call
func (*Store) CreateStore ¶
CreateStore , if implemented, initialises any storage. If not implemented, an error will be returned.
func (*Store) FetchUserByEmail ¶
FetchUserByEmail Emails are not unique, except within a domain.
func (*Store) FetchUserByGUID ¶
FetchUserByGUID No domains are required as this is the primary (or unique) key
func (*Store) FetchUserByLogin ¶
FetchUserByLogin Login names are only unique within the domain
func (*Store) FetchUserByToken ¶
FetchUserByToken If the user is not logged in, a 'User not found' error is returned.
func (*Store) GetDriverInterface ¶
func (s *Store) GetDriverInterface() gdriver.DriverInterface
GetDriverInterface is a low level function that replaces the raw storage driver with the driver passed.
func (*Store) GetStorageConnector ¶
GetStorageConnector will return the actual connection to the database for low-level access. This should be avoided unless you are coding for a very non-portable function
func (*Store) GetStorageDriver ¶
func (s *Store) GetStorageDriver() StorageDriver
GetStorageDriver will return the objects storage driver. This is for internal use only
func (*Store) LongHelp ¶
LongHelp will return a long description of the storage driver. It should give a fair amount of detail
func (*Store) Open ¶
Open a connection to the storage mechanism and return both a storage structure and an error status of the open
func (*Store) Ping ¶
Ping will test to see if the storage system is alive. This is an optional routine. If it doesn't exist, a nil return occurs (no error)
func (*Store) SetDriverInterface ¶
func (s *Store) SetDriverInterface(x gdriver.DriverInterface)
SetDriverInterface is a low level function and should never be called. It will force the storage driver to use the passed driver instead of the one defined.
func (*Store) SetLastError ¶
SetLastError will save the last error that occured in this class
func (*Store) SetStorageDriver ¶
func (s *Store) SetStorageDriver(x StorageDriver)
SetStorageDriver will set the higher-level driver to the storagedriver passed.
func (*Store) UserFetch ¶
UserFetch will find a tenant using the domain, a field name and the field value. There will only be one record returned. If you pass MatchAnyDomain as the domain, this will only be valid for a small number of key-types (e.g. enforced unique keys.)
func (*Store) UserInsert ¶
UserInsert will attempt to insert a new 'tenant' record in the datase. It makes sure the database is open and will save any error code that occurs.
type Storer ¶
type Storer interface { // Required wrappers for required StorageDriver functions Open(connect string, extraDriverOptions string) error UserFetch(domain, lookupKey, lookkupValue string) (*tenant.User, error) UserInsert(user *tenant.User) error UserUpdate(user *tenant.User) error // Optional device connection functions CreateStore() error Close() error GetStorageConnector() Conn LastError() error IsOpen() bool Ping() error Release() error Reset() // The following are convienence wrapper functions for the UserXXX functions FetchUserByEmail(domain, email string) (*tenant.User, error) FetchUserByGUID(guid string) (*tenant.User, error) FetchUserByLogin(domain, loginName string) (*tenant.User, error) FetchUserByToken(token string) (*tenant.User, error) // The following are wrappers for the gdriver routines. Id() string ShortHelp() string LongHelp() string // Internal routines SetDriverInterface(x gdriver.DriverInterface) GetDriverInterface() gdriver.DriverInterface SetStorageDriver(x StorageDriver) GetStorageDriver() StorageDriver }
Storer interface gives the set of methods that a storage driver MAY implement. Because some are optional, see the methods for Store for ones that are required.
func GetDefaultDriver ¶
func GetDefaultDriver() Storer
GetDefaultDriver fetches the name of the default driver and then activates the driver
func GetDriver ¶
GetDriver will pick the driver from the map and return a fully initialised storage driver to the caller.
func SetDefault ¶
SetDefault sets the name of the driver that should be the default driver.