Documentation ¶
Index ¶
- Constants
- Variables
- func APIKeyDelete(loggedInUser, uuid string) (err error)
- func APIKeySave(key, loggedInUser string, dateCreated time.Time, expiryDate *time.Time, ...) (uuid string, err error)
- func AddDatabase(loggedInUser, dbOwner, dbName string, createBranch bool, ...) (numBytes int64, newCommitID string, calculatedDbSha string, err error)
- func AddDefaultLicences() (err error)
- func AddDefaultUser() error
- func AddUser(auth0ID, userName, password, email, displayName, avatarURL string) error
- func AnalysisRecordUserStorage(userName string, recordDate time.Time, spaceUsedStandard, spaceUsedLive int64) (err error)
- func AnalysisUsersWithDBs() (userList map[string]int, err error)
- func ApiCallLog(loggedInUser, dbOwner, dbName, operation, callerSw string)
- func AuthorizerLive(d interface{}, action sqlite.Action, ...) sqlite.Auth
- func AuthorizerSelect(d interface{}, action sqlite.Action, ...) sqlite.Auth
- func CacheData(cacheKey string, cacheData interface{}, cacheSeconds int) error
- func CheckDBExists(dbOwner, dbName string) (bool, error)
- func CheckDBID(dbOwner string, dbID int64) (avail bool, dbName string, err error)
- func CheckDBLive(dbOwner, dbName string) (isLive bool, liveNode string, err error)
- func CheckDBPermissions(loggedInUser, dbOwner, dbName string, writeAccess bool) (bool, error)
- func CheckDBStarred(loggedInUser, dbOwner, dbName string) (bool, error)
- func CheckDBWatched(loggedInUser, dbOwner, dbName string) (bool, error)
- func CheckEmailExists(email string) (bool, error)
- func CheckLicenceExists(userName, licenceName string) (exists bool, err error)
- func CheckUnicode(rawInput string, decodeBase64 bool) (str string, err error)
- func CheckUserExists(userName string) (bool, error)
- func ClearCache() (err error)
- func CloseMQChannel(channel *amqp.Channel) (err error)
- func CloseMQConnection(connection *amqp.Connection) (err error)
- func CommitLicenceSHA(dbOwner, dbName, commitID string) (licenceSHA string, err error)
- func CommitPublicFlag(loggedInUser, dbOwner, dbName, commitID string) (public bool, err error)
- func ConnectCache() error
- func ConnectMinio() (err error)
- func ConnectPostgreSQL() (err error)
- func ConnectQueue() (channel *amqp.Channel, err error)
- func CreateCommitID(c CommitEntry) string
- func CreateDBTreeID(entries []DBTreeEntry) string
- func CreateRelease(...) (err error)
- func CreateTag(...) (err error)
- func CypressSeed(w http.ResponseWriter, r *http.Request)
- func DBDetails(DB *SQLiteDBinfo, loggedInUser, dbOwner, dbName, commitID string) (err error)
- func DBStars(dbOwner, dbName string) (starCount int, err error)
- func DBWatchers(dbOwner, dbName string) (watcherCount int, err error)
- func DataValuesMatch(a []DataValue, b []DataValue) (equal bool)
- func DefaultCommit(dbOwner, dbName string) (commitID string, err error)
- func DeleteBranchHistory(dbOwner, dbName, branchName, commitID string) (isolatedTags, isolatedRels []string, err error)
- func DeleteComment(dbOwner, dbName string, discID, comID int) error
- func DeleteDatabase(dbOwner, dbName string) error
- func DeleteLicence(userName, licenceName string) (err error)
- func DisconnectPostgreSQL()
- func DownloadDatabase(w http.ResponseWriter, r *http.Request, ...) (bytesWritten int64, err error)
- func EnvProd(w http.ResponseWriter, r *http.Request)
- func EnvTest(w http.ResponseWriter, r *http.Request)
- func EscapeId(id string) string
- func EscapeIds(ids []string) (escaped []string)
- func EscapeValue(val DataValue) string
- func EscapeValues(vals []DataValue) (escaped []string)
- func FlushViewCount()
- func ForkDatabase(srcOwner, dbName, dstOwner string) (newForkCount int, err error)
- func ForkParent(loggedInUser, dbOwner, dbName string) (parentOwner, parentDBName string, err error)
- func ForkedFrom(dbOwner, dbName string) (forkOwn, forkDB string, forkDel bool, err error)
- func GenerateClientCert(userName string) (_ []byte, err error)
- func GetAPIKeyUser(key string) (user string, err error)
- func GetBranches(dbOwner, dbName string) (branches map[string]BranchEntry, err error)
- func GetCachedData(cacheKey string, cacheData interface{}) (bool, error)
- func GetCommitList(dbOwner, dbName string) (map[string]CommitEntry, error)
- func GetCurrentFunctionName() (FuncName string)
- func GetDatabase(r *http.Request, allowGet bool) (dbName string, err error)
- func GetDefaultBranchName(dbOwner, dbName string) (branchName string, err error)
- func GetDefaultTableName(dbOwner, dbName string) (tableName string, err error)
- func GetDiscussionAndMRCount(dbOwner, dbName string) (discCount, mrCount int, err error)
- func GetFormBranch(r *http.Request) (branch string, err error)
- func GetFormCommit(r *http.Request) (commitID string, err error)
- func GetFormLicence(r *http.Request) (licenceName string, err error)
- func GetFormLive(r *http.Request) (live bool, err error)
- func GetFormODC(r *http.Request) (userName string, dbName string, commitID string, err error)
- func GetFormOwner(r *http.Request, allowGet bool) (dbOwner string, err error)
- func GetFormRelease(r *http.Request) (release string, err error)
- func GetFormSourceURL(r *http.Request) (sourceURL string, err error)
- func GetFormTable(r *http.Request, allowGet bool) (table string, err error)
- func GetFormTag(r *http.Request) (tag string, err error)
- func GetFormUDC(r *http.Request) (userName string, dbName string, commitID string, err error)
- func GetLicence(userName, licenceName string) (txt, format string, err error)
- func GetLicenceInfoFromSha256(userName, sha256 string) (lName, lURL string, err error)
- func GetLicenceSha256FromName(userName, licenceName string) (sha256 string, err error)
- func GetLicences(user string) (map[string]LicenceEntry, error)
- func GetOD(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, err error)
- func GetODC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, commitID string, err error)
- func GetODT(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, err error)
- func GetODTC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, commitID string, ...)
- func GetPrimaryKeyAndOtherColumns(sdb *sqlite.Conn, schema, table string) (pks []string, implicitPk bool, other []string, err error)
- func GetPub(r *http.Request) (public bool, err error)
- func GetReleases(dbOwner, dbName string) (releases map[string]ReleaseEntry, err error)
- func GetSQLiteRowCount(sdb *sqlite.Conn, dbTable string) (rowCount int, err error)
- func GetShares(dbOwner, dbName string) (shares map[string]ShareDatabasePermissions, err error)
- func GetTable(r *http.Request) (requestedTable string, err error)
- func GetTags(dbOwner, dbName string) (tags map[string]TagEntry, err error)
- func GetUFD(r *http.Request, allowGet bool) (userName string, dbFolder string, dbName string, err error)
- func GetUsername(r *http.Request, allowGet bool) (userName string, err error)
- func GetUsernameFromEmail(email string) (userName, avatarURL string, err error)
- func GetViewCount(dbOwner string, dbName string) (count int, err error)
- func GetVisualisations(dbOwner, dbName string) (visualisations map[string]VisParamsV2, err error)
- func HttpErrorLog() *log.Logger
- func IncrementDownloadCount(dbOwner, dbName string) error
- func IncrementViewCount(dbOwner string, dbName string) error
- func InvalidateCacheEntry(loggedInUser string, dbOwner string, dbName string, commitID string) error
- func IsCommitInBranchHistory(dbOwner, dbName, branchName, commitID string) (bool, error)
- func JobQueueCheck()
- func JobQueueCreateDatabase(req JobRequest) (err error)
- func JobQueueErrorString(errCode JobQueueErrorCode) string
- func JobQueueGetSize(DBOwner, DBName string) (size int64, err error)
- func JobQueueListen()
- func JobSubmit[T any](response *T, targetNode, operation, requestingUser, dbOwner, dbName string, ...) (err error)
- func LiveAddDatabasePG(dbOwner, dbName, bucketName, liveNode string, accessType SetAccessType) (err error)
- func LiveBackup(liveNode, loggedInUser, dbOwner, dbName string) (err error)
- func LiveColumns(liveNode, loggedInUser, dbOwner, dbName, table string) (columns []sqlite.Column, pk []string, err error)
- func LiveCreateDB(channel *amqp.Channel, dbOwner, dbName, objectID string) (liveNode string, err error)
- func LiveDelete(liveNode, loggedInUser, dbOwner, dbName string) (err error)
- func LiveExecute(liveNode, loggedInUser, dbOwner, dbName, sql string) (rowsChanged int, err error)
- func LiveGenerateMinioNames(userName string) (bucketName, objectName string, err error)
- func LiveGetMinioNames(loggedInUser, dbOwner, dbName string) (bucketName, objectName string, err error)
- func LiveRetrieveDatabaseMinio(baseDir, dbOwner, dbName, objectID string) (dbPath string, err error)
- func LiveSize(liveNode, loggedInUser, dbOwner, dbName string) (size int64, err error)
- func LiveSqlHistoryAdd(loggedInUser, dbOwner, dbName, stmt string, state SqlHistoryItemStates, ...) (err error)
- func LiveSqlHistoryDeleteOld(loggedInUser, dbOwner, dbName string, keepRecords int) (err error)
- func LiveStoreDatabaseMinio(db *os.File, dbOwner, dbName string, dbSize int64) (minioObjectID string, err error)
- func LiveTables(liveNode, loggedInUser, dbOwner, dbName string) (tables []string, err error)
- func LiveTablesAndViews(liveNode, loggedInUser, dbOwner, dbName string) (list []string, err error)
- func LiveViews(liveNode, loggedInUser, dbOwner, dbName string) (views []string, err error)
- func LogDB4SConnect(userAcc, ipAddr, userAgent string, downloadDate time.Time) error
- func LogDownload(dbOwner, dbName, loggedInUser, ipAddr, serverSw, userAgent string, ...) error
- func LogSQLiteQueryAfter(insertID, memUsed, memHighWater int64) (err error)
- func LogSQLiteQueryBefore(source, dbOwner, dbName, loggedInUser, ipAddr, userAgent, query string) (int64, error)
- func LogUpload(dbOwner, dbName, loggedInUser, ipAddr, serverSw, userAgent string, ...) error
- func MQCreateDBQueue(channel *amqp.Channel) (queue amqp.Queue, err error)
- func MQCreateQueryQueue(channel *amqp.Channel, nodeName string) (queue amqp.Queue, err error)
- func MQCreateResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName, result string) (err error)
- func MQRequest(channel *amqp.Channel, ...) (result []byte, err error)
- func MQResponse(requestType string, msg amqp.Delivery, channel *amqp.Channel, nodeName string, ...) (err error)
- func MemcacheHandle() *memcache.Client
- func Merge(destOwner, destName, destBranch, srcOwner, srcName string, ...) (newCommitID string, err error)
- func MetadataCacheKey(prefix string, loggedInUser string, dbOwner string, dbName string, ...) string
- func MinioDeleteDatabase(source, dbOwner, dbName, bucket, id string) (err error)
- func MinioHandle(bucket, id string) (*minio.Object, error)
- func MinioHandleClose(userDB *minio.Object) (err error)
- func MinioLocation(dbOwner, dbName, commitID, loggedInUser string) (minioBucket, minioID string, lastModified time.Time, err error)
- func NewEvent(details EventDetails) (err error)
- func OpenSQLiteDatabase(bucket, id string) (sdb *sqlite.Conn, err error)
- func OpenSQLiteDatabaseDefensive(w http.ResponseWriter, r *http.Request, ...) (sdb *sqlite.Conn, err error)
- func OpenSQLiteDatabaseLive(baseDir, dbOwner, dbName string) (sdb *sqlite.Conn, err error)
- func PrefUserMaxRows(loggedInUser string) int
- func RandomString(length int) string
- func ReadConfig() (err error)
- func ReadSQLiteDBCSV(sdb *sqlite.Conn, dbTable string) ([][]string, error)
- func RecordWebLogin(userName string) (err error)
- func RemoveLiveDB(dbOwner, dbName string) (err error)
- func RenameDatabase(userName, dbName, newName string) error
- func ReservedUsernamesCheck(userName string) error
- func ResetDB() error
- func ResponseComplete(responseID int) (err error)
- func ResponseQueueCheck()
- func ResponseQueueListen()
- func ResponseSubmit(jobID int, submitterNode string, payload []byte) (err error)
- func RetrieveDatabaseFile(bucket, id string) (newDB string, err error)
- func SQLiteBackupLive(baseDir, dbOwner, dbName string) (err error)
- func SQLiteExecuteQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string) (rowsChanged int, err error)
- func SQLiteGetTablesLive(baseDir, dbOwner, dbName string) (tables []string, err error)
- func SQLiteGetViewsLive(baseDir, dbOwner, dbName string) (views []string, err error)
- func SQLiteSanityCheck(fileName string) (tables []string, err error)
- func SQLiteVersionNumber() int32
- func SanitiseLogString(v string) (result string)
- func SaveDBSettings(userName, dbName, oneLineDesc, fullDesc, defaultTable string, public bool, ...) error
- func SendEmails()
- func SetClientCert(newCert []byte, userName string) error
- func SetUserPreferences(userName string, maxRows int, displayName, email string) error
- func SetUserStatusUpdates(userName string, numUpdates int) error
- func SignalHandler(done *chan struct{})
- func SocialStats(dbOwner, dbName string) (wa, st, fo int, err error)
- func StatusUpdateCheck(dbOwner, dbName string, thisID int, userName string) (numStatusUpdates int, err error)
- func StatusUpdates(loggedInUser string) (statusUpdates map[string][]StatusUpdateEntry, err error)
- func StatusUpdatesLoop()
- func StoreBranches(dbOwner, dbName string, branches map[string]BranchEntry) error
- func StoreComment(dbOwner, dbName, commenter string, discID int, comText string, discClose bool, ...) error
- func StoreCommits(dbOwner, dbName string, commitList map[string]CommitEntry) error
- func StoreDatabase(dbOwner, dbName string, branches map[string]BranchEntry, c CommitEntry, ...) error
- func StoreDatabaseFile(db *os.File, sha string, dbSize int64) error
- func StoreDefaultBranchName(dbOwner, dbName, branchName string) error
- func StoreDefaultTableName(dbOwner, dbName, tableName string) error
- func StoreDiscussion(dbOwner, dbName, loggedInUser, title, text string, discType DiscussionType, ...) (newID int, err error)
- func StoreLicence(userName, licenceName string, txt []byte, url string, orderNum int, ...) error
- func StoreReleases(dbOwner, dbName string, releases map[string]ReleaseEntry) error
- func StoreShares(dbOwner, dbName string, shares map[string]ShareDatabasePermissions) (err error)
- func StoreStatusUpdates(userName string, statusUpdates map[string][]StatusUpdateEntry) error
- func StoreTags(dbOwner, dbName string, tags map[string]TagEntry) error
- func SwitchDefault(w http.ResponseWriter, r *http.Request)
- func SwitchFirst(w http.ResponseWriter, r *http.Request)
- func SwitchSecond(w http.ResponseWriter, r *http.Request)
- func SwitchThird(w http.ResponseWriter, r *http.Request)
- func TableRowsCacheKey(prefix string, loggedInUser string, dbOwner string, dbName string, ...) string
- func Tables(sdb *sqlite.Conn) (tbl []string, err error)
- func TablesAndViews(sdb *sqlite.Conn, dbName string) (list []string, err error)
- func TestLogout(w http.ResponseWriter, r *http.Request)
- func ToggleDBStar(loggedInUser, dbOwner, dbName string) error
- func ToggleDBWatch(loggedInUser, dbOwner, dbName string) error
- func UpdateAvatarURL(userName, avatarURL string) error
- func UpdateComment(dbOwner, dbName, loggedInUser string, discID, comID int, newText string) error
- func UpdateContributorsCount(dbOwner, dbName string) error
- func UpdateDiscussion(dbOwner, dbName, loggedInUser string, discID int, newTitle, newText string) error
- func UpdateMergeRequestCommits(dbOwner, dbName string, discID int, mrCommits []CommitEntry) (err error)
- func UpdateModified(dbOwner, dbName string) (err error)
- func UploadResponse(w http.ResponseWriter, r *http.Request, ...) (retMsg map[string]string, httpStatus int, err error)
- func UserNameFromAuth0ID(auth0id string) (string, error)
- func UserStatusUpdates(userName string) (numUpdates int, err error)
- func ValidateBranchName(fieldName string) error
- func ValidateCommitID(fieldName string) error
- func ValidateDB(dbName string) error
- func ValidateDiscussionTitle(fieldName string) error
- func ValidateDisplayName(dbName string) error
- func ValidateEmail(email string) error
- func ValidateFieldName(fieldName string) error
- func ValidateLicence(licence string) error
- func ValidateLicenceFullName(licence string) error
- func ValidateMarkdown(fieldName string) error
- func ValidatePGTable(table string) error
- func ValidateUser(user string) error
- func ValidateUserDB(user, db string) error
- func ValidateUserDBTable(user, db, table string) error
- func ValidateUserEmail(user, email string) error
- func ValidateVisualisationName(name string) error
- func ViewCount(dbOwner, dbName string) (viewCount int, err error)
- func Views(sdb *sqlite.Conn) (vw []string, err error)
- func VisualisationDeleteParams(dbOwner, dbName, visName string) (err error)
- func VisualisationRename(dbOwner, dbName, visName, visNewName string) (err error)
- func VisualisationSaveData(dbOwner, dbName, commitID, hash string, visData []VisRowV1) (err error)
- func VisualisationSaveParams(dbOwner, dbName, visName string, visParams VisParamsV2) (err error)
- func WaitForResponse[T any](jobID int, resp *T) (err error)
- func WriteDBtoDisk(loggedInUser, dbOwner, dbName string, newDB io.Reader) (numBytes int64, tempDB *os.File, sha string, sTbls []string, err error)
- type APIJSONColumn
- type APIJSONIndex
- type APIJSONIndexColumn
- type APIKey
- type AccessType
- type ActivityRange
- type ActivityRow
- type ActivityStats
- type ApiInfo
- type Auth0Info
- type BranchEntry
- type BranchListResponseContainer
- type CommitData
- type CommitEntry
- type DB4SInfo
- type DBEntry
- type DBInfo
- type DBTree
- type DBTreeEntry
- type DBTreeEntryType
- type DataDiff
- type DataRow
- type DataValue
- type DatabaseName
- type DiffObjectChangeset
- type DiffType
- type Diffs
- type DiscussionCommentEntry
- type DiscussionCommentType
- type DiscussionEntry
- type DiscussionType
- type DiskCacheInfo
- type EnvInfo
- type EventDetails
- type EventProcessingInfo
- type EventType
- type ExecuteResponseContainer
- type FilteringErrorLogWriter
- type ForkEntry
- type ForkType
- type JobQueueErrorCode
- type JobRequest
- type JobRequestRows
- type JobResponseDBColumns
- type JobResponseDBCreate
- type JobResponseDBError
- type JobResponseDBExecute
- type JobResponseDBIndexes
- type JobResponseDBQuery
- type JobResponseDBRows
- type JobResponseDBSize
- type JobResponseDBTables
- type JobResponseDBViews
- type JsonError
- type LicenceEntry
- type LicenceInfo
- type LiveDBColumnsResponse
- type LiveDBErrorResponse
- type LiveDBExecuteResponse
- type LiveDBIndexesResponse
- type LiveDBQueryResponse
- type LiveDBRequest
- type LiveDBResponse
- type LiveDBRowsRequest
- type LiveDBRowsResponse
- type LiveDBSizeResponse
- type LiveDBTablesResponse
- type LiveDBViewsResponse
- type LiveInfo
- type MQInfo
- type MemcacheInfo
- type MergeRequestEntry
- type MergeRequestState
- type MergeStrategy
- type MetadataResponseContainer
- type MinioInfo
- type PGInfo
- type QuerySource
- type ReleaseEntry
- type ResponseInfo
- type ResponseReceivers
- type SQLiteDBinfo
- type SQLiteRecordSet
- func LiveQuery(liveNode, loggedInUser, dbOwner, dbName, query string) (rows SQLiteRecordSet, err error)
- func LiveRowData(liveNode, loggedInUser, dbOwner, dbName string, reqData JobRequestRows) (rowData SQLiteRecordSet, err error)
- func ReadSQLiteDB(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, maxRows, rowOffset int) (SQLiteRecordSet, error)
- func ReadSQLiteDBCols(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, ...) (SQLiteRecordSet, error)
- func SQLiteReadDatabasePage(...) (tables []string, defaultTable string, rowData SQLiteRecordSet, dbSize int64, ...)
- func SQLiteRunQuery(sdb *sqlite.Conn, querySource QuerySource, dbQuery string, ...) (memUsed, memHighWater int64, dataRows SQLiteRecordSet, err error)
- func SQLiteRunQueryDefensive(w http.ResponseWriter, r *http.Request, querySource QuerySource, ...) (SQLiteRecordSet, error)
- func SQLiteRunQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string) (records SQLiteRecordSet, err error)
- type SchemaDiff
- type SetAccessType
- type SetDBType
- type ShareDatabasePermissions
- type ShareDatabasePermissionsOthers
- type ShareDatabasePermissionsUser
- type SigningInfo
- type SqlHistoryItem
- type SqlHistoryItemStates
- type StatusResponseContainer
- type StatusUpdateEntry
- type TagEntry
- type TomlConfig
- type UploadResponseContainer
- type UploadRow
- type UserDetails
- type UserInfo
- type UserInfoSlice
- type UserMgmtInfo
- type ValType
- type VisGetFields
- type VisParamsV2
- type VisRowV1
- type WebInfo
- type WebpageResponseContainer
- type WhereClause
Constants ¶
const ( TODAY ActivityRange = "today" THIS_WEEK = "week" THIS_MONTH = "month" ALL_TIME = "all" )
const ( TREE DBTreeEntryType = "tree" DATABASE = "db" LICENCE = "licence" )
const ( TEXT DiscussionCommentType = "txt" CLOSE = "cls" REOPEN = "rop" )
const ( EVENT_NEW_DISCUSSION EventType = 0 // These are not iota, as it would be seriously bad for these numbers to change EVENT_NEW_MERGE_REQUEST = 1 EVENT_NEW_COMMENT = 2 EVENT_NEW_RELEASE = 3 )
const ( OPEN MergeRequestState = 0 // These are not iota, as it would be seriously bad for these numbers to change CLOSED_WITH_MERGE = 1 CLOSED_WITHOUT_MERGE = 2 )
const DefaultNumDisplayRows = 25
DefaultNumDisplayRows is the number of rows to display by default on the database page
const MaxDatabaseSize = 512
MaxDatabaseSize is the maximum database size accepted for upload (in MB)
const MaxLicenceSize = 1
MaxLicenceSize is the maximum licence size accepted for upload (in MB)
const MinioFolderChars = 6
MinioFolderChars is the number of leading characters of a files' sha256 used as the Minio folder name eg: When set to 6, then "34f4255a737156147fbd0a44323a895d18ade79d4db521564d1b0dbb8764cbbc"
-> Minio folder: "34f425" -> Minio filename: "5a737156147fbd0a44323a895d18ade79d4db521564d1b0dbb8764cbbc"
const SqliteDebug = 0
SqliteDebug displays some SQLite related debugging information (on the backend), when set to a non-0 value
Variables ¶
var ( // JobListenConn is the PG server connection used for receiving PG notifications JobListenConn *pgx.Conn // JobQueueConn is the PG server connection used for submitting and retrieving jobs JobQueueConn *pgpool.Pool // JobQueueDebug tells the daemons whether or not to output debug messages while running job queue code // Mostly useful for development / debugging purposes. 0 means no debug messages, higher values means more verbosity JobQueueDebug = 0 )
var ( // AmqpChan is the AMQP channel handle we use for communication with our AMQP backend AmqpChan *amqp.Channel // UseAMQP switches between running in AMQP mode (true) or job queue server mode (false) UseAMQP = false )
var ( // CheckJobQueue is used by the live daemons for triggering a check of the job queue CheckJobQueue chan struct{} // CheckResponsesQueue is used by the non-live daemons for triggering a check of the job responses queue CheckResponsesQueue chan struct{} // ResponseQueue is used to direct job queue responses back to the appropriate callers ResponseQueue *ResponseReceivers // SubmitterInstance is a random string generated at server start for identification purposes SubmitterInstance string )
var SQLiteFunctions = []function{}/* 139 elements not displayed */
SQLiteFunctions lists the function we allow SQL queries to run
var ( // Validate is used for input validation Validate *valid.Validate )
Functions ¶
func APIKeyDelete ¶ added in v0.0.15
APIKeyDelete deletes an existing API key from the PostgreSQL database
func APIKeySave ¶ added in v0.0.6
func APIKeySave(key, loggedInUser string, dateCreated time.Time, expiryDate *time.Time, comment string) (uuid string, err error)
APIKeySave saves a new API key to the PostgreSQL database
func AddDatabase ¶
func AddDatabase(loggedInUser, dbOwner, dbName string, createBranch bool, branchName, commitID string, accessType SetAccessType, licenceName, commitMsg, sourceURL string, newDB io.Reader, lastModified, commitTime time.Time, authorName, authorEmail, committerName, committerEmail string, otherParents []string, dbSha string) (numBytes int64, newCommitID string, calculatedDbSha string, err error)
AddDatabase is handles database upload processing
func AddDefaultLicences ¶
func AddDefaultLicences() (err error)
AddDefaultLicences adds the default licences to the PostgreSQL database. Generally useful for populating a new database, or adding new entries to an existing one
func AddDefaultUser ¶
func AddDefaultUser() error
AddDefaultUser adds the default user to the system, so the referential integrity of licence user_id 0 works
func AnalysisRecordUserStorage ¶ added in v0.0.15
func AnalysisRecordUserStorage(userName string, recordDate time.Time, spaceUsedStandard, spaceUsedLive int64) (err error)
AnalysisRecordUserStorage adds a record to the backend database containing the amount of storage space used by a user
func AnalysisUsersWithDBs ¶ added in v0.0.15
AnalysisUsersWithDBs returns the list of users with at least one database
func ApiCallLog ¶ added in v0.0.15
func ApiCallLog(loggedInUser, dbOwner, dbName, operation, callerSw string)
ApiCallLog records an API call operation. Database name is optional, as not all API calls operate on a database. If a database name is provided however, then the database owner name *must* also be provided
func AuthorizerLive ¶ added in v0.0.15
func AuthorizerLive(d interface{}, action sqlite.Action, tableName, funcName, dbName, triggerName string) sqlite.Auth
AuthorizerLive is a SQLite authorizer callback intended to allow almost anything. Except for loading extensions, and running pragmas.
func AuthorizerSelect ¶ added in v0.0.6
func AuthorizerSelect(d interface{}, action sqlite.Action, tableName, funcName, dbName, triggerName string) sqlite.Auth
AuthorizerSelect is a SQLite authorizer callback which only allows SELECT queries and their needed sub-operations to run.
func CheckDBExists ¶
CheckDBExists checks if a database exists. It does NOT perform any permission checks. If an error occurred, the true/false value should be ignored, as only the error value is valid
func CheckDBID ¶
CheckDBID checks if a given database ID is available, and returns its name so the caller can determine if it has been renamed. If an error occurs, the true/false value should be ignored, as only the error value is valid
func CheckDBLive ¶ added in v0.0.15
CheckDBLive checks if the given database is a live database
func CheckDBPermissions ¶ added in v0.0.15
CheckDBPermissions checks if a database exists and can be accessed by the given user. If an error occurred, the true/false value should be ignored, as only the error value is valid
func CheckDBStarred ¶
CheckDBStarred check if a database has been starred by a given user. The boolean return value is only valid when err is nil
func CheckDBWatched ¶
CheckDBWatched checks if a database is being watched by a given user. The boolean return value is only valid when err is nil
func CheckEmailExists ¶
CheckEmailExists checks if an email address already exists in our system. Returns true if the email is already in the system, false if not. If an error occurred, the true/false value should be ignored, as only the error value is valid
func CheckLicenceExists ¶ added in v0.0.5
CheckLicenceExists checks if a given licence exists in our system
func CheckUnicode ¶ added in v0.0.6
CheckUnicode checks if a given string is unicode, and safe for using in SQLite queries (eg no SQLite control characters)
func CheckUserExists ¶
CheckUserExists checks if a username already exists in our system. Returns true if the username is already taken, false if not. If an error occurred, the true/false value should be ignored, and only the error return code used
func ClearCache ¶ added in v0.0.15
func ClearCache() (err error)
ClearCache removes all items currently cached by Memcached, so it's like a newly started server
func CloseMQChannel ¶ added in v0.0.15
CloseMQChannel closes an open AMQP channel
func CloseMQConnection ¶ added in v0.0.15
func CloseMQConnection(connection *amqp.Connection) (err error)
CloseMQConnection closes an open AMQP connection
func CommitLicenceSHA ¶
CommitLicenceSHA returns the licence used by the database in a given commit
func CommitPublicFlag ¶ added in v0.0.15
CommitPublicFlag returns the public flag of a given commit
func ConnectMinio ¶
func ConnectMinio() (err error)
ConnectMinio parses the Minio configuration, to ensure it seems workable Note - this doesn't actually open a connection to the Minio server.
func ConnectPostgreSQL ¶
func ConnectPostgreSQL() (err error)
ConnectPostgreSQL creates a connection pool to the PostgreSQL server
func ConnectQueue ¶ added in v0.0.15
ConnectQueue creates the connections to the backend queue server
func CreateCommitID ¶
func CreateCommitID(c CommitEntry) string
CreateCommitID generate a stable SHA256 for a commit
func CreateDBTreeID ¶
func CreateDBTreeID(entries []DBTreeEntry) string
CreateDBTreeID generate the SHA256 for a tree Tree entry structure is: * [ entry type ] [ licence sha256] [ file sha256 ] [ file name ] [ last modified (timestamp) ] [ file size (bytes) ]
func CreateRelease ¶ added in v0.2.1
func CreateRelease(dbOwner, dbName, releaseName, releaseDescription, releaserName, releaserEmail, commitID string) (err error)
CreateRelease is used for creating a release when running tests
func CreateTag ¶ added in v0.2.1
func CreateTag(dbOwner, dbName, tagName, tagDescription, taggerName, taggerEmail, commitID string) (err error)
CreateTag is used for creating a tag when running tests
func CypressSeed ¶ added in v0.0.15
func CypressSeed(w http.ResponseWriter, r *http.Request)
CypressSeed empties the backend database, then adds pre-defined test data (PostgreSQL and Minio)
func DBDetails ¶
func DBDetails(DB *SQLiteDBinfo, loggedInUser, dbOwner, dbName, commitID string) (err error)
DBDetails returns the details for a specific database
func DBWatchers ¶
DBWatchers returns the watchers count for a given database
func DataValuesMatch ¶ added in v0.0.15
DataValuesMatch compares two slices of DataValue objects. It returns true if the two are equal, false otherwise.
func DefaultCommit ¶
DefaultCommit returns the default commit ID for a specific database
func DeleteBranchHistory ¶
func DeleteBranchHistory(dbOwner, dbName, branchName, commitID string) (isolatedTags, isolatedRels []string, err error)
DeleteBranchHistory safely removes the commit history for a branch, from the head of the branch back to (but not including) the specified commit. The new branch head will be at the commit ID specified
func DeleteComment ¶
DeleteComment deletes a specific comment from a discussion
func DeleteDatabase ¶
DeleteDatabase deletes a database from PostgreSQL Note that we leave a stub/placeholder entry for all uploaded databases in PG, so our stats don't miss data over time and so the dependant table data doesn't go weird. We also set the "is_deleted" boolean to true for its entry, so our database query functions know to skip it
func DeleteLicence ¶ added in v0.0.5
DeleteLicence removes a (user supplied) database licence from the system
func DisconnectPostgreSQL ¶
func DisconnectPostgreSQL()
DisconnectPostgreSQL disconnects the PostgreSQL database connections
func DownloadDatabase ¶ added in v0.0.9
func DownloadDatabase(w http.ResponseWriter, r *http.Request, dbOwner, dbName, commitID, loggedInUser, sourceSw string) (bytesWritten int64, err error)
DownloadDatabase returns the SQLite database file to the requester
func EnvProd ¶ added in v0.0.15
func EnvProd(w http.ResponseWriter, r *http.Request)
EnvProd changes the running environment to be "production" NOTE - This route to call this is only available when the server is _started_ in the "test" environment
func EnvTest ¶ added in v0.0.15
func EnvTest(w http.ResponseWriter, r *http.Request)
EnvTest changes the running environment to be "test" NOTE - This route to call this is only available when the server is _started_ in the "test" environment
func EscapeId ¶ added in v0.0.6
EscapeId puts an SQL identifier in quote characters and escapes any quote characters it contains, making it safe for use in SQL queries
func EscapeValue ¶ added in v0.0.6
EscapeValue formats, quotes and escapes a DataValue for use in SQL queries
func EscapeValues ¶ added in v0.0.7
EscapeValues does the same as EscapeValue but for a slice of DataValues
func FlushViewCount ¶
func FlushViewCount()
FlushViewCount periodically flushes the database view count from Memcache to PostgreSQL
func ForkDatabase ¶
ForkDatabase forks the PostgreSQL entry for a SQLite database from one user to another
func ForkParent ¶
ForkParent returns the parent of a database, if there is one (and it's accessible to the logged in user). If no parent was found, the returned Owner/DBName values will be empty strings
func ForkedFrom ¶
ForkedFrom checks if the given database was forked from another, and if so returns that one's owner and database name
func GenerateClientCert ¶
GenerateClientCert generates a new DBHub.io client certificate for the given user
func GetAPIKeyUser ¶ added in v0.0.6
GetAPIKeyUser returns the owner of a given API key. Returns an empty string if the key has no known owner
func GetBranches ¶
func GetBranches(dbOwner, dbName string) (branches map[string]BranchEntry, err error)
GetBranches load the branch heads for a database TODO: It might be better to have the default branch name be returned as part of this list, by indicating in the list TODO which of the branches is the default.
func GetCachedData ¶
GetCachedData retrieves cached data from Memcached
func GetCommitList ¶
func GetCommitList(dbOwner, dbName string) (map[string]CommitEntry, error)
GetCommitList returns the full commit list for a database
func GetCurrentFunctionName ¶
func GetCurrentFunctionName() (FuncName string)
GetCurrentFunctionName returns the name of the function this was called from
func GetDatabase ¶
GetDatabase extracts a database name from GET or POST/PUT data
func GetDefaultBranchName ¶
GetDefaultBranchName returns the default branch name for a database
func GetDefaultTableName ¶
GetDefaultTableName returns the default table name for a database
func GetDiscussionAndMRCount ¶
GetDiscussionAndMRCount returns the discussion and merge request counts for a database TODO: The only reason this function exists atm, is because we're incorrectly caching the discussion and MR data in TODO a way that makes invalidating it correctly hard/impossible. We should redo our memcached approach to solve the TODO issue properly
func GetFormBranch ¶
GetFormBranch return the requested branch name, from get or post data
func GetFormCommit ¶
GetFormCommit returns the requested database commit, from form data
func GetFormLicence ¶
GetFormLicence returns the licence name (if any) present in the form data
func GetFormLive ¶ added in v0.0.15
GetFormLive returns the "live" value (if any) present in the form data
func GetFormODC ¶ added in v0.0.6
GetFormODC returns the database owner, database name, and commit (if any) present in the form data
func GetFormOwner ¶ added in v0.0.6
GetFormOwner returns the database owner present in the GET or POST/PUT data
func GetFormRelease ¶
GetFormRelease returns the requested release name, from get or post data
func GetFormSourceURL ¶
GetFormSourceURL returns the source URL (if any) present in the form data
func GetFormTable ¶ added in v0.0.6
GetFormTable returns the table name present in the GET or POST/PUT data
func GetFormTag ¶
GetFormTag returns the requested tag name, from get or post data
func GetFormUDC ¶
GetFormUDC returns the username, database, and commit (if any) present in the form data
func GetLicence ¶
GetLicence returns the text for a given licence
func GetLicenceInfoFromSha256 ¶
GetLicenceInfoFromSha256 returns the friendly name + licence URL for the licence matching a given sha256 Note - When user defined licence has the same sha256 as a default one we return the user defined licences' friendly name
func GetLicenceSha256FromName ¶
GetLicenceSha256FromName returns the sha256 for a given licence
func GetLicences ¶
func GetLicences(user string) (map[string]LicenceEntry, error)
GetLicences returns the list of licences available to a user
func GetODC ¶
func GetODC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, commitID string, err error)
GetODC returns the requested database owner, database name, and commit revision
func GetODT ¶
func GetODT(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, err error)
GetODT returns the requested database owner, database name, and table name
func GetODTC ¶
func GetODTC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, commitID string, err error)
GetODTC returns the requested database owner, database name, table name, and commit string
func GetPrimaryKeyAndOtherColumns ¶ added in v0.0.7
func GetPrimaryKeyAndOtherColumns(sdb *sqlite.Conn, schema, table string) (pks []string, implicitPk bool, other []string, err error)
GetPrimaryKeyAndOtherColumns figures out the primary key columns and the other columns of a table. The schema and table parameters specify the schema and table names to use. This function returns two arrays: One containing the list of primary key columns in the same order as they are used in the primary key. The other array contains a list of all the other, non-primary key columns. Generated columns are ignored completely. If the primary key exists only implicitly, i.e. it's the rowid column, the implicitPk flag is set to true.
func GetPub ¶
GetPub returns the requested "public" variable, if present in the form data If something goes wrong, it defaults to "false".
func GetReleases ¶
func GetReleases(dbOwner, dbName string) (releases map[string]ReleaseEntry, err error)
GetReleases returns the list of releases for a database
func GetSQLiteRowCount ¶
GetSQLiteRowCount returns the number of rows in a SQLite table.
func GetShares ¶ added in v0.0.15
func GetShares(dbOwner, dbName string) (shares map[string]ShareDatabasePermissions, err error)
GetShares returns a map with all users for which the given database is shared as key and their permissions as value.
func GetUFD ¶
func GetUFD(r *http.Request, allowGet bool) (userName string, dbFolder string, dbName string, err error)
GetUFD returns the username, folder, and database name (if any) present in the form data
func GetUsername ¶
GetUsername returns the username (if any) present in the GET or POST/PUT data
func GetUsernameFromEmail ¶
GetUsernameFromEmail returns the username associated with an email address
func GetViewCount ¶
GetViewCount retrieves the view count in Memcached for a database
func GetVisualisations ¶ added in v0.0.6
func GetVisualisations(dbOwner, dbName string) (visualisations map[string]VisParamsV2, err error)
GetVisualisations returns the saved visualisations for a given database
func HttpErrorLog ¶ added in v0.0.15
HttpErrorLog is used to filter out the copious 'TLS handshake error' messages we're getting
func IncrementDownloadCount ¶
IncrementDownloadCount increments the download count for a database
func IncrementViewCount ¶
IncrementViewCount increments the view counter in Memcached for a database
func InvalidateCacheEntry ¶
func InvalidateCacheEntry(loggedInUser string, dbOwner string, dbName string, commitID string) error
InvalidateCacheEntry invalidate Memcache data for a database entry or entries
func IsCommitInBranchHistory ¶
IsCommitInBranchHistory checks if a given commit ID is in the history of the given branch
func JobQueueCheck ¶ added in v0.0.15
func JobQueueCheck()
JobQueueCheck checks if newly submitted work is available for processing
func JobQueueCreateDatabase ¶ added in v0.0.15
func JobQueueCreateDatabase(req JobRequest) (err error)
JobQueueCreateDatabase creates a database on a live node
func JobQueueErrorString ¶ added in v0.0.15
func JobQueueErrorString(errCode JobQueueErrorCode) string
func JobQueueGetSize ¶ added in v0.0.15
JobQueueGetSize returns the on disk size of a database on a live node
func JobQueueListen ¶ added in v0.0.15
func JobQueueListen()
JobQueueListen listens for database notify events indicating newly submitted jobs
func JobSubmit ¶ added in v0.0.15
func JobSubmit[T any](response *T, targetNode, operation, requestingUser, dbOwner, dbName string, data interface{}) (err error)
JobSubmit submits job details to our PostgreSQL based job queue
func LiveAddDatabasePG ¶ added in v0.0.15
func LiveAddDatabasePG(dbOwner, dbName, bucketName, liveNode string, accessType SetAccessType) (err error)
LiveAddDatabasePG adds the details for a live database to PostgreSQL
func LiveBackup ¶ added in v0.0.15
LiveBackup asks the job queue backend to store the given database back into Minio
func LiveColumns ¶ added in v0.0.15
func LiveColumns(liveNode, loggedInUser, dbOwner, dbName, table string) (columns []sqlite.Column, pk []string, err error)
LiveColumns requests the job queue backend to return a list of all columns of the given table
func LiveCreateDB ¶ added in v0.0.15
func LiveCreateDB(channel *amqp.Channel, dbOwner, dbName, objectID string) (liveNode string, err error)
LiveCreateDB requests the job queue backend create a new live SQLite database
func LiveDelete ¶ added in v0.0.15
LiveDelete asks our job queue backend to delete a database
func LiveExecute ¶ added in v0.0.15
LiveExecute asks our job queue backend to execute a SQL statement on a database
func LiveGenerateMinioNames ¶ added in v0.0.15
LiveGenerateMinioNames generates Minio bucket and object names for a live database
func LiveGetMinioNames ¶ added in v0.0.15
func LiveGetMinioNames(loggedInUser, dbOwner, dbName string) (bucketName, objectName string, err error)
LiveGetMinioNames retrieves the Minio bucket and object names for a live database
func LiveRetrieveDatabaseMinio ¶ added in v0.0.15
func LiveRetrieveDatabaseMinio(baseDir, dbOwner, dbName, objectID string) (dbPath string, err error)
LiveRetrieveDatabaseMinio retrieves a live SQLite database from Minio, and places it on the local filesystem
func LiveSize ¶ added in v0.0.15
LiveSize asks our job queue backend for the file size of a database
func LiveSqlHistoryAdd ¶ added in v0.0.15
func LiveSqlHistoryAdd(loggedInUser, dbOwner, dbName, stmt string, state SqlHistoryItemStates, result interface{}) (err error)
LiveSqlHistoryAdd adds a new record to the history of recently executed SQL statements
func LiveSqlHistoryDeleteOld ¶ added in v0.0.15
LiveSqlHistoryDeleteOld deletes all saved SQL statements in the SQL history table, except for the most recent ones
func LiveStoreDatabaseMinio ¶ added in v0.0.15
func LiveStoreDatabaseMinio(db *os.File, dbOwner, dbName string, dbSize int64) (minioObjectID string, err error)
LiveStoreDatabaseMinio stores a live SQLite database in Minio
func LiveTables ¶ added in v0.0.15
LiveTables asks our job queue backend to provide the list of tables (not including views!) in a database
func LiveTablesAndViews ¶ added in v0.0.15
LiveTablesAndViews asks our job queue backend to provide the list of tables and views in a database
func LiveViews ¶ added in v0.0.15
LiveViews asks our job queue backend to provide the list of views (not including tables!) in a database
func LogDB4SConnect ¶ added in v0.0.6
LogDB4SConnect creates a DB4S default browse list entry
func LogDownload ¶
func LogDownload(dbOwner, dbName, loggedInUser, ipAddr, serverSw, userAgent string, downloadDate time.Time, sha string) error
LogDownload creates a download log entry
func LogSQLiteQueryAfter ¶ added in v0.0.6
LogSQLiteQueryAfter adds memory allocation stats for the execution run of a user supplied SQLite query
func LogSQLiteQueryBefore ¶ added in v0.0.6
func LogSQLiteQueryBefore(source, dbOwner, dbName, loggedInUser, ipAddr, userAgent, query string) (int64, error)
LogSQLiteQueryBefore logs the basic info for a user supplied SQLite query
func LogUpload ¶
func LogUpload(dbOwner, dbName, loggedInUser, ipAddr, serverSw, userAgent string, uploadDate time.Time, sha string) error
LogUpload creates an upload log entry
func MQCreateDBQueue ¶ added in v0.0.15
MQCreateDBQueue creates a queue on the MQ server for "create database" messages
func MQCreateQueryQueue ¶ added in v0.0.15
MQCreateQueryQueue creates a queue on the MQ server for sending database queries to
func MQCreateResponse ¶ added in v0.0.15
func MQCreateResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName, result string) (err error)
MQCreateResponse sends a success/failure response back
func MQRequest ¶ added in v0.0.15
func MQRequest(channel *amqp.Channel, queue, operation, requestingUser, dbOwner, dbName string, data interface{}) (result []byte, err error)
MQRequest is the main function used for sending requests to our AMQP backend
func MQResponse ¶ added in v0.0.15
func MQResponse(requestType string, msg amqp.Delivery, channel *amqp.Channel, nodeName string, responseData interface{}) (err error)
MQResponse sends an AMQP response back to its requester
func MemcacheHandle ¶
MemcacheHandle returns the Memcached handle
func Merge ¶ added in v0.0.15
func Merge(destOwner, destName, destBranch, srcOwner, srcName string, commitDiffList []CommitEntry, message, loggedInUser string) (newCommitID string, err error)
Merge merges the commits in commitDiffList into the destination branch destBranch of the given database
func MetadataCacheKey ¶
func MetadataCacheKey(prefix string, loggedInUser string, dbOwner string, dbName string, commitID string) string
MetadataCacheKey generates a predictable cache key for metadata information
func MinioDeleteDatabase ¶ added in v0.0.15
MinioDeleteDatabase deletes a database file from Minio
func MinioHandle ¶
MinioHandle gets a handle from Minio for a SQLite database object
func MinioHandleClose ¶
func MinioHandleClose(userDB *minio.Object) (err error)
MinioHandleClose closes a Minio object handle. Probably most useful for calling with defer()
func MinioLocation ¶
func MinioLocation(dbOwner, dbName, commitID, loggedInUser string) (minioBucket, minioID string, lastModified time.Time, err error)
MinioLocation returns the Minio bucket and ID for a given database. dbOwner & dbName are from owner/database URL fragment, loggedInUser is the name for the currently logged in user, for access permission check. Use an empty string ("") as the loggedInUser parameter if the true value isn't set or known. If the requested database doesn't exist, or the loggedInUser doesn't have access to it, then an error will be returned
func NewEvent ¶
func NewEvent(details EventDetails) (err error)
NewEvent adds an event entry to PostgreSQL
func OpenSQLiteDatabase ¶ added in v0.0.6
OpenSQLiteDatabase retrieves a SQLite database from Minio, opens it, then returns the connection handle.
func OpenSQLiteDatabaseDefensive ¶ added in v0.0.6
func OpenSQLiteDatabaseDefensive(w http.ResponseWriter, r *http.Request, dbOwner, dbName, commitID, loggedInUser string) (sdb *sqlite.Conn, err error)
OpenSQLiteDatabaseDefensive is similar to OpenSQLiteDatabase(), but opens the database Read Only and implements the recommended defensive precautions for potentially malicious user provided SQL queries: https://www.sqlite.org/security.html
func OpenSQLiteDatabaseLive ¶ added in v0.0.15
OpenSQLiteDatabaseLive is similar to OpenSQLiteDatabase(), but opens the a live SQLite database and implements the recommended defensive precautions for potentially malicious user provided SQL queries: https://www.sqlite.org/security.html TODO: De-duplicate/refactor the common code in this function and OpenSQLiteDatabaseDefensive() above, as they're TODO mostly the same
func PrefUserMaxRows ¶
PrefUserMaxRows returns the user's preference for maximum number of SQLite rows to display.
func RandomString ¶
RandomString generates a random alphanumeric string of the desired length
func ReadSQLiteDBCSV ¶
ReadSQLiteDBCSV is a specialised variation of the ReadSQLiteDB() function, just for our CSV exporting code. It may be merged with that in future.
func RecordWebLogin ¶ added in v0.0.15
RecordWebLogin records the start time of a user login session, for stats purposes
func RemoveLiveDB ¶ added in v0.0.15
RemoveLiveDB deletes a live database from the local node. For example, when the user deletes it from their account. Be aware, it leaves the database owners directory in place, to avoid any potential race condition of trying to delete that directory while other databases in their account are being worked with
func RenameDatabase ¶
RenameDatabase renames a SQLite database
func ReservedUsernamesCheck ¶
ReservedUsernamesCheck checks a username against the list of reserved ones
func ResetDB ¶ added in v0.0.15
func ResetDB() error
ResetDB resets the database to its default state. eg for testing purposes
func ResponseComplete ¶ added in v0.0.15
ResponseComplete marks a response as processed
func ResponseQueueCheck ¶ added in v0.0.15
func ResponseQueueCheck()
ResponseQueueCheck checks if a newly submitted response is available for processing
func ResponseQueueListen ¶ added in v0.0.15
func ResponseQueueListen()
ResponseQueueListen listens for database notify events with responses from the other DBHub.io daemons
func ResponseSubmit ¶ added in v0.0.15
ResponseSubmit adds a response to the job_responses table
func RetrieveDatabaseFile ¶ added in v0.0.6
RetrieveDatabaseFile retrieves a SQLite database file from Minio. If there's a locally cached version already available though, use that
func SQLiteBackupLive ¶ added in v0.0.15
SQLiteBackupLive is used by our job queue backend nodes to refresh a live SQLite database back into Minio
func SQLiteExecuteQueryLive ¶ added in v0.0.15
func SQLiteExecuteQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string) (rowsChanged int, err error)
SQLiteExecuteQueryLive is used by our job queue backend infrastructure to execute a user provided SQLite statement
func SQLiteGetTablesLive ¶ added in v0.0.15
SQLiteGetTablesLive is used by our job queue backend nodes to retrieve the list of tables in a SQLite database
func SQLiteGetViewsLive ¶ added in v0.0.15
SQLiteGetViewsLive is used by our job queue backend nodes to retrieve the list of views in a SQLite database
func SQLiteSanityCheck ¶ added in v0.0.15
SQLiteSanityCheck performs basic sanity checks of an uploaded database.
func SQLiteVersionNumber ¶ added in v0.0.6
func SQLiteVersionNumber() int32
SQLiteVersionNumber returns the version number of the available SQLite library, in 300X00Y format.
func SanitiseLogString ¶ added in v0.0.15
func SaveDBSettings ¶
func SaveDBSettings(userName, dbName, oneLineDesc, fullDesc, defaultTable string, public bool, sourceURL, defaultBranch string) error
SaveDBSettings saves updated database settings to PostgreSQL
func SendEmails ¶
func SendEmails()
SendEmails sends status update emails to people watching databases
func SetClientCert ¶
SetClientCert stores a certificate for a given client
func SetUserPreferences ¶
SetUserPreferences sets the user's preference for maximum number of SQLite rows to display
func SetUserStatusUpdates ¶
SetUserStatusUpdates increments the view counter in Memcached for a database
func SignalHandler ¶ added in v0.0.15
func SignalHandler(done *chan struct{})
SignalHandler is a background goroutine that exists to catch *nix termination signals then shut the daemon down cleanly
func SocialStats ¶
SocialStats returns the latest social stats for a given database
func StatusUpdateCheck ¶
func StatusUpdateCheck(dbOwner, dbName string, thisID int, userName string) (numStatusUpdates int, err error)
StatusUpdateCheck checks if a status update for the user exists for a given discussion or MR, and if so then removes it
func StatusUpdates ¶
func StatusUpdates(loggedInUser string) (statusUpdates map[string][]StatusUpdateEntry, err error)
StatusUpdates returns the list of outstanding status updates for a user
func StatusUpdatesLoop ¶
func StatusUpdatesLoop()
StatusUpdatesLoop periodically generates status updates (alert emails TBD) from the event queue
func StoreBranches ¶
func StoreBranches(dbOwner, dbName string, branches map[string]BranchEntry) error
StoreBranches updates the branches list for a database
func StoreComment ¶
func StoreComment(dbOwner, dbName, commenter string, discID int, comText string, discClose bool, mrState MergeRequestState) error
StoreComment adds a comment to a discussion
func StoreCommits ¶
func StoreCommits(dbOwner, dbName string, commitList map[string]CommitEntry) error
StoreCommits updates the commit list for a database
func StoreDatabase ¶
func StoreDatabase(dbOwner, dbName string, branches map[string]BranchEntry, c CommitEntry, pub bool, buf *os.File, sha string, dbSize int64, oneLineDesc, fullDesc string, createDefBranch bool, branchName, sourceURL string) error
StoreDatabase stores database details in PostgreSQL, and the database data itself in Minio
func StoreDatabaseFile ¶
StoreDatabaseFile stores a database file in Minio
func StoreDefaultBranchName ¶
StoreDefaultBranchName stores the default branch name for a database
func StoreDefaultTableName ¶
StoreDefaultTableName stores the default table name for a database
func StoreDiscussion ¶
func StoreDiscussion(dbOwner, dbName, loggedInUser, title, text string, discType DiscussionType, mr MergeRequestEntry) (newID int, err error)
StoreDiscussion stores a new discussion for a database
func StoreLicence ¶
func StoreLicence(userName, licenceName string, txt []byte, url string, orderNum int, fullName, fileFormat string) error
StoreLicence stores a licence
func StoreReleases ¶
func StoreReleases(dbOwner, dbName string, releases map[string]ReleaseEntry) error
StoreReleases stores the releases for a database
func StoreShares ¶ added in v0.0.15
func StoreShares(dbOwner, dbName string, shares map[string]ShareDatabasePermissions) (err error)
StoreShares stores the shares of a database
func StoreStatusUpdates ¶
func StoreStatusUpdates(userName string, statusUpdates map[string][]StatusUpdateEntry) error
StoreStatusUpdates stores the status updates list for a user
func SwitchDefault ¶ added in v0.0.15
func SwitchDefault(w http.ResponseWriter, r *http.Request)
SwitchDefault changes the logged in user to be the user "default"
func SwitchFirst ¶ added in v0.0.15
func SwitchFirst(w http.ResponseWriter, r *http.Request)
SwitchFirst changes the logged in user to be the test user "first"
func SwitchSecond ¶ added in v0.0.15
func SwitchSecond(w http.ResponseWriter, r *http.Request)
SwitchSecond changes the logged in user to be the test user "second"
func SwitchThird ¶ added in v0.0.15
func SwitchThird(w http.ResponseWriter, r *http.Request)
SwitchThird changes the logged in user to be the test user "third"
func TableRowsCacheKey ¶
func TableRowsCacheKey(prefix string, loggedInUser string, dbOwner string, dbName string, commitID string, dbTable string, rows int) string
TableRowsCacheKey generates a predictable cache key for SQLite row data. ONLY for standard databases
func TablesAndViews ¶ added in v0.0.6
TablesAndViews returns the list of tables and views in the SQLite database.
func TestLogout ¶ added in v0.0.15
func TestLogout(w http.ResponseWriter, r *http.Request)
TestLogout logs out the user for test runs
func ToggleDBStar ¶
ToggleDBStar toggles the starring of a database by a user
func ToggleDBWatch ¶
ToggleDBWatch toggles the watch status of a database by a user
func UpdateAvatarURL ¶
UpdateAvatarURL updates the Avatar URL for a user
func UpdateComment ¶
UpdateComment updates the text for a comment
func UpdateContributorsCount ¶
UpdateContributorsCount updates the contributors count for a database
func UpdateDiscussion ¶
func UpdateDiscussion(dbOwner, dbName, loggedInUser string, discID int, newTitle, newText string) error
UpdateDiscussion updates the text for a discussion
func UpdateMergeRequestCommits ¶
func UpdateMergeRequestCommits(dbOwner, dbName string, discID int, mrCommits []CommitEntry) (err error)
UpdateMergeRequestCommits updates the commit list for a Merge Request
func UpdateModified ¶ added in v0.0.15
UpdateModified is a simple function to change the 'last modified' timestamp for a database to now()
func UploadResponse ¶ added in v0.0.13
func UploadResponse(w http.ResponseWriter, r *http.Request, loggedInUser, targetUser, targetDB, commitID, serverSw string) (retMsg map[string]string, httpStatus int, err error)
UploadResponse validates incoming upload requests from the db4s and api daemons, then processes the upload
func UserNameFromAuth0ID ¶
UserNameFromAuth0ID returns the username for a given Auth0 ID
func UserStatusUpdates ¶
UserStatusUpdates returns the number of status updates outstanding for a user
func ValidateBranchName ¶
ValidateBranchName validates the provided branch, release, or tag name
func ValidateCommitID ¶ added in v0.0.5
ValidateCommitID validates the provided commit ID
func ValidateDiscussionTitle ¶
ValidateDiscussionTitle validates the provided discussion or merge request title
func ValidateDisplayName ¶ added in v0.0.5
ValidateDisplayName validates a provided full name
func ValidateEmail ¶
ValidateEmail validates the provided email address
func ValidateFieldName ¶
ValidateFieldName validates the SQLite field name
func ValidateLicence ¶
ValidateLicence validates the provided licence name (ID)
func ValidateLicenceFullName ¶ added in v0.0.5
ValidateLicenceFullName validate the provided licence full name
func ValidateMarkdown ¶
ValidateMarkdown validates the provided markdown
func ValidatePGTable ¶
ValidatePGTable validates the provided PostgreSQL table name
func ValidateUser ¶
ValidateUser validates the provided username
func ValidateUserDB ¶
ValidateUserDB validates the provided user and database name
func ValidateUserDBTable ¶
ValidateUserDBTable validates the provided user, database, and table name
func ValidateUserEmail ¶
ValidateUserEmail validates the provided username and email address
func ValidateVisualisationName ¶ added in v0.0.15
ValidateVisualisationName validates the provided name of a saved visualisation query
func VisualisationDeleteParams ¶ added in v0.0.6
VisualisationDeleteParams deletes a set of visualisation parameters
func VisualisationRename ¶ added in v0.0.15
VisualisationRename renames an existing saved visualisation
func VisualisationSaveData ¶ added in v0.0.6
VisualisationSaveData saves visualisation result data for later retrieval
func VisualisationSaveParams ¶ added in v0.0.6
func VisualisationSaveParams(dbOwner, dbName, visName string, visParams VisParamsV2) (err error)
VisualisationSaveParams saves a set of visualisation parameters for later retrieval
func WaitForResponse ¶ added in v0.0.15
WaitForResponse waits for the job queue server to provide a response for a given job id
func WriteDBtoDisk ¶ added in v0.0.15
func WriteDBtoDisk(loggedInUser, dbOwner, dbName string, newDB io.Reader) (numBytes int64, tempDB *os.File, sha string, sTbls []string, err error)
WriteDBtoDisk gets an uploaded database file from the user's incoming request, and writes it to a local temporary file
Types ¶
type APIJSONColumn ¶ added in v0.0.6
type APIJSONColumn struct { Cid int `json:"column_id"` Name string `json:"name"` DataType string `json:"data_type"` NotNull bool `json:"not_null"` DfltValue string `json:"default_value"` Pk int `json:"primary_key"` }
APIJSONColumn is a copy of the Column type from github.com/gwenn/gosqlite, but including JSON field name info
type APIJSONIndex ¶ added in v0.0.11
type APIJSONIndex struct { Name string `json:"name"` Table string `json:"table"` Columns []APIJSONIndexColumn `json:"columns"` }
APIJSONIndex holds the details of an index for a SQLite database. It's used by our API for returning index information
func LiveIndexes ¶ added in v0.0.15
func LiveIndexes(liveNode, loggedInUser, dbOwner, dbName string) (indexes []APIJSONIndex, err error)
LiveIndexes asks our job queue backend to provide the list of indexes in a database
func SQLiteGetIndexesLive ¶ added in v0.0.15
func SQLiteGetIndexesLive(baseDir, dbOwner, dbName string) (indexes []APIJSONIndex, err error)
SQLiteGetIndexesLive is used by our job queue backend nodes to retrieve the list of indexes from a SQLite database
type APIJSONIndexColumn ¶ added in v0.0.11
APIJSONIndexColumn holds the details of one column of a SQLite database index. It's used by our API for returning index information
type APIKey ¶ added in v0.0.6
type APIKey struct { Uuid string `json:"uuid"` Key string `json:"key"` DateCreated time.Time `json:"date_created"` ExpiryDate *time.Time `json:"expiry_date"` Comment string `json:"comment"` }
APIKey is an internal structure used for passing around user API keys
func APIKeyGenerate ¶ added in v0.0.15
func APIKeyGenerate(loggedInUser string, expiryDate *time.Time, comment string) (key APIKey, err error)
APIKeyGenerate generates a random API key and saves it in the database
func GetAPIKeys ¶ added in v0.0.6
GetAPIKeys returns the list of API keys for a user
type AccessType ¶
type AccessType int
AccessType is whether a database is private, or public, or both
const ( DB_BOTH AccessType = iota DB_PRIVATE DB_PUBLIC )
type ActivityRange ¶
type ActivityRange string
type ActivityRow ¶
type ActivityStats ¶
type ActivityStats struct { Downloads []ActivityRow Forked []ActivityRow Starred []ActivityRow Uploads []UploadRow Viewed []ActivityRow }
func GetActivityStats ¶
func GetActivityStats() (stats ActivityStats, err error)
GetActivityStats returns the latest activity stats
type ApiInfo ¶ added in v0.0.6
type ApiInfo struct { BaseDir string `toml:"base_dir"` BindAddress string `toml:"bind_address"` Certificate string `toml:"certificate"` CertificateKey string `toml:"certificate_key"` RequestLog string `toml:"request_log"` ServerName string `toml:"server_name"` }
ApiInfo contains configuration info for the API daemon
type BranchEntry ¶
type BranchListResponseContainer ¶ added in v0.0.8
type BranchListResponseContainer struct { Branches map[string]BranchEntry `json:"branches"` DefaultBranch string `json:"default_branch"` }
BranchListResponseContainer holds the response to a client request for the database branch list. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons
func BranchListResponse ¶ added in v0.0.8
func BranchListResponse(dbOwner, dbName string) (list BranchListResponseContainer, err error)
BranchListResponse returns the branch list for a database. It's used by both the DB4S and API daemons, to ensure they return exactly the same data
type CommitData ¶
type CommitData struct { AuthorAvatar string `json:"author_avatar"` AuthorEmail string `json:"author_email"` AuthorName string `json:"author_name"` AuthorUsername string `json:"author_username"` ID string `json:"id"` Parent string `json:"parent"` LicenceChange string `json:"licence_change"` Message string `json:"message"` Timestamp time.Time `json:"timestamp"` }
type CommitEntry ¶
type CommitEntry struct { AuthorEmail string `json:"author_email"` AuthorName string `json:"author_name"` CommitterEmail string `json:"committer_email"` CommitterName string `json:"committer_name"` ID string `json:"id"` Message string `json:"message"` OtherParents []string `json:"other_parents"` Parent string `json:"parent"` Timestamp time.Time `json:"timestamp"` Tree DBTree `json:"tree"` }
func GetCommonAncestorCommits ¶
func GetCommonAncestorCommits(srcOwner, srcDBName, srcBranch, destOwner, destName, destBranch string) (ancestorID string, commitList []CommitEntry, errType int, err error)
GetCommonAncestorCommits determines the common ancestor commit (if any) between a source and destination branch. Returns the commit ID of the ancestor and a slice of the commits between them. If no common ancestor exists, the returned ancestorID will be an empty string. Created for use by our Merge Request functions.
type DB4SInfo ¶
type DB4SInfo struct { CAChain string `toml:"ca_chain"` Certificate string CertificateKey string `toml:"certificate_key"` Debug bool Port int Server string }
DB4SInfo contains configuration info for the DB4S end point daemon
type DBEntry ¶
type DBEntry struct { DateEntry time.Time DBName string Owner string OwnerDisplayName string `json:"display_name"` }
func UserStarredDBs ¶
UserStarredDBs returns the list of databases starred by a user
func UserWatchingDBs ¶
UserWatchingDBs returns the list of databases watched by a user
func UsersStarredDB ¶
UsersStarredDB returns the list of users who starred a database
func UsersWatchingDB ¶
UsersWatchingDB returns the list of users watching a database
type DBInfo ¶
type DBInfo struct { Branch string Branches int BranchList []string Commits int CommitID string Contributors int Database string DateCreated time.Time DBEntry DBTreeEntry DefaultBranch string DefaultTable string Discussions int Downloads int ForkDatabase string ForkDeleted bool ForkOwner string Forks int FullDesc string IsLive bool LastModified time.Time Licence string LicenceURL string LiveNode string MRs int MyStar bool MyWatch bool OneLineDesc string Owner string Public bool RepoModified time.Time Releases int SHA256 string Size int64 SourceURL string Stars int Tables []string Tags int Views int Watchers int }
func LiveUserDBs ¶ added in v0.0.15
func LiveUserDBs(dbOwner string, public AccessType) (list []DBInfo, err error)
LiveUserDBs returns the list of live databases owned by the user
type DBTree ¶
type DBTree struct { ID string `json:"id"` Entries []DBTreeEntry `json:"entries"` }
type DBTreeEntry ¶
type DBTreeEntryType ¶
type DBTreeEntryType string
type DataDiff ¶ added in v0.0.6
type DataDiff struct { ActionType DiffType `json:"action_type"` Sql string `json:"sql,omitempty"` Pk []DataValue `json:"pk"` DataBefore []interface{} `json:"data_before,omitempty"` DataAfter []interface{} `json:"data_after,omitempty"` }
DataDiff stores a single change in the data of a table, i.e. a single new, deleted, or changed row
type DatabaseName ¶ added in v0.0.15
type DiffObjectChangeset ¶ added in v0.0.6
type DiffObjectChangeset struct { ObjectName string `json:"object_name"` ObjectType string `json:"object_type"` Schema *SchemaDiff `json:"schema,omitempty"` Data []DataDiff `json:"data,omitempty"` }
DiffObjectChangeset stores all the differences between two objects in a database, for example two tables. Both Schema and Data are optional and can be nil if there are no respective changes in this object.
type DiffType ¶ added in v0.0.6
type DiffType string
DiffType specifies the type of change in a row or object
type Diffs ¶ added in v0.0.6
type Diffs struct {
Diff []DiffObjectChangeset `json:"diff"`
}
Diffs is able to store all the differences between two databases.
func DBDiff ¶ added in v0.0.15
DBDiff generates the differences between the two database files in dbA and dbB
func Diff ¶ added in v0.0.6
func Diff(ownerA string, nameA string, commitA string, ownerB string, nameB string, commitB string, loggedInUser string, merge MergeStrategy, includeData bool) (Diffs, error)
Diff generates the differences between the two commits commitA and commitB of the two databases specified in the other parameters
type DiscussionCommentEntry ¶
type DiscussionCommentEntry struct { AvatarURL string `json:"avatar_url"` Body string `json:"body"` BodyRendered string `json:"body_rendered"` Commenter string `json:"commenter"` DateCreated time.Time `json:"creation_date"` EntryType DiscussionCommentType `json:"entry_type"` ID int `json:"com_id"` }
func DiscussionComments ¶
func DiscussionComments(dbOwner, dbName string, discID, comID int) (list []DiscussionCommentEntry, err error)
DiscussionComments returns the list of comments for a given discussion If a non-0 comID value is passed, it will only return the details for that specific comment in the discussion. Otherwise it will return a list of all comments for a given discussion Note - This returns a slice instead of a map. We use a slice because it lets us use an ORDER BY clause in the SQL and preserve the returned order (maps don't preserve order). If in future we no longer need to preserve the order, it might be useful to switch to using a map instead since they're often simpler to work with.
type DiscussionCommentType ¶
type DiscussionCommentType string
type DiscussionEntry ¶
type DiscussionEntry struct { AvatarURL string `json:"avatar_url"` Body string `json:"body"` BodyRendered string `json:"body_rendered"` CommentCount int `json:"comment_count"` Creator string `json:"creator"` DateCreated time.Time `json:"creation_date"` ID int `json:"disc_id"` LastModified time.Time `json:"last_modified"` MRDetails MergeRequestEntry `json:"mr_details"` Open bool `json:"open"` Title string `json:"title"` Type DiscussionType `json:"discussion_type"` }
func Discussions ¶
func Discussions(dbOwner, dbName string, discType DiscussionType, discID int) (list []DiscussionEntry, err error)
Discussions returns the list of discussions or MRs for a given database If a non-0 discID value is passed, it will only return the details for that specific discussion/MR. Otherwise, it will return a list of all discussions or MRs for a given database Note - This returns a slice of DiscussionEntry, instead of a map. We use a slice because it lets us use an ORDER
BY clause in the SQL and preserve the returned order (maps don't preserve order). If in future we no longer need to preserve the order, it might be useful to switch to using a map instead since they're often simpler to work with.
type DiscussionType ¶
type DiscussionType int
const ( DISCUSSION DiscussionType = 0 // These are not iota, as it would be seriously bad for these numbers to change MERGE_REQUEST = 1 )
type DiskCacheInfo ¶
type DiskCacheInfo struct {
Directory string
}
DiskCacheInfo contains the path to the root of the local disk cache
type EnvInfo ¶
EnvInfo holds information about the purpose of the running server. eg "is this a production, docker, or development" instance?
type EventDetails ¶
type EventDetails struct { DBName string `json:"database_name"` DiscID int `json:"discussion_id"` ID string `json:"event_id"` Message string `json:"message"` Owner string `json:"database_owner"` Timestamp time.Time `json:"event_timestamp"` Title string `json:"title"` Type EventType `json:"event_type"` URL string `json:"event_url"` UserName string `json:"username"` }
type EventProcessingInfo ¶
type EventProcessingInfo struct { Delay time.Duration `toml:"delay"` EmailQueueProcessingDelay time.Duration `toml:"email_queue_processing_delay"` Smtp2GoKey string `toml:"smtp2go_key"` // The SMTP2GO API key }
EventProcessingInfo hold configuration for the event processing loop
type ExecuteResponseContainer ¶ added in v0.0.15
type ExecuteResponseContainer struct { RowsChanged int `json:"rows_changed"` Status string `json:"status"` }
ExecuteResponseContainer is used by our job queue backend, to return information in response to an Execute() call on a live database. It holds the success/failure status of the remote call, and also the number of rows changed by the Execute() call (if it succeeded)
type FilteringErrorLogWriter ¶ added in v0.0.15
type FilteringErrorLogWriter struct{}
FilteringErrorLogWriter is a custom error logger for our http servers, to filter out the copious 'TLS handshake error' messages we're getting. Very heavily based on: https://github.com/golang/go/issues/26918#issuecomment-974257205
type ForkEntry ¶
type JobQueueErrorCode ¶ added in v0.0.15
type JobQueueErrorCode int
const ( JobQueueNoError JobQueueErrorCode = iota JobQueueRequestedTableNotPresent )
func SQLiteGetColumnsLive ¶ added in v0.0.15
func SQLiteGetColumnsLive(baseDir, dbOwner, dbName, table string) (columns []sqlite.Column, pk []string, err error, errCode JobQueueErrorCode)
SQLiteGetColumnsLive is used by our job queue backend nodes to retrieve the list of columns from a SQLite database
type JobRequest ¶ added in v0.0.15
type JobRequest struct { Operation string `json:"operation"` DBOwner string `json:"dbowner"` DBName string `json:"dbname"` Data interface{} `json:"data,omitempty"` RequestingUser string `json:"requesting_user"` }
JobRequest holds the fields used for sending requests to our job request backend
type JobRequestRows ¶ added in v0.0.15
type JobRequestRows struct { DbTable string `json:"db_table"` SortCol string `json:"sort_col"` SortDir string `json:"sort_dir"` CommitID string `json:"commit_id"` RowOffset int `json:"row_offset"` MaxRows int `json:"max_rows"` }
JobRequestRows holds the data used when making a rows request to our job queue backend
type JobResponseDBColumns ¶ added in v0.0.15
type JobResponseDBColumns struct { Columns []sqlite.Column `json:"columns"` Err string `json:"error"` ErrCode JobQueueErrorCode `json:"error_code"` PkColumns []string `json:"pkColumns"` }
JobResponseDBColumns holds the fields used for receiving column list responses from our job queue backend
type JobResponseDBCreate ¶ added in v0.0.15
JobResponseDBCreate holds the fields used for receiving database creation responses from our job queue backend
type JobResponseDBError ¶ added in v0.0.15
type JobResponseDBError struct {
Err string `json:"error"`
}
JobResponseDBError holds the structure used when our job queue backend only needs to response with an error field (empty or not)
type JobResponseDBExecute ¶ added in v0.0.15
type JobResponseDBExecute struct { Err string `json:"error"` RowsChanged int `json:"rows_changed"` }
JobResponseDBExecute holds the fields used for receiving the database execute response from our job queue backend
type JobResponseDBIndexes ¶ added in v0.0.15
type JobResponseDBIndexes struct { Err string `json:"error"` Indexes []APIJSONIndex `json:"indexes"` }
JobResponseDBIndexes holds the fields used for receiving the database index list from our job queue backend
type JobResponseDBQuery ¶ added in v0.0.15
type JobResponseDBQuery struct { Err string `json:"error"` Results SQLiteRecordSet `json:"results"` }
JobResponseDBQuery holds the fields used for receiving database query results from our job queue backend
type JobResponseDBRows ¶ added in v0.0.15
type JobResponseDBRows struct { DatabaseSize int64 `json:"database_size"` DefaultTable string `json:"default_table"` Err string `json:"error"` RowData SQLiteRecordSet `json:"row_data"` Tables []string `json:"tables"` }
JobResponseDBRows holds the fields used for receiving table row data from our job queue backend
type JobResponseDBSize ¶ added in v0.0.15
JobResponseDBSize holds the fields used for receiving database size responses from our job queue backend
type JobResponseDBTables ¶ added in v0.0.15
JobResponseDBTables holds the fields used for receiving the database table list from our job queue backend
type JobResponseDBViews ¶ added in v0.0.15
JobResponseDBViews holds the fields used for receiving the database views list from our job queue backend
type JsonError ¶ added in v0.0.6
type JsonError struct {
Error string `json:"error"`
}
JsonError holds the details of an error. It's used by our API for returning error information
type LicenceEntry ¶
type LicenceInfo ¶ added in v0.0.5
type LicenceInfo struct {
LicenceDir string `toml:"licence_dir"`
}
LicenceInfo -> LicenceDir holds the path to the licence files
type LiveDBColumnsResponse ¶ added in v0.0.15
type LiveDBColumnsResponse struct { Node string `json:"node"` Columns []sqlite.Column `json:"columns"` PkColumns []string `json:"pkColuns"` Error string `json:"error"` ErrCode JobQueueErrorCode `json:"error_code"` }
LiveDBColumnsResponse holds the fields used for receiving column list responses from our AMQP backend
type LiveDBErrorResponse ¶ added in v0.0.15
LiveDBErrorResponse holds just the node name and any error message used in responses by our AMQP backend It's useful for error message, and other responses where no other fields are needed
type LiveDBExecuteResponse ¶ added in v0.0.15
type LiveDBExecuteResponse struct { Node string `json:"node"` RowsChanged int `json:"rows_changed"` Error string `json:"error"` }
LiveDBExecuteResponse returns the number of rows changed by an Execute() call
type LiveDBIndexesResponse ¶ added in v0.0.15
type LiveDBIndexesResponse struct { Node string `json:"node"` Indexes []APIJSONIndex `json:"indexes"` Error string `json:"error"` }
LiveDBIndexesResponse holds the fields used for receiving index list responses from our AMQP backend
type LiveDBQueryResponse ¶ added in v0.0.15
type LiveDBQueryResponse struct { Node string `json:"node"` Results SQLiteRecordSet `json:"results"` Error string `json:"error"` }
LiveDBQueryResponse holds the fields used for receiving query responses from our AMQP backend
type LiveDBRequest ¶ added in v0.0.15
type LiveDBRequest struct { Operation string `json:"operation"` DBOwner string `json:"dbowner"` DBName string `json:"dbname"` Data interface{} `json:"data,omitempty"` RequestingUser string `json:"requesting_user"` }
LiveDBRequest holds the fields used for sending requests to our AMQP backend
type LiveDBResponse ¶ added in v0.0.15
type LiveDBResponse struct { Node string `json:"node"` Result string `json:"result"` Error string `json:"error"` }
LiveDBResponse holds the fields used for receiving (non-query) responses from our AMQP backend
type LiveDBRowsRequest ¶ added in v0.0.15
type LiveDBRowsRequest struct { DbTable string `json:"db_table"` SortCol string `json:"sort_col"` SortDir string `json:"sort_dir"` CommitID string `json:"commit_id"` RowOffset int `json:"row_offset"` MaxRows int `json:"max_rows"` }
LiveDBRowsRequest holds the data used when making an AMQP rows request
type LiveDBRowsResponse ¶ added in v0.0.15
type LiveDBRowsResponse struct { Node string `json:"node"` DatabaseSize int64 `json:"database_size"` DefaultTable string `json:"default_table"` Error string `json:"error"` RowData SQLiteRecordSet `json:"row_data"` Tables []string `json:"tables"` }
LiveDBRowsResponse holds the fields used for receiving database page row responses from our AMQP backend
type LiveDBSizeResponse ¶ added in v0.0.15
type LiveDBSizeResponse struct { Node string `json:"node"` Size int64 `json:"size"` Error string `json:"error"` }
LiveDBSizeResponse holds the fields used for receiving database size responses from our AMQP backend
type LiveDBTablesResponse ¶ added in v0.0.15
type LiveDBTablesResponse struct { Node string `json:"node"` Tables []string `json:"tables"` Error string `json:"error"` }
LiveDBTablesResponse holds the fields used for receiving table list responses from our AMQP backend
type LiveDBViewsResponse ¶ added in v0.0.15
type LiveDBViewsResponse struct { Node string `json:"node"` Views []string `json:"views"` Error string `json:"error"` }
LiveDBViewsResponse holds the fields used for receiving view list responses from our AMQP backend
type MemcacheInfo ¶
type MemcacheInfo struct { DefaultCacheTime int `toml:"default_cache_time"` Server string `toml:"server"` ViewCountFlushDelay time.Duration `toml:"view_count_flush_delay"` }
MemcacheInfo contains the Memcached configuration parameters
type MergeRequestEntry ¶
type MergeRequestEntry struct { Commits []CommitEntry `json:"commits"` DestBranch string `json:"destination_branch"` SourceBranch string `json:"source_branch"` SourceDBID int64 `json:"source_database_id"` SourceDBName string `json:"source_database_name"` SourceOwner string `json:"source_owner"` State MergeRequestState `json:"state"` }
type MergeRequestState ¶
type MergeRequestState int
type MergeStrategy ¶ added in v0.0.7
type MergeStrategy int
MergeStrategy specifies the type of SQL statements included in the diff results. The SQL statements can be used for merging databases and depending on whether and how you want to merge you should choose your merge strategy.
const ( // NoMerge removes any SQL statements for merging from the diff results NoMerge MergeStrategy = iota // PreservePkMerge produces SQL statements which preserve the values of the primary key columns. // Executing these statements on the first database produces a database similar to the second. PreservePkMerge // NewPkMerge produces SQL statements which generate new values for the primary key columns when // executed. This avoids a couple of possible conflicts and allows merging more distant databases. NewPkMerge )
type MetadataResponseContainer ¶ added in v0.0.8
type MetadataResponseContainer struct { Branches map[string]BranchEntry `json:"branches"` Commits map[string]CommitEntry `json:"commits"` DefBranch string `json:"default_branch"` Releases map[string]ReleaseEntry `json:"releases"` Tags map[string]TagEntry `json:"tags"` WebPage string `json:"web_page"` }
MetadataResponseContainer holds the response to a client request for database metadata. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons
func MetadataResponse ¶ added in v0.0.8
func MetadataResponse(dbOwner, dbName string) (meta MetadataResponseContainer, err error)
MetadataResponse returns the metadata for a database. It's used by both the DB4S and API daemons, to ensure they return exactly the same data
type MinioInfo ¶
type MinioInfo struct { AccessKey string `toml:"access_key"` HTTPS bool Secret string Server string }
MinioInfo contains the Minio connection parameters
type PGInfo ¶
type PGInfo struct { Database string NumConnections int `toml:"num_connections"` Port int Password string Server string SSL bool Username string }
PGInfo contains the PostgreSQL connection parameters
type QuerySource ¶ added in v0.0.6
type QuerySource int
QuerySource is used internally to help choose the output format from a SQL query
const ( QuerySourceDB4S QuerySource = iota QuerySourceVisualisation QuerySourceAPI QuerySourceInternal )
type ReleaseEntry ¶
type ResponseInfo ¶ added in v0.0.15
type ResponseInfo struct {
// contains filtered or unexported fields
}
ResponseInfo holds job queue responses. Most of the useful info is json encoded in the payload field
type ResponseReceivers ¶ added in v0.0.15
ResponseReceivers is a simple structure used for matching up job queue responses to the caller who submitted the job
func NewResponseQueue ¶ added in v0.0.15
func NewResponseQueue() *ResponseReceivers
NewResponseQueue is the constructor function for creating a new ResponseReceivers
func (*ResponseReceivers) AddReceiver ¶ added in v0.0.15
func (r *ResponseReceivers) AddReceiver(jobID int, newReceiver *chan ResponseInfo)
AddReceiver adds a new response receiver
func (*ResponseReceivers) RemoveReceiver ¶ added in v0.0.15
func (r *ResponseReceivers) RemoveReceiver(jobID int)
RemoveReceiver removes a response receiver (generally after it has received the response it was waiting for)
type SQLiteDBinfo ¶
type SQLiteRecordSet ¶
type SQLiteRecordSet struct { ColCount int ColNames []string Offset int PrimaryKeyColumns []string `json:"primaryKeyColumns,omitempty"` Records []DataRow RowCount int SortCol string SortDir string Tablename string TotalRows int }
func LiveQuery ¶ added in v0.0.15
func LiveQuery(liveNode, loggedInUser, dbOwner, dbName, query string) (rows SQLiteRecordSet, err error)
LiveQuery sends a SQLite query to a live database on its hosting node
func LiveRowData ¶ added in v0.0.15
func LiveRowData(liveNode, loggedInUser, dbOwner, dbName string, reqData JobRequestRows) (rowData SQLiteRecordSet, err error)
LiveRowData asks our job queue backend to send us the SQLite table data for a given range of rows
func ReadSQLiteDB ¶
func ReadSQLiteDB(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, maxRows, rowOffset int) (SQLiteRecordSet, error)
ReadSQLiteDB reads up to maxRows number of rows from a given SQLite database table. If maxRows < 0 (eg -1), then read all rows.
func ReadSQLiteDBCols ¶
func ReadSQLiteDBCols(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, ignoreBinary, ignoreNull bool, maxRows, rowOffset int) (SQLiteRecordSet, error)
ReadSQLiteDBCols reads up to maxRows # of rows from a SQLite database. Only returns the requested columns.
func SQLiteReadDatabasePage ¶ added in v0.0.15
func SQLiteReadDatabasePage(bucket, id, loggedInUser, dbOwner, dbName, dbTable, sortCol, sortDir, commitID string, rowOffset, maxRows int, isLive bool) (tables []string, defaultTable string, rowData SQLiteRecordSet, dbSize int64, err error)
SQLiteReadDatabasePage opens a SQLite database (locally) and returns a "page" of rows from it, for display in the database view page. Note that the dbSize return value is only set for live databases.
func SQLiteRunQuery ¶ added in v0.0.6
func SQLiteRunQuery(sdb *sqlite.Conn, querySource QuerySource, dbQuery string, ignoreBinary, ignoreNull bool) (memUsed, memHighWater int64, dataRows SQLiteRecordSet, err error)
SQLiteRunQuery runs a SQLite query. DO NOT use this for user provided SQL queries. For those, use SQLiteRunQueryDefensive().
func SQLiteRunQueryDefensive ¶ added in v0.0.6
func SQLiteRunQueryDefensive(w http.ResponseWriter, r *http.Request, querySource QuerySource, dbOwner, dbName, commitID, loggedInUser, query string) (SQLiteRecordSet, error)
SQLiteRunQueryDefensive runs a user provided SQLite query, using our "defensive" mode. eg with limits placed on what it's allowed to do.
func SQLiteRunQueryLive ¶ added in v0.0.15
func SQLiteRunQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string) (records SQLiteRecordSet, err error)
SQLiteRunQueryLive is used by our job queue backend infrastructure to run a user provided SQLite query
type SchemaDiff ¶ added in v0.0.6
type SchemaDiff struct { ActionType DiffType `json:"action_type"` Sql string `json:"sql,omitempty"` Before string `json:"before"` After string `json:"after"` }
SchemaDiff describes the changes to the schema of a database object, i.e. a created, dropped or altered object
type SetAccessType ¶ added in v0.0.15
type SetAccessType int
SetAccessType is used for setting the public flag of a database
const ( SetToPublic SetAccessType = iota SetToPrivate KeepCurrentAccessType )
type SetDBType ¶ added in v0.0.15
type SetDBType int
SetDBType is used for setting what type of database we're working with
type ShareDatabasePermissions ¶ added in v0.0.15
type ShareDatabasePermissions string
const ( MayRead ShareDatabasePermissions = "r" MayReadAndWrite ShareDatabasePermissions = "rw" )
type ShareDatabasePermissionsOthers ¶ added in v0.0.15
type ShareDatabasePermissionsOthers struct {}
ShareDatabasePermissionsOthers contains a list of user permissions for a given database
type ShareDatabasePermissionsUser ¶ added in v0.0.15
type ShareDatabasePermissionsUser struct {}
ShareDatabasePermissionsUser contains a list of shared database permissions for a given user
func GetSharesForUser ¶ added in v0.0.15
func GetSharesForUser(userName string) (shares []ShareDatabasePermissionsUser, err error)
GetSharesForUser returns a list of all the databases shared with the given user, and their permissions.
type SigningInfo ¶
type SigningInfo struct { CertDaysValid int `toml:"cert_days_valid"` Enabled bool `toml:"enabled"` IntermediateCert string `toml:"intermediate_cert"` IntermediateKey string `toml:"intermediate_key"` }
SigningInfo contains the info used for signing DB4S client certificates
type SqlHistoryItem ¶ added in v0.0.15
type SqlHistoryItem struct { Statement string `json:"input"` Result interface{} `json:"output"` State SqlHistoryItemStates `json:"state"` }
func LiveSqlHistoryGet ¶ added in v0.0.15
func LiveSqlHistoryGet(loggedInUser, dbOwner, dbName string) (history []SqlHistoryItem, err error)
LiveSqlHistoryGet returns the list of recently executed SQL statement for a user and database
type SqlHistoryItemStates ¶ added in v0.0.15
type SqlHistoryItemStates string
const ( Executed SqlHistoryItemStates = "executed" Queried SqlHistoryItemStates = "queried" Error SqlHistoryItemStates = "error" )
type StatusResponseContainer ¶ added in v0.0.14
type StatusResponseContainer struct {
Status string `json:"status"`
}
StatusResponseContainer holds a general status message response to a client request.
type StatusUpdateEntry ¶
type TomlConfig ¶
type TomlConfig struct { Api ApiInfo Auth0 Auth0Info DB4S DB4SInfo Environment EnvInfo DiskCache DiskCacheInfo Event EventProcessingInfo Licence LicenceInfo Live LiveInfo Memcache MemcacheInfo Minio MinioInfo MQ MQInfo Pg PGInfo Sign SigningInfo UserMgmt UserMgmtInfo Web WebInfo }
TomlConfig is a top level structure containing the server configuration information
var ( // Conf holds our configuration info Conf TomlConfig )
type UploadResponseContainer ¶ added in v0.0.13
UploadResponseContainer holds the response to a client upload. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons
type UserDetails ¶
type UserDetails struct { AvatarURL string ClientCert []byte DateJoined time.Time DisplayName string Email string MinioBucket string Password string PHash []byte PVerify string Username string }
func User ¶
func User(userName string) (user UserDetails, err error)
User returns details for a user
type UserInfoSlice ¶ added in v0.0.6
type UserInfoSlice []UserInfo
UserInfoSlice is used for sorting a UserInfo list by Last Modified date descending
func DB4SDefaultList ¶
func DB4SDefaultList(loggedInUser string) (UserInfoSlice, error)
DB4SDefaultList returns a list of 1) users with public databases, 2) along with the logged in users' most recently modified database (including their private one(s))
func (UserInfoSlice) Len ¶ added in v0.0.6
func (u UserInfoSlice) Len() int
func (UserInfoSlice) Less ¶ added in v0.0.6
func (u UserInfoSlice) Less(i, j int) bool
func (UserInfoSlice) Swap ¶ added in v0.0.6
func (u UserInfoSlice) Swap(i, j int)
type UserMgmtInfo ¶ added in v0.0.15
type UserMgmtInfo struct { BannedUsers []string `toml:"banned_users"` // List of users banned from the service SizeOverrideUsers []string `toml:"size_override_users"` // List of users allowed to override the database upload size limits }
UserMgmtInfo contains the various settings for specific users, or groups of users
type ValType ¶
type ValType int
ValType indicates the type of data in a field returned from a SQLite query
type VisGetFields ¶ added in v0.0.6
type VisGetFields struct {
VisName string `validate:"required,visname,min=1,max=63"` // 63 char limit seems reasonable
}
VisGetFields is used when validating input
type VisParamsV2 ¶ added in v0.0.6
type WebInfo ¶
type WebInfo struct { BaseDir string `toml:"base_dir"` BindAddress string `toml:"bind_address"` Certificate string `toml:"certificate"` CertificateKey string `toml:"certificate_key"` RequestLog string `toml:"request_log"` ServerName string `toml:"server_name"` SessionStorePassword string `toml:"session_store_password"` }
WebInfo contains configuration info for the webUI daemon
type WebpageResponseContainer ¶ added in v0.0.12
type WebpageResponseContainer struct {
WebPage string `json:"web_page"`
}
WebpageResponseContainer holds the response to a client request for the database webUI URL. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons