tables

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: MIT Imports: 7 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllTables

func GetAllTables() []interface{}

func ManualMigrate added in v1.1.0

func ManualMigrate(db *gorm.DB) error

func PrimaryKeyForTable

func PrimaryKeyForTable(tableName string) (string, error)

Types

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 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"`
	Stage               int64
	SerializedOperation []byte
}

func (*Execution) TableName

func (t *Execution) TableName() string

type ExecutionSummary added in v1.1.0

type ExecutionSummary struct {
	Model
	// The SummaryID is a randomly generated identifier.
	SummaryID    string `gorm:"primary_key"`
	InvocationID string `gorm:"index:esum_invocation_id"`

	// The user/group permissions of the calling user.
	UserID  string `gorm:"index:esum_user_id"`
	GroupID string `gorm:"index:esum_group_id"`
	Perms   int    `gorm:"index:esum_perms"`

	// A "hash/bytes_size" formatted Digest message that
	// uniquely identifies the Action that was completed.
	ActionDigest string `gorm:"index:esum_action_digest_index"`

	// A unique worker identifier string, identifying the
	// machine that completed this execution.
	WorkerID string

	// Execution metrics (cpu,memory,tx,rx, etc)
	UserCpuTimeUsec            int64
	SysCpuTimeUsec             int64
	MaxResidentSetSizeBytes    int64
	PageReclaims               int64
	PageFaults                 int64
	Swaps                      int64
	BlockInputOperations       int64
	BlockOutputOperations      int64
	MessagesSent               int64
	MessagesReceived           int64
	SignalsReceived            int64
	VoluntaryContextSwitches   int64
	InvoluntaryContextSwitches int64

	FileDownloadCount        int64
	FileDownloadSizeBytes    int64
	FileDownloadDurationUsec int64
	FileUploadCount          int64
	FileUploadSizeBytes      int64
	FileUploadDurationUsec   int64
}

func (*ExecutionSummary) TableName added in v1.1.0

func (t *ExecutionSummary) 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

	// 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"`
}

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"`
	Command          string
	Pattern          string `gorm:"type:text;"`
	ActionCount      int64
	BlobID           string
	InvocationStatus int64 `gorm:"index:invocation_status_idx"`
}

func (*Invocation) FromProtoAndBlobID added in v1.0.4

func (i *Invocation) FromProtoAndBlobID(p *inpb.Invocation, blobID string)

func (*Invocation) TableName

func (i *Invocation) TableName() string

func (*Invocation) ToProto added in v1.0.4

func (i *Invocation) ToProto() *inpb.Invocation

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 Table

type Table interface {
	TableName() string
}

A Table must define the table name.

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:"many2many:UserGroups;"`

	// 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

Jump to

Keyboard shortcuts

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