data

package
v0.0.0-...-b359386 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_PAGE_SIZE = 1000
View Source
const RouterMigrationStart = 36

RouterMigrationStart is the ID of the migration that starts the router migrations, and is used when restoring cluster backups to determine whether or not the restore should import the legacy router database into the controller (and thus perform the migrations that would otherwise be performed by migration 36 onwards)

Variables

View Source
var (
	ErrRouteNotFound        = errors.New("controller: route not found")
	ErrRouteConflict        = errors.New("controller: duplicate route")
	ErrRouteReserved        = errors.New("controller: cannot bind TCP to a reserved port")
	ErrRouteUnreservedHTTP  = errors.New("controller: cannot route HTTP to a non-HTTP port")
	ErrRouteUnreservedHTTPS = errors.New("controller: cannot route HTTPS to a non-HTTPS port")
	ErrRouteInvalid         = errors.New("controller: invalid route")
)
View Source
var ErrEventBufferOverflow = errors.New("event stream buffer overflow")

ErrEventBufferOverflow is returned to clients when the in-memory event buffer is full due to clients not reading events quickly enough.

View Source
var ErrNotFound = ct.ErrNotFound

Functions

func CreateEvent

func CreateEvent(dbExec func(string, ...interface{}) error, e *ct.Event, data interface{}) error

func MigrateDB

func MigrateDB(db *postgres.DB) error

func OpenAndMigrateDB

func OpenAndMigrateDB(conf *postgres.Conf) *postgres.DB

func PrepareStatements

func PrepareStatements(conn *pgx.Conn) error

Types

type AppRepo

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

func NewAppRepo

func NewAppRepo(db *postgres.DB, defaultDomain string, routes *RouteRepo) *AppRepo

func (*AppRepo) Add

func (r *AppRepo) Add(data interface{}) error

func (*AppRepo) Get

func (r *AppRepo) Get(id string) (interface{}, error)

func (*AppRepo) GetRelease

func (r *AppRepo) GetRelease(id string) (*ct.Release, error)

func (*AppRepo) List

func (r *AppRepo) List() (interface{}, error)

func (*AppRepo) ListPage

func (r *AppRepo) ListPage(opts ListAppOptions) ([]*ct.App, *PageToken, error)

func (*AppRepo) SetRelease

func (r *AppRepo) SetRelease(app *ct.App, releaseID string) error

func (*AppRepo) TxGet

func (r *AppRepo) TxGet(tx rowQueryer, id string) (*ct.App, error)

func (*AppRepo) TxGetRelease

func (r *AppRepo) TxGetRelease(tx rowQueryer, id string) (*ct.Release, error)

func (*AppRepo) TxSetRelease

func (r *AppRepo) TxSetRelease(tx *postgres.DBTx, app *ct.App, releaseID string) error

func (*AppRepo) Update

func (r *AppRepo) Update(id string, data map[string]interface{}) (interface{}, error)

type ArtifactRepo

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

func NewArtifactRepo

func NewArtifactRepo(db *postgres.DB) *ArtifactRepo

func (*ArtifactRepo) Add

func (r *ArtifactRepo) Add(data interface{}) error

func (*ArtifactRepo) Get

func (r *ArtifactRepo) Get(id string) (interface{}, error)

func (*ArtifactRepo) List

func (r *ArtifactRepo) List() (interface{}, error)

func (*ArtifactRepo) ListIDs

func (r *ArtifactRepo) ListIDs(ids ...string) (map[string]*ct.Artifact, error)

type BackupRepo

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

func NewBackupRepo

func NewBackupRepo(db *postgres.DB) *BackupRepo

func (*BackupRepo) Add

func (r *BackupRepo) Add(b *ct.ClusterBackup) error

func (*BackupRepo) GetLatest

func (r *BackupRepo) GetLatest() (*ct.ClusterBackup, error)

func (*BackupRepo) Update

func (r *BackupRepo) Update(b *ct.ClusterBackup) error

type DeploymentRepo

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

func NewDeploymentRepo

func NewDeploymentRepo(db *postgres.DB, appRepo *AppRepo, releaseRepo *ReleaseRepo, formationRepo *FormationRepo) *DeploymentRepo

func (*DeploymentRepo) Add

func (r *DeploymentRepo) Add(appID, releaseID string) (*ct.Deployment, error)

func (*DeploymentRepo) AddExpanded

func (r *DeploymentRepo) AddExpanded(appID, releaseID string) (*ct.ExpandedDeployment, error)

func (*DeploymentRepo) Get

func (r *DeploymentRepo) Get(id string) (*ct.Deployment, error)

func (*DeploymentRepo) GetExpanded

func (r *DeploymentRepo) GetExpanded(id string) (*ct.ExpandedDeployment, error)

func (*DeploymentRepo) List

func (r *DeploymentRepo) List(appID string) ([]*ct.Deployment, error)

func (*DeploymentRepo) ListPage

type DomainMigrationRepo

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

func NewDomainMigrationRepo

func NewDomainMigrationRepo(db *postgres.DB) *DomainMigrationRepo

func (*DomainMigrationRepo) Add

type EventListener

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

EventListener creates a postgres Listener for events and forwards them to subscribers.

func NewEventListener

func NewEventListener(r *EventRepo) *EventListener

func (*EventListener) CloseWithError

func (e *EventListener) CloseWithError(err error)

CloseWithError marks the listener as closed and closes all subscribers with the given error.

func (*EventListener) IsClosed

func (e *EventListener) IsClosed() bool

IsClosed returns whether or not the listener is closed.

func (*EventListener) Listen

func (e *EventListener) Listen() error

Listen creates a postgres listener for events and starts a goroutine to forward the events to subscribers.

func (*EventListener) Notify

func (e *EventListener) Notify(event *ct.Event)

Notify notifies all sbscribers of the given event.

func (*EventListener) Subscribe

func (e *EventListener) Subscribe(appIDs, objectTypes, objectIDs []string) (*EventSubscriber, error)

Subscribe creates and returns an EventSubscriber for the given apps, types and objects. An empty appIDs list subscribes to all apps

func (*EventListener) Unsubscribe

func (e *EventListener) Unsubscribe(s *EventSubscriber)

Unsubscribe unsubscribes the given subscriber.

type EventRepo

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

func NewEventRepo

func NewEventRepo(db *postgres.DB) *EventRepo

func (*EventRepo) GetEvent

func (r *EventRepo) GetEvent(id int64) (*ct.Event, error)

func (*EventRepo) ListEvents

func (r *EventRepo) ListEvents(appIDs, objectTypes, objectIDs []string, beforeID *int64, sinceID *int64, count int) ([]*ct.Event, error)

type EventSubscriber

type EventSubscriber struct {
	Events chan *ct.Event
	Err    error
	// contains filtered or unexported fields
}

EventSubscriber receives events from the EventListener loop and maintains it's own loop to forward those events to the Events channel.

func (*EventSubscriber) Close

func (e *EventSubscriber) Close()

Close unsubscribes from the EventListener and stops the loop.

func (*EventSubscriber) CloseWithError

func (e *EventSubscriber) CloseWithError(err error)

CloseWithError sets the Err field and then closes the subscriber.

func (*EventSubscriber) Notify

func (e *EventSubscriber) Notify(event *ct.Event)

Notify filters the event based on it's appID, type and objectID and then pushes it to the event queue.

type FormationRepo

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

func NewFormationRepo

func NewFormationRepo(db *postgres.DB, appRepo *AppRepo, releaseRepo *ReleaseRepo, artifactRepo *ArtifactRepo) *FormationRepo

func (*FormationRepo) AddScaleRequest

func (r *FormationRepo) AddScaleRequest(req *ct.ScaleRequest, deleteFormation bool) (*ct.ScaleRequest, error)

func (*FormationRepo) Get

func (r *FormationRepo) Get(appID, releaseID string) (*ct.Formation, error)

func (*FormationRepo) GetExpanded

func (r *FormationRepo) GetExpanded(appID, releaseID string, includeDeleted bool) (*ct.ExpandedFormation, error)

func (*FormationRepo) List

func (r *FormationRepo) List(appID string) ([]*ct.Formation, error)

func (*FormationRepo) ListActive

func (r *FormationRepo) ListActive() ([]*ct.ExpandedFormation, error)

func (*FormationRepo) ListScaleRequests

func (r *FormationRepo) ListScaleRequests(opts ListScaleRequestOptions) ([]*ct.ScaleRequest, *PageToken, error)

func (*FormationRepo) ListSince

func (r *FormationRepo) ListSince(since time.Time) ([]*ct.ExpandedFormation, error)

func (*FormationRepo) TxGet

func (r *FormationRepo) TxGet(tx rowQueryer, appID, releaseID string) (*ct.Formation, error)

func (*FormationRepo) UpdateScaleRequest

func (r *FormationRepo) UpdateScaleRequest(req *ct.ScaleRequest) error

type JobRepo

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

Job Stuff

func NewJobRepo

func NewJobRepo(db *postgres.DB) *JobRepo

func (*JobRepo) Add

func (r *JobRepo) Add(job *ct.Job) error

func (*JobRepo) Get

func (r *JobRepo) Get(id string) (*ct.Job, error)

func (*JobRepo) List

func (r *JobRepo) List(appID string) ([]*ct.Job, error)

func (*JobRepo) ListActive

func (r *JobRepo) ListActive() ([]*ct.Job, error)

type ListAppOptions

type ListAppOptions struct {
	PageToken    PageToken
	AppIDs       []string
	LabelFilters []ct.LabelFilter
}

type ListDeploymentOptions

type ListDeploymentOptions struct {
	PageToken     PageToken
	AppIDs        []string
	DeploymentIDs []string
	StatusFilters []string
	TypeFilters   []ct.ReleaseType
}

type ListReleaseOptions

type ListReleaseOptions struct {
	PageToken    PageToken
	AppIDs       []string
	ReleaseIDs   []string
	LabelFilters []ct.LabelFilter
}

type ListScaleRequestOptions

type ListScaleRequestOptions struct {
	PageToken    PageToken
	AppIDs       []string
	ReleaseIDs   []string
	ScaleIDs     []string
	StateFilters []ct.ScaleRequestState
}

type PageToken

type PageToken struct {
	CursorID *string
	Size     int
}

func ParsePageToken

func ParsePageToken(tokenStr string) (*PageToken, error)

ParsePageToken decodes a PageToken from a string of the format '<cursorID>:<size>'

func (*PageToken) Cursor

func (t *PageToken) Cursor() (*time.Time, error)

Cursor converts the microseconds since the unix epoch stored in CursorID to a time.Time

func (*PageToken) String

func (t *PageToken) String() string

type ProviderRepo

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

func NewProviderRepo

func NewProviderRepo(db *postgres.DB) *ProviderRepo

func (*ProviderRepo) Add

func (r *ProviderRepo) Add(data interface{}) error

func (*ProviderRepo) Get

func (r *ProviderRepo) Get(id string) (interface{}, error)

func (*ProviderRepo) List

func (r *ProviderRepo) List() (interface{}, error)

type ReleaseRepo

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

func NewReleaseRepo

func NewReleaseRepo(db *postgres.DB, artifacts *ArtifactRepo, que *que.Client) *ReleaseRepo

func (*ReleaseRepo) Add

func (r *ReleaseRepo) Add(data interface{}) error

func (*ReleaseRepo) AppList

func (r *ReleaseRepo) AppList(appID string) ([]*ct.Release, error)

func (*ReleaseRepo) Delete

func (r *ReleaseRepo) Delete(app *ct.App, release *ct.Release) error

Delete deletes any formations for the given app and release, then deletes the release and any associated file artifacts if there are no remaining formations for the release, enqueueing a worker job to delete any files stored in the blobstore

func (*ReleaseRepo) Get

func (r *ReleaseRepo) Get(id string) (interface{}, error)

func (*ReleaseRepo) List

func (r *ReleaseRepo) List() (interface{}, error)

func (*ReleaseRepo) ListPage

func (r *ReleaseRepo) ListPage(opts ListReleaseOptions) ([]*ct.Release, *PageToken, error)

func (*ReleaseRepo) TxGet

func (r *ReleaseRepo) TxGet(tx rowQueryer, id string) (*ct.Release, error)

type ResourceRepo

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

func NewResourceRepo

func NewResourceRepo(db *postgres.DB) *ResourceRepo

func (*ResourceRepo) Add

func (rr *ResourceRepo) Add(r *ct.Resource) error

func (*ResourceRepo) AddApp

func (rr *ResourceRepo) AddApp(resourceID, appID string) (*ct.Resource, error)

func (*ResourceRepo) AppList

func (r *ResourceRepo) AppList(appID string) ([]*ct.Resource, error)

func (*ResourceRepo) Get

func (r *ResourceRepo) Get(id string) (*ct.Resource, error)

func (*ResourceRepo) List

func (r *ResourceRepo) List() ([]*ct.Resource, error)

func (*ResourceRepo) ProviderList

func (r *ResourceRepo) ProviderList(providerID string) ([]*ct.Resource, error)

func (*ResourceRepo) Remove

func (rr *ResourceRepo) Remove(r *ct.Resource) error

func (*ResourceRepo) RemoveApp

func (rr *ResourceRepo) RemoveApp(resourceID, appID string) (*ct.Resource, error)

type RouteRepo

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

func NewRouteRepo

func NewRouteRepo(db *postgres.DB) *RouteRepo

func (*RouteRepo) Add

func (r *RouteRepo) Add(route *router.Route) error

func (*RouteRepo) Delete

func (r *RouteRepo) Delete(route *router.Route) error

func (*RouteRepo) Get

func (r *RouteRepo) Get(typ, id string) (*router.Route, error)

func (*RouteRepo) List

func (r *RouteRepo) List(parentRef string) ([]*router.Route, error)

func (*RouteRepo) Update

func (r *RouteRepo) Update(route *router.Route) error

type SinkRepo

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

func NewSinkRepo

func NewSinkRepo(db *postgres.DB) *SinkRepo

func (*SinkRepo) Add

func (r *SinkRepo) Add(s *ct.Sink) error

func (*SinkRepo) Get

func (r *SinkRepo) Get(id string) (*ct.Sink, error)

func (*SinkRepo) List

func (r *SinkRepo) List() ([]*ct.Sink, error)

func (*SinkRepo) ListSince

func (r *SinkRepo) ListSince(since time.Time) ([]*ct.Sink, error)

func (*SinkRepo) Remove

func (r *SinkRepo) Remove(id string) error

type VolumeRepo

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

func NewVolumeRepo

func NewVolumeRepo(db *postgres.DB) *VolumeRepo

func (*VolumeRepo) Add

func (r *VolumeRepo) Add(vol *ct.Volume) error

func (*VolumeRepo) AppList

func (r *VolumeRepo) AppList(appID string) ([]*ct.Volume, error)

func (*VolumeRepo) Decommission

func (r *VolumeRepo) Decommission(appID string, vol *ct.Volume) error

func (*VolumeRepo) Get

func (r *VolumeRepo) Get(appID, volID string) (*ct.Volume, error)

func (*VolumeRepo) List

func (r *VolumeRepo) List() ([]*ct.Volume, error)

func (*VolumeRepo) ListSince

func (r *VolumeRepo) ListSince(since time.Time) ([]*ct.Volume, error)

Jump to

Keyboard shortcuts

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