tables

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: MIT Imports: 6 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllTables

func GetAllTables() []interface{}

func PostAutoMigrate

func PostAutoMigrate(db *gorm.DB) error

Manual migration called after auto-migration.

func PrimaryKeyForTable

func PrimaryKeyForTable(tableName string) (string, error)

Types

type APIKey

type APIKey struct {
	Model

	APIKeyID string `gorm:"primary_key"`
	UserID   string
	GroupID  string `gorm:"index:api_key_group_id_index"`
	Perms    int
	// The API key token used for authentication.
	Value string `gorm:"unique_index:api_key_value_index"`
	// The user-specified description of the API key that helps them
	// remember what it's for.
	Label string
}

func (*APIKey) TableName

func (k *APIKey) TableName() string

type CacheEntry

type CacheEntry struct {
	Model
	EntryID            string `gorm:"primary_key;"`
	ExpirationTimeUsec int64
	SizeBytes          int64
	ReadCount          int64
}

func (*CacheEntry) TableName

func (c *CacheEntry) TableName() string

type CacheLog

type CacheLog struct {
	Model
	InvocationID       string `gorm:"primary_key"`
	JoinKey            string `gorm:"primary_key"`
	DigestHash         string
	RemoteInstanceName string
	SerializedProto    []byte `gorm:"size:max"`
}

func (*CacheLog) TableName

func (c *CacheLog) TableName() string

type Execution

type Execution struct {
	Model
	// The subscriber ID, a concatenated string of the
	// auth Issuer ID and the subcriber ID string.
	ExecutionID string `gorm:"primary_key"`
	UserID      string `gorm:"index:executions_user_id"`
	GroupID     string `gorm:"index:executions_group_id"`
	Perms       int    `gorm:"index:executions_perms"`

	Stage                   int64
	SerializedOperation     []byte `gorm:"size:max"` // deprecated.
	StatusCode              int32
	StatusMessage           string
	SerializedStatusDetails []byte `gorm:"size:max"`
	CachedResult            bool
	InvocationID            string `gorm:"index:execution_invocation_id"`

	// IOStats
	FileDownloadCount        int64
	FileDownloadSizeBytes    int64
	FileDownloadDurationUsec int64
	FileUploadCount          int64
	FileUploadSizeBytes      int64
	FileUploadDurationUsec   int64

	// ExecutedActionMetadata
	Worker                             string
	QueuedTimestampUsec                int64
	WorkerStartTimestampUsec           int64
	WorkerCompletedTimestampUsec       int64
	InputFetchStartTimestampUsec       int64
	InputFetchCompletedTimestampUsec   int64
	ExecutionStartTimestampUsec        int64
	ExecutionCompletedTimestampUsec    int64
	OutputUploadStartTimestampUsec     int64
	OutputUploadCompletedTimestampUsec int64

	// Command Snippet
	CommandSnippet string
}

func (*Execution) TableName

func (t *Execution) TableName() string

type ExecutionNode

type ExecutionNode struct {
	Model
	Host                  string `gorm:"primary_key"`
	Port                  int32  `gorm:"primary_key;auto_increment:false"`
	AssignableMemoryBytes int64
	AssignableMilliCPU    int64
	Constraints           string
	OS                    string
	Arch                  string
	Pool                  string
}

func (*ExecutionNode) TableName

func (n *ExecutionNode) TableName() string

type ExecutionTask

type ExecutionTask struct {
	Model
	TaskID               string `gorm:"primary_key"`
	SerializedTask       []byte `gorm:"size:max"`
	EstimatedMemoryBytes int64
	EstimatedMilliCPU    int64
	ClaimedAtUsec        int64
	AttemptCount         int64
	OS                   string
	Arch                 string
	Pool                 string
}

func (*ExecutionTask) TableName

func (n *ExecutionTask) TableName() string

type Group

type Group struct {
	Model

	GroupID string `gorm:"primary_key;"`
	// The user that OWNS this group. Only this user may modify it.
	UserID string

	// The group name. This may be displayed to users.
	Name string

	// A unique URL segment that is displayed in group-related URLs.
	// e.g. "example-org" in app.buildbuddy.com/join/example-org or
	// "example-org.buildbuddy.com" if we support subdomains in the future.
	URLIdentifier *string `gorm:"unique_index:url_identifier_unique_index"`

	SharingEnabled bool `gorm:"default:true"`

	// The "owned" domain. In enterprise/cloud version, we create a
	// group for a customer's domain, and new users that sign up with an
	// email belonging to that domain may be added to this group.
	OwnedDomain string `gorm:"index:owned_domain_index"`

	// The group access token. This token allows writing data for this
	// group.
	WriteToken string `gorm:"index:write_token_index"`

	// The group's api key. This allows members of the group to make
	// API requests on the group's behalf.
	APIKey string `gorm:"index:api_key_index"`

	// The group's Github API token.
	GithubToken string
}

func (*Group) TableName

func (g *Group) TableName() string

type Invocation

