Documentation ¶
Index ¶
- Constants
- Variables
- func CreateEvent(dbExec func(string, ...interface{}) error, e *ct.Event, data interface{}) error
- func MigrateDB(db *postgres.DB) error
- func OpenAndMigrateDB(conf *postgres.Conf) *postgres.DB
- func PrepareStatements(conn *pgx.Conn) error
- type AppRepo
- func (r *AppRepo) Add(data interface{}) error
- func (r *AppRepo) Get(id string) (interface{}, error)
- func (r *AppRepo) GetRelease(id string) (*ct.Release, error)
- func (r *AppRepo) List() (interface{}, error)
- func (r *AppRepo) ListPage(opts ListAppOptions) ([]*ct.App, *PageToken, error)
- func (r *AppRepo) SetRelease(app *ct.App, releaseID string) error
- func (r *AppRepo) TxGet(tx rowQueryer, id string) (*ct.App, error)
- func (r *AppRepo) TxGetRelease(tx rowQueryer, id string) (*ct.Release, error)
- func (r *AppRepo) TxSetRelease(tx *postgres.DBTx, app *ct.App, releaseID string) error
- func (r *AppRepo) Update(id string, data map[string]interface{}) (interface{}, error)
- type ArtifactRepo
- type BackupRepo
- type DeploymentRepo
- func (r *DeploymentRepo) Add(appID, releaseID string) (*ct.Deployment, error)
- func (r *DeploymentRepo) AddExpanded(appID, releaseID string) (*ct.ExpandedDeployment, error)
- func (r *DeploymentRepo) Get(id string) (*ct.Deployment, error)
- func (r *DeploymentRepo) GetExpanded(id string) (*ct.ExpandedDeployment, error)
- func (r *DeploymentRepo) List(appID string) ([]*ct.Deployment, error)
- func (r *DeploymentRepo) ListPage(opts ListDeploymentOptions) ([]*ct.ExpandedDeployment, *PageToken, error)
- type DomainMigrationRepo
- type EventListener
- func (e *EventListener) CloseWithError(err error)
- func (e *EventListener) IsClosed() bool
- func (e *EventListener) Listen() error
- func (e *EventListener) Notify(event *ct.Event)
- func (e *EventListener) Subscribe(appIDs, objectTypes, objectIDs []string) (*EventSubscriber, error)
- func (e *EventListener) Unsubscribe(s *EventSubscriber)
- type EventRepo
- type EventSubscriber
- type FormationRepo
- func (r *FormationRepo) AddScaleRequest(req *ct.ScaleRequest, deleteFormation bool) (*ct.ScaleRequest, error)
- func (r *FormationRepo) Get(appID, releaseID string) (*ct.Formation, error)
- func (r *FormationRepo) GetExpanded(appID, releaseID string, includeDeleted bool) (*ct.ExpandedFormation, error)
- func (r *FormationRepo) List(appID string) ([]*ct.Formation, error)
- func (r *FormationRepo) ListActive() ([]*ct.ExpandedFormation, error)
- func (r *FormationRepo) ListScaleRequests(opts ListScaleRequestOptions) ([]*ct.ScaleRequest, *PageToken, error)
- func (r *FormationRepo) ListSince(since time.Time) ([]*ct.ExpandedFormation, error)
- func (r *FormationRepo) TxGet(tx rowQueryer, appID, releaseID string) (*ct.Formation, error)
- func (r *FormationRepo) UpdateScaleRequest(req *ct.ScaleRequest) error
- type JobRepo
- type ListAppOptions
- type ListDeploymentOptions
- type ListReleaseOptions
- type ListScaleRequestOptions
- type PageToken
- type ProviderRepo
- type ReleaseRepo
- func (r *ReleaseRepo) Add(data interface{}) error
- func (r *ReleaseRepo) AppList(appID string) ([]*ct.Release, error)
- func (r *ReleaseRepo) Delete(app *ct.App, release *ct.Release) error
- func (r *ReleaseRepo) Get(id string) (interface{}, error)
- func (r *ReleaseRepo) List() (interface{}, error)
- func (r *ReleaseRepo) ListPage(opts ListReleaseOptions) ([]*ct.Release, *PageToken, error)
- func (r *ReleaseRepo) TxGet(tx rowQueryer, id string) (*ct.Release, error)
- type ResourceRepo
- func (rr *ResourceRepo) Add(r *ct.Resource) error
- func (rr *ResourceRepo) AddApp(resourceID, appID string) (*ct.Resource, error)
- func (r *ResourceRepo) AppList(appID string) ([]*ct.Resource, error)
- func (r *ResourceRepo) Get(id string) (*ct.Resource, error)
- func (r *ResourceRepo) List() ([]*ct.Resource, error)
- func (r *ResourceRepo) ProviderList(providerID string) ([]*ct.Resource, error)
- func (rr *ResourceRepo) Remove(r *ct.Resource) error
- func (rr *ResourceRepo) RemoveApp(resourceID, appID string) (*ct.Resource, error)
- type RouteRepo
- type SinkRepo
- type VolumeRepo
- func (r *VolumeRepo) Add(vol *ct.Volume) error
- func (r *VolumeRepo) AppList(appID string) ([]*ct.Volume, error)
- func (r *VolumeRepo) Decommission(appID string, vol *ct.Volume) error
- func (r *VolumeRepo) Get(appID, volID string) (*ct.Volume, error)
- func (r *VolumeRepo) List() ([]*ct.Volume, error)
- func (r *VolumeRepo) ListSince(since time.Time) ([]*ct.Volume, error)
Constants ¶
const DEFAULT_PAGE_SIZE = 1000
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 ¶
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") )
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.
var ErrNotFound = ct.ErrNotFound
Functions ¶
func CreateEvent ¶
func PrepareStatements ¶
Types ¶
type AppRepo ¶
type AppRepo struct {
// contains filtered or unexported fields
}
func NewAppRepo ¶
func (*AppRepo) TxGetRelease ¶
func (*AppRepo) TxSetRelease ¶
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)
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 ¶
func (r *DeploymentRepo) ListPage(opts ListDeploymentOptions) ([]*ct.ExpandedDeployment, *PageToken, error)
type DomainMigrationRepo ¶
type DomainMigrationRepo struct {
// contains filtered or unexported fields
}
func NewDomainMigrationRepo ¶
func NewDomainMigrationRepo(db *postgres.DB) *DomainMigrationRepo
func (*DomainMigrationRepo) Add ¶
func (repo *DomainMigrationRepo) Add(dm *ct.DomainMigration) error
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 ¶
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) 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 ¶
type ListAppOptions ¶
type ListAppOptions struct { PageToken PageToken AppIDs []string LabelFilters []ct.LabelFilter }
type ListDeploymentOptions ¶
type ListReleaseOptions ¶
type ListReleaseOptions struct { PageToken PageToken AppIDs []string ReleaseIDs []string LabelFilters []ct.LabelFilter }
type ListScaleRequestOptions ¶
type PageToken ¶
func ParsePageToken ¶
ParsePageToken decodes a PageToken from a string of the format '<cursorID>:<size>'
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) Delete ¶
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)
type ResourceRepo ¶
type ResourceRepo struct {
// contains filtered or unexported fields
}
func NewResourceRepo ¶
func NewResourceRepo(db *postgres.DB) *ResourceRepo
func (*ResourceRepo) AddApp ¶
func (rr *ResourceRepo) AddApp(resourceID, appID string) (*ct.Resource, error)
func (*ResourceRepo) ProviderList ¶
func (r *ResourceRepo) ProviderList(providerID string) ([]*ct.Resource, error)
type RouteRepo ¶
type RouteRepo struct {
// contains filtered or unexported fields
}
func NewRouteRepo ¶
type SinkRepo ¶
type SinkRepo struct {
// contains filtered or unexported fields
}
func NewSinkRepo ¶
type VolumeRepo ¶
type VolumeRepo struct {
// contains filtered or unexported fields
}
func NewVolumeRepo ¶
func NewVolumeRepo(db *postgres.DB) *VolumeRepo
func (*VolumeRepo) Decommission ¶
func (r *VolumeRepo) Decommission(appID string, vol *ct.Volume) error