Documentation ¶
Index ¶
- type DB
- type DatabaseLayer
- func (db DatabaseLayer) Clone() DB
- func (db DatabaseLayer) Close()
- func (db DatabaseLayer) Copy() DB
- func (db DatabaseLayer) Devices() DeviceManager
- func (db DatabaseLayer) Migrations() MigrationManager
- func (db DatabaseLayer) Permissions() PermissionManager
- func (db DatabaseLayer) RefreshTokens() RefreshTokenManager
- func (db DatabaseLayer) Users() UserManager
- type Device
- type DeviceManager
- type MigrationInfo
- type MigrationManager
- type Permission
- type PermissionManager
- type RefreshToken
- type RefreshTokenManager
- type User
- type UserLayer
- type UserManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { Clone() DB Copy() DB Close() Users() UserManager RefreshTokens() RefreshTokenManager Permissions() PermissionManager Migrations() MigrationManager Devices() DeviceManager }
DB implementation is what newsletter depends on in case some other db is preferred, all one would have to do is to simply implement the db interface
func GetDbImplementation ¶
GetDbImplementation Returns database implementation of DB interface
type DatabaseLayer ¶
type DatabaseLayer struct {
// contains filtered or unexported fields
}
DatabaseLayer is implementation of DB interface
func (DatabaseLayer) Clone ¶
func (db DatabaseLayer) Clone() DB
Clone works just like Copy, but also reuses the same socket as the original session, in case it had already reserved one due to its consistency guarantees. This behavior ensures that writes performed in the old session are necessarily observed when using the new session, as long as it was a strong or monotonic session. That said, it also means that long operations may cause other goroutines using the original session to wait.
func (DatabaseLayer) Close ¶
func (db DatabaseLayer) Close()
Close terminates the session. It's a runtime error to use a session after it has been closed.
func (DatabaseLayer) Copy ¶
func (db DatabaseLayer) Copy() DB
Copy works just like New, but preserves the exact authentication information from the original session.
func (DatabaseLayer) Devices ¶
func (db DatabaseLayer) Devices() DeviceManager
Devices returns implementation of DeviceManager
func (DatabaseLayer) Migrations ¶
func (db DatabaseLayer) Migrations() MigrationManager
Migrations returns MigrationManager
func (DatabaseLayer) Permissions ¶
func (db DatabaseLayer) Permissions() PermissionManager
Permissions returns PermissionManager
func (DatabaseLayer) RefreshTokens ¶
func (db DatabaseLayer) RefreshTokens() RefreshTokenManager
RefreshTokens returns RefreshTokenManager
type DeviceManager ¶
type DeviceManager interface { Register(token string) error Exists(token string) (bool, error) FindByToken(token string) (*Device, error) }
DeviceManager interface to satisfied for managing devices
func GetDeviceManager ¶
func GetDeviceManager(db *mgo.Database) DeviceManager
GetDeviceManager returns an implementation of DeviceManager
type MigrationInfo ¶
type MigrationInfo struct { Key string `json:"key"` Description string `json:"description"` AppliedAt time.Time `json:"applied_at"` }
MigrationInfo information about migration
type MigrationManager ¶
type MigrationManager interface { MarkApplied(key string, description string) error IsApplied(key string) (bool, error) }
MigrationManager deals with any info related to migration saved to disk
func GetMigrationManager ¶
func GetMigrationManager(db *mgo.Database) MigrationManager
GetMigrationManager returns implementation of MigrationManager
type Permission ¶
Permission struct, key is the unique permission key, description is human readable description of permission
type PermissionManager ¶
type PermissionManager interface { Create(key string, description string) error Exists(key string) (bool, error) List() ([]Permission, error) }
PermissionManager deals with Permission persistence
func GetPermissionManager ¶
func GetPermissionManager(db *mgo.Database) PermissionManager
GetPermissionManager returns an implementation of PermissionManager
type RefreshToken ¶
RefreshToken representation of a Refresh Token
type RefreshTokenManager ¶
type RefreshTokenManager interface { FindOne(token string) (*RefreshToken, error) Add(token string, user string) error List(user string) ([]RefreshToken, error) Delete(token string) error }
RefreshTokenManager deals with persistence of RefreshTokens
func GetRefreshTokenManager ¶
func GetRefreshTokenManager(db *mgo.Database) RefreshTokenManager
GetRefreshTokenManager returns implementation of RefreshTokenManager
type User ¶
type User struct { ID bson.ObjectId `json:"_id" bson:"_id,omitempty"` Email string `json:"email"` Password string `json:"password"` Permissions []string `json:"permissions"` }
User is representation of a user
type UserLayer ¶
type UserLayer struct {
// contains filtered or unexported fields
}
UserLayer is implementation of UserManager interface
func (UserLayer) FindByEmail ¶
FindByEmail given email, returns a User
type UserManager ¶
type UserManager interface { FindByEmail(email string) (*User, error) FindByID(id string) (*User, error) Create(user User) error List() ([]User, error) Update(id string, user User) error }
UserManager deals with anything related to User Persistence
func GetUserManager ¶
func GetUserManager(db *mgo.Database) UserManager
GetUserManager returns implementation of UserManager