appspacemetadb

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthIDExists = errors.New("auth ID (email or dropid) not unique in this appspace")

ErrAuthIDExists is returned when the appspace already has a user with that auth_id string

Functions

This section is empty.

Types

type AppspaceMetaDB

type AppspaceMetaDB struct {
	Config *domain.RuntimeConfig `checkinject:"required"`
	//Validator     domain.Validator
	AppspaceModel interface {
		GetFromID(domain.AppspaceID) (*domain.Appspace, error)
	} `checkinject:"required"`
	AppspaceStatus interface {
		IsLockedClosed(domain.AppspaceID) bool
	} `checkinject:"required"`
	// contains filtered or unexported fields
}

AppspaceMetaDB opens and tracks connections to appspace meta DBs

func (*AppspaceMetaDB) CloseConn

func (mdb *AppspaceMetaDB) CloseConn(appspaceID domain.AppspaceID) error

CloseConn closes the db file and removes connection from conns The expectation is that this is called after the appspace has been confirmed stopped

func (*AppspaceMetaDB) Create

func (mdb *AppspaceMetaDB) Create(appspaceID domain.AppspaceID, dsAPIVersion int) error

Create an apspace meta DB file for an appspace. Should specify schema version or DS API version, and branch accordingly.

func (*AppspaceMetaDB) GetHandle

func (mdb *AppspaceMetaDB) GetHandle(appspaceID domain.AppspaceID) (*sqlx.DB, error)

GetHandle returns the db handle for the appspace

func (*AppspaceMetaDB) Init

func (mdb *AppspaceMetaDB) Init()

Init initializes data structures as needed

type DbConn

type DbConn struct {
	// contains filtered or unexported fields
}

DbConn holds the db handle and relevant request data

func (*DbConn) GetHandle

func (dbc *DbConn) GetHandle() *sqlx.DB

GetHandle returns the DB handle for theis connection

func (*DbConn) RunMigrationStep

func (dbc *DbConn) RunMigrationStep(toVersion int, up bool) error

RunMigrationStep runs a single migration step This is exported but doesn't match the domain.DbConn Interface that is returned above.

type InfoModel

type InfoModel struct {
	AppspaceMetaDB interface {
		GetHandle(domain.AppspaceID) (*sqlx.DB, error)
	} `checkinject:"required"`
}

InfoModel interacts with the info table of appspace meata db

func (*InfoModel) GetAppspaceMetaInfo

func (m *InfoModel) GetAppspaceMetaInfo(dataPath string) (domain.AppspaceMetaInfo, error)

GetAppspaceMetaInfo returns the schema as stored in the appspace meta db at path But this should really return all basic metadata info about the appspace app, version, domain, etc... Or you could return api version (which should also be stored with appspace presumably) .. and then get versioned structs with all info.

func (*InfoModel) GetSchema

func (m *InfoModel) GetSchema(appspaceID domain.AppspaceID) (int, error)

GetSchema returns the schema or 0 if none exists

func (*InfoModel) SetSchema

func (m *InfoModel) SetSchema(appspaceID domain.AppspaceID, schema int) error

SetSchema sets the schema in the info db

type UsersV0

type UsersV0 struct {
	AppspaceMetaDB interface {
		GetHandle(domain.AppspaceID) (*sqlx.DB, error)
	}
}

UsersV0 stores the user's DropIDs

func (*UsersV0) Create

func (u *UsersV0) Create(appspaceID domain.AppspaceID, authType string, authID string) (domain.ProxyID, error)

Create an appspace user with provided auth.

func (*UsersV0) Delete

func (u *UsersV0) Delete(appspaceID domain.AppspaceID, proxyID domain.ProxyID) error

Delete the appspace user Note: need more thought on what it measn to "delete": What happens with the user's data on the appspace?

func (*UsersV0) Get

func (u *UsersV0) Get(appspaceID domain.AppspaceID, proxyID domain.ProxyID) (domain.AppspaceUser, error)

Get returns an AppspaceUser

func (*UsersV0) GetAll

func (u *UsersV0) GetAll(appspaceID domain.AppspaceID) ([]domain.AppspaceUser, error)

GetAll returns an appspace's list of users.

func (*UsersV0) GetByDropID

func (u *UsersV0) GetByDropID(appspaceID domain.AppspaceID, dropID string) (domain.AppspaceUser, error)

GetByDropID returns an appspace that matches the dropid string It returns sql.ErrNoRows if not found

func (*UsersV0) UpdateAuth

func (u *UsersV0) UpdateAuth(appspaceID domain.AppspaceID, proxyID domain.ProxyID, authType string, authID string) error

func (*UsersV0) UpdateMeta

func (u *UsersV0) UpdateMeta(appspaceID domain.AppspaceID, proxyID domain.ProxyID, displayName string, avatar string, permissions []string) error

UpdateMeta updates the appspace-facing data for the user

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL