Documentation
¶
Index ¶
- func SetServiceDB(db Storer)
- type NopStorage
- func (s *NopStorage) DeleteService(serviceID string) (err error)
- func (s *NopStorage) InsertFromConfig(cfg *api.ConfigFile) error
- func (s *NopStorage) LoadAuthRealm(realmID string) (realm types.AuthRealm, err error)
- func (s *NopStorage) LoadAuthRealmsByType(realmType string) (realms []types.AuthRealm, err error)
- func (s *NopStorage) LoadAuthSessionByID(realmID, sessionID string) (session types.AuthSession, err error)
- func (s *NopStorage) LoadAuthSessionByUser(realmID string, userID id.UserID) (session types.AuthSession, err error)
- func (s *NopStorage) LoadBotOptions(userID id.UserID, roomID id.RoomID) (opts types.BotOptions, err error)
- func (s *NopStorage) LoadMatrixClientConfig(userID id.UserID) (config api.ClientConfig, err error)
- func (s *NopStorage) LoadMatrixClientConfigs() (configs []api.ClientConfig, err error)
- func (s *NopStorage) LoadNextBatch(userID id.UserID) (nextBatch string, err error)
- func (s *NopStorage) LoadService(serviceID string) (service types.Service, err error)
- func (s *NopStorage) LoadServicesByType(serviceType string) (services []types.Service, err error)
- func (s *NopStorage) LoadServicesForUser(serviceUserID id.UserID) (services []types.Service, err error)
- func (s *NopStorage) RemoveAuthSession(realmID string, userID id.UserID) error
- func (s *NopStorage) StoreAuthRealm(realm types.AuthRealm) (old types.AuthRealm, err error)
- func (s *NopStorage) StoreAuthSession(session types.AuthSession) (old types.AuthSession, err error)
- func (s *NopStorage) StoreBotOptions(opts types.BotOptions) (oldOpts types.BotOptions, err error)
- func (s *NopStorage) StoreMatrixClientConfig(config api.ClientConfig) (oldConfig api.ClientConfig, err error)
- func (s *NopStorage) StoreService(service types.Service) (oldService types.Service, err error)
- func (s *NopStorage) UpdateNextBatch(userID id.UserID, nextBatch string) (err error)
- type ServiceDB
- func (d *ServiceDB) DeleteService(serviceID string) (err error)
- func (d *ServiceDB) GetSQLDb() (*sql.DB, string)
- func (d *ServiceDB) InsertFromConfig(cfg *api.ConfigFile) error
- func (d *ServiceDB) LoadAuthRealm(realmID string) (realm types.AuthRealm, err error)
- func (d *ServiceDB) LoadAuthRealmsByType(realmType string) (realms []types.AuthRealm, err error)
- func (d *ServiceDB) LoadAuthSessionByID(realmID, sessionID string) (session types.AuthSession, err error)
- func (d *ServiceDB) LoadAuthSessionByUser(realmID string, userID id.UserID) (session types.AuthSession, err error)
- func (d *ServiceDB) LoadBotOptions(userID id.UserID, roomID id.RoomID) (opts types.BotOptions, err error)
- func (d *ServiceDB) LoadMatrixClientConfig(userID id.UserID) (config api.ClientConfig, err error)
- func (d *ServiceDB) LoadMatrixClientConfigs() (configs []api.ClientConfig, err error)
- func (d *ServiceDB) LoadNextBatch(userID id.UserID) (nextBatch string, err error)
- func (d *ServiceDB) LoadService(serviceID string) (service types.Service, err error)
- func (d *ServiceDB) LoadServicesByType(serviceType string) (services []types.Service, err error)
- func (d *ServiceDB) LoadServicesForUser(serviceUserID id.UserID) (services []types.Service, err error)
- func (d *ServiceDB) RemoveAuthSession(realmID string, userID id.UserID) error
- func (d *ServiceDB) StoreAuthRealm(realm types.AuthRealm) (old types.AuthRealm, err error)
- func (d *ServiceDB) StoreAuthSession(session types.AuthSession) (old types.AuthSession, err error)
- func (d *ServiceDB) StoreBotOptions(opts types.BotOptions) (oldOpts types.BotOptions, err error)
- func (d *ServiceDB) StoreMatrixClientConfig(config api.ClientConfig) (oldConfig api.ClientConfig, err error)
- func (d *ServiceDB) StoreService(service types.Service) (oldService types.Service, err error)
- func (d *ServiceDB) UpdateNextBatch(userID id.UserID, nextBatch string) (err error)
- type Storer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type NopStorage ¶
type NopStorage struct{}
NopStorage nops every store API call. This is intended to be embedded into derived structs in tests
func (*NopStorage) DeleteService ¶
func (s *NopStorage) DeleteService(serviceID string) (err error)
DeleteService NOP
func (*NopStorage) InsertFromConfig ¶
func (s *NopStorage) InsertFromConfig(cfg *api.ConfigFile) error
InsertFromConfig NOP
func (*NopStorage) LoadAuthRealm ¶
func (s *NopStorage) LoadAuthRealm(realmID string) (realm types.AuthRealm, err error)
LoadAuthRealm NOP
func (*NopStorage) LoadAuthRealmsByType ¶
func (s *NopStorage) LoadAuthRealmsByType(realmType string) (realms []types.AuthRealm, err error)
LoadAuthRealmsByType NOP
func (*NopStorage) LoadAuthSessionByID ¶
func (s *NopStorage) LoadAuthSessionByID(realmID, sessionID string) (session types.AuthSession, err error)
LoadAuthSessionByID NOP
func (*NopStorage) LoadAuthSessionByUser ¶
func (s *NopStorage) LoadAuthSessionByUser(realmID string, userID id.UserID) (session types.AuthSession, err error)
LoadAuthSessionByUser NOP
func (*NopStorage) LoadBotOptions ¶
func (s *NopStorage) LoadBotOptions(userID id.UserID, roomID id.RoomID) (opts types.BotOptions, err error)
LoadBotOptions NOP
func (*NopStorage) LoadMatrixClientConfig ¶
func (s *NopStorage) LoadMatrixClientConfig(userID id.UserID) (config api.ClientConfig, err error)
LoadMatrixClientConfig NOP
func (*NopStorage) LoadMatrixClientConfigs ¶
func (s *NopStorage) LoadMatrixClientConfigs() (configs []api.ClientConfig, err error)
LoadMatrixClientConfigs NOP
func (*NopStorage) LoadNextBatch ¶
func (s *NopStorage) LoadNextBatch(userID id.UserID) (nextBatch string, err error)
LoadNextBatch NOP
func (*NopStorage) LoadService ¶
func (s *NopStorage) LoadService(serviceID string) (service types.Service, err error)
LoadService NOP
func (*NopStorage) LoadServicesByType ¶
func (s *NopStorage) LoadServicesByType(serviceType string) (services []types.Service, err error)
LoadServicesByType NOP
func (*NopStorage) LoadServicesForUser ¶
func (s *NopStorage) LoadServicesForUser(serviceUserID id.UserID) (services []types.Service, err error)
LoadServicesForUser NOP
func (*NopStorage) RemoveAuthSession ¶
func (s *NopStorage) RemoveAuthSession(realmID string, userID id.UserID) error
RemoveAuthSession NOP
func (*NopStorage) StoreAuthRealm ¶
StoreAuthRealm NOP
func (*NopStorage) StoreAuthSession ¶
func (s *NopStorage) StoreAuthSession(session types.AuthSession) (old types.AuthSession, err error)
StoreAuthSession NOP
func (*NopStorage) StoreBotOptions ¶
func (s *NopStorage) StoreBotOptions(opts types.BotOptions) (oldOpts types.BotOptions, err error)
StoreBotOptions NOP
func (*NopStorage) StoreMatrixClientConfig ¶
func (s *NopStorage) StoreMatrixClientConfig(config api.ClientConfig) (oldConfig api.ClientConfig, err error)
StoreMatrixClientConfig NOP
func (*NopStorage) StoreService ¶
StoreService NOP
func (*NopStorage) UpdateNextBatch ¶
func (s *NopStorage) UpdateNextBatch(userID id.UserID, nextBatch string) (err error)
UpdateNextBatch NOP
type ServiceDB ¶
type ServiceDB struct {
// contains filtered or unexported fields
}
A ServiceDB stores the configuration for the services
func Open ¶
Open a SQL database to use as a ServiceDB. This will automatically create the necessary database tables if they aren't already present.
func (*ServiceDB) DeleteService ¶
DeleteService deletes the given service from the database.
func (*ServiceDB) GetSQLDb ¶
GetSQLDb retrieves the SQL database instance of a ServiceDB and the dialect it uses (sqlite3 or postgres).
func (*ServiceDB) InsertFromConfig ¶
func (d *ServiceDB) InsertFromConfig(cfg *api.ConfigFile) error
InsertFromConfig inserts entries from the config file into the database. This only really makes sense for in-memory databases.
func (*ServiceDB) LoadAuthRealm ¶
LoadAuthRealm loads an AuthRealm from the database. Returns sql.ErrNoRows if the realm isn't in the database.
func (*ServiceDB) LoadAuthRealmsByType ¶
LoadAuthRealmsByType loads all auth realms with the given type from the database. The realms are ordered based on their realm ID. Returns an empty list if there are no realms with that type.
func (*ServiceDB) LoadAuthSessionByID ¶
func (d *ServiceDB) LoadAuthSessionByID(realmID, sessionID string) (session types.AuthSession, err error)
LoadAuthSessionByID loads an AuthSession from the database based on the given realm and session ID. Returns sql.ErrNoRows if the session isn't in the database.
func (*ServiceDB) LoadAuthSessionByUser ¶
func (d *ServiceDB) LoadAuthSessionByUser(realmID string, userID id.UserID) (session types.AuthSession, err error)
LoadAuthSessionByUser loads an AuthSession from the database based on the given realm and user ID. Returns sql.ErrNoRows if the session isn't in the database.
func (*ServiceDB) LoadBotOptions ¶
func (d *ServiceDB) LoadBotOptions(userID id.UserID, roomID id.RoomID) (opts types.BotOptions, err error)
LoadBotOptions loads bot options from the database. Returns sql.ErrNoRows if the bot options isn't in the database.
func (*ServiceDB) LoadMatrixClientConfig ¶
LoadMatrixClientConfig loads a Matrix client config from the database. Returns sql.ErrNoRows if the client isn't in the database.
func (*ServiceDB) LoadMatrixClientConfigs ¶
func (d *ServiceDB) LoadMatrixClientConfigs() (configs []api.ClientConfig, err error)
LoadMatrixClientConfigs loads all Matrix client configs from the database.
func (*ServiceDB) LoadNextBatch ¶
LoadNextBatch loads the next_batch token for the given user.
func (*ServiceDB) LoadService ¶
LoadService loads a service from the database. Returns sql.ErrNoRows if the service isn't in the database.
func (*ServiceDB) LoadServicesByType ¶
LoadServicesByType loads all the bot services configured for a given type. Returns an empty list if there aren't any services configured.
func (*ServiceDB) LoadServicesForUser ¶
func (d *ServiceDB) LoadServicesForUser(serviceUserID id.UserID) (services []types.Service, err error)
LoadServicesForUser loads all the bot services configured for a given user. Returns an empty list if there aren't any services configured.
func (*ServiceDB) RemoveAuthSession ¶
RemoveAuthSession removes the auth session for the given user on the given realm. No error is returned if the session did not exist in the first place.
func (*ServiceDB) StoreAuthRealm ¶
StoreAuthRealm stores the given AuthRealm, clobbering based on the realm ID. This function updates the time added/updated values. The previous realm, if any, is returned.
func (*ServiceDB) StoreAuthSession ¶
func (d *ServiceDB) StoreAuthSession(session types.AuthSession) (old types.AuthSession, err error)
StoreAuthSession stores the given AuthSession, clobbering based on the tuple of user ID and realm ID. This function updates the time added/updated values. The previous session, if any, is returned.
func (*ServiceDB) StoreBotOptions ¶
func (d *ServiceDB) StoreBotOptions(opts types.BotOptions) (oldOpts types.BotOptions, err error)
StoreBotOptions stores a BotOptions into the database either by inserting a new bot options or updating an existing bot options. Returns the old bot options if there was one.
func (*ServiceDB) StoreMatrixClientConfig ¶
func (d *ServiceDB) StoreMatrixClientConfig(config api.ClientConfig) (oldConfig api.ClientConfig, err error)
StoreMatrixClientConfig stores the Matrix client config for a bot service. If a config already exists then it will be updated, otherwise a new config will be inserted. The previous config is returned.
func (*ServiceDB) StoreService ¶
StoreService stores a service into the database either by inserting a new service or updating an existing service. Returns the old service if there was one.
type Storer ¶
type Storer interface { StoreMatrixClientConfig(config api.ClientConfig) (oldConfig api.ClientConfig, err error) LoadMatrixClientConfigs() (configs []api.ClientConfig, err error) LoadMatrixClientConfig(userID id.UserID) (config api.ClientConfig, err error) UpdateNextBatch(userID id.UserID, nextBatch string) (err error) LoadNextBatch(userID id.UserID) (nextBatch string, err error) LoadService(serviceID string) (service types.Service, err error) DeleteService(serviceID string) (err error) LoadServicesForUser(serviceUserID id.UserID) (services []types.Service, err error) LoadServicesByType(serviceType string) (services []types.Service, err error) StoreService(service types.Service) (oldService types.Service, err error) LoadAuthRealm(realmID string) (realm types.AuthRealm, err error) LoadAuthRealmsByType(realmType string) (realms []types.AuthRealm, err error) StoreAuthRealm(realm types.AuthRealm) (old types.AuthRealm, err error) StoreAuthSession(session types.AuthSession) (old types.AuthSession, err error) LoadAuthSessionByUser(realmID string, userID id.UserID) (session types.AuthSession, err error) LoadAuthSessionByID(realmID, sessionID string) (session types.AuthSession, err error) RemoveAuthSession(realmID string, userID id.UserID) error LoadBotOptions(userID id.UserID, roomID id.RoomID) (opts types.BotOptions, err error) StoreBotOptions(opts types.BotOptions) (oldOpts types.BotOptions, err error) InsertFromConfig(cfg *api.ConfigFile) error }
Storer is the interface which needs to be conformed to in order to persist Go-NEB data