type Invocation struct {
	Model
	InvocationID                     string `gorm:"primary_key;"`
	UserID                           string `gorm:"index:user_id"`
	GroupID                          string `gorm:"index:group_id"`
	Perms                            int    `gorm:"index:perms"`
	Success                          bool
	User                             string `gorm:"index:user_index"`
	DurationUsec                     int64
	Host                             string `gorm:"index:host_index"`
	RepoURL                          string `gorm:"index:repo_url_index"`
	CommitSHA                        string `gorm:"index:commit_sha_index"`
	Role                             string `gorm:"index:role_index"`
	Command                          string
	Pattern                          string `gorm:"type:text;"`
	ActionCount                      int64
	BlobID                           string
	InvocationStatus                 int64 `gorm:"index:invocation_status_idx"`
	ActionCacheHits                  int64
	ActionCacheMisses                int64
	ActionCacheUploads               int64
	CasCacheHits                     int64
	CasCacheMisses                   int64
	CasCacheUploads                  int64
	TotalDownloadSizeBytes           int64
	TotalUploadSizeBytes             int64
	TotalDownloadUsec                int64
	TotalUploadUsec                  int64
	TotalCachedActionExecUsec        int64
	DownloadThroughputBytesPerSecond int64
	UploadThroughputBytesPerSecond   int64
	InvocationPK                     int64 `gorm:"unique_index:invocation_invocation_pk"`
}

func (*Invocation) TableName

func (i *Invocation) TableName() string

type Model

type Model struct {
	CreatedAtUsec int64
	UpdatedAtUsec int64
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) (err error)

Timestamps are hard and differing sql implementations do... a lot. Too much. So, we handle this in go-code and set these to time.Now().UnixNano and store as int64.

func (*Model) BeforeUpdate

func (m *Model) BeforeUpdate(tx *gorm.DB) (err error)

type PostAutoMigrateLogic

type PostAutoMigrateLogic func() error

func PreAutoMigrate

func PreAutoMigrate(db *gorm.DB) ([]PostAutoMigrateLogic, error)

Manual migration called before auto-migration.

May return a list of functions to be executed after auto-migration. This is useful in cases where some logic needs to be executed in PostAutoMigrate, but some info is needed before the migration takes place in order to know what to do.

type Table

type Table interface {
	TableName() string
}

A Table must define the table name.

type Target

type Target struct {
	Model
	UserID   string `gorm:"primaryKey"`
	GroupID  string `gorm:"primaryKey"`
	RepoURL  string `gorm:"primaryKey"`
	Label    string `gorm:"primaryKey"`
	TargetID int64  `gorm:"index:target_target_id"`
	Perms    int    `gorm:"index:target_perms"`
	RuleType string
}

func (*Target) TableName

func (t *Target) TableName() string

type TargetStatus

type TargetStatus struct {
	Model
	TargetID      int64 `gorm:"primaryKey"`
	InvocationPK  int64 `gorm:"primaryKey"`
	TargetType    int32
	TestSize      int32
	Status        int32
	StartTimeUsec int64
	DurationUsec  int64
}

The Status of a target.

func (*TargetStatus) TableName

func (ts *TargetStatus) TableName() string

type TelemetryLog

type TelemetryLog struct {
	Model
	InstallationUUID    string `gorm:"primary_key"`
	InstanceUUID        string `gorm:"primary_key"`
	TelemetryLogUUID    string `gorm:"primary_key"`
	RecordedAtUsec      int64
	AppVersion          string
	AppURL              string
	Hostname            string
	InvocationCount     int64
	RegisteredUserCount int64
	BazelUserCount      int64
	BazelHostCount      int64
	FeatureCacheEnabled bool
	FeatureRBEEnabled   bool
	FeatureAPIEnabled   bool
	FeatureAuthEnabled  bool
}

func (*TelemetryLog) TableName

func (t *TelemetryLog) TableName() string

type Token

type Token struct {
	Model
	// The subscriber ID, a concatenated string of the
	// auth Issuer ID and the subcriber ID string.
	SubID        string `gorm:"primary_key"`
	AccessToken  string
	RefreshToken string
	ExpiryUsec   int64
}

func (*Token) TableName

func (t *Token) TableName() string

type User

type User struct {
	Model

	// The buildbuddy user ID.
	UserID string `gorm:"primary_key;"`

	// The subscriber ID, a concatenated string of the
	// auth Issuer ID and the subcriber ID string.
	SubID string `gorm:"index:sub_id_index"`

	// Groups are used to determine read/write permissions
	// for everything.
	Groups []*Group `gorm:"-"` // gorm ignore

	// Profile information etc.
	FirstName string
	LastName  string
	Email     string
	ImageURL  string
}

func (*User) TableName

func (u *User) TableName() string

func (*User) ToProto

func (u *User) ToProto() *uspb.DisplayUser

type UserGroup

type UserGroup struct {
	UserUserID   string `gorm:"primary_key"`
	GroupGroupID string `gorm:"primary_key"`

	// The user's membership status.
	// Values correspond to `GroupMembershipStatus` enum values in `grp.proto`.
	MembershipStatus int32 `gorm:"index:membership_status_index"`
}

func (*UserGroup) TableName

func (ug *UserGroup) TableName() string

Jump to

Keyboard shortcuts

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