Documentation ¶
Index ¶
- func Migrate(ctx context.Context, dsn string) error
- type Artefact
- type AssociateArtefactWithDeploymentParams
- type Controller
- type ControllerState
- type CreateIngressRouteParams
- type DB
- type DBI
- type DBTX
- type Deployment
- type DeploymentArtefact
- type Event
- type EventType
- type GetActiveDeploymentSchemasRow
- type GetActiveDeploymentsRow
- type GetActiveRunnersRow
- type GetAllIngressRoutesRow
- type GetArtefactDigestsRow
- type GetDeploymentArtefactsRow
- type GetDeploymentRow
- type GetDeploymentsNeedingReconciliationRow
- type GetDeploymentsWithArtefactsRow
- type GetExistingDeploymentForModuleRow
- type GetIngressRoutesRow
- type GetProcessListRow
- type GetRouteForRunnerRow
- type GetRoutingTableRow
- type GetRunnerRow
- type GetRunnersForDeploymentRow
- type IngressRoute
- type InsertCallEventParams
- type InsertDeploymentCreatedEventParams
- type InsertDeploymentUpdatedEventParams
- type InsertEventParams
- type InsertLogEventParams
- type Key
- type Module
- type NullControllerState
- type NullDuration
- type NullEventType
- type NullKey
- type NullOrigin
- type NullRunnerState
- type NullTime
- type Origin
- type Querier
- type Queries
- func (q *Queries) AssociateArtefactWithDeployment(ctx context.Context, arg AssociateArtefactWithDeploymentParams) error
- func (q *Queries) CreateArtefact(ctx context.Context, digest []byte, content []byte) (int64, error)
- func (q *Queries) CreateDeployment(ctx context.Context, name model.DeploymentName, moduleName string, ...) error
- func (q *Queries) CreateIngressRequest(ctx context.Context, origin Origin, name string, sourceAddr string) error
- func (q *Queries) CreateIngressRoute(ctx context.Context, arg CreateIngressRouteParams) error
- func (q *Queries) DeregisterRunner(ctx context.Context, key Key) (int64, error)
- func (q *Queries) ExpireRunnerReservations(ctx context.Context) (int64, error)
- func (q *Queries) GetActiveDeploymentSchemas(ctx context.Context) ([]GetActiveDeploymentSchemasRow, error)
- func (q *Queries) GetActiveDeployments(ctx context.Context, all bool) ([]GetActiveDeploymentsRow, error)
- func (q *Queries) GetActiveRunners(ctx context.Context, all bool) ([]GetActiveRunnersRow, error)
- func (q *Queries) GetAllIngressRoutes(ctx context.Context, all bool) ([]GetAllIngressRoutesRow, error)
- func (q *Queries) GetArtefactContentRange(ctx context.Context, start int32, count int32, iD int64) ([]byte, error)
- func (q *Queries) GetArtefactDigests(ctx context.Context, digests [][]byte) ([]GetArtefactDigestsRow, error)
- func (q *Queries) GetControllers(ctx context.Context, all bool) ([]Controller, error)
- func (q *Queries) GetDeployment(ctx context.Context, name model.DeploymentName) (GetDeploymentRow, error)
- func (q *Queries) GetDeploymentArtefacts(ctx context.Context, deploymentID int64) ([]GetDeploymentArtefactsRow, error)
- func (q *Queries) GetDeploymentsByID(ctx context.Context, ids []int64) ([]Deployment, error)
- func (q *Queries) GetDeploymentsNeedingReconciliation(ctx context.Context) ([]GetDeploymentsNeedingReconciliationRow, error)
- func (q *Queries) GetDeploymentsWithArtefacts(ctx context.Context, digests [][]byte, schema []byte, count int64) ([]GetDeploymentsWithArtefactsRow, error)
- func (q *Queries) GetExistingDeploymentForModule(ctx context.Context, name string) (GetExistingDeploymentForModuleRow, error)
- func (q *Queries) GetIdleRunners(ctx context.Context, labels []byte, limit int64) ([]Runner, error)
- func (q *Queries) GetIngressRoutes(ctx context.Context, method string) ([]GetIngressRoutesRow, error)
- func (q *Queries) GetModulesByID(ctx context.Context, ids []int64) ([]Module, error)
- func (q *Queries) GetProcessList(ctx context.Context) ([]GetProcessListRow, error)
- func (q *Queries) GetRouteForRunner(ctx context.Context, key Key) (GetRouteForRunnerRow, error)
- func (q *Queries) GetRoutingTable(ctx context.Context, modules []string) ([]GetRoutingTableRow, error)
- func (q *Queries) GetRunner(ctx context.Context, key Key) (GetRunnerRow, error)
- func (q *Queries) GetRunnerState(ctx context.Context, key Key) (RunnerState, error)
- func (q *Queries) GetRunnersForDeployment(ctx context.Context, name model.DeploymentName) ([]GetRunnersForDeploymentRow, error)
- func (q *Queries) InsertCallEvent(ctx context.Context, arg InsertCallEventParams) error
- func (q *Queries) InsertDeploymentCreatedEvent(ctx context.Context, arg InsertDeploymentCreatedEventParams) error
- func (q *Queries) InsertDeploymentUpdatedEvent(ctx context.Context, arg InsertDeploymentUpdatedEventParams) error
- func (q *Queries) InsertEvent(ctx context.Context, arg InsertEventParams) error
- func (q *Queries) InsertLogEvent(ctx context.Context, arg InsertLogEventParams) error
- func (q *Queries) KillStaleControllers(ctx context.Context, timeout time.Duration) (int64, error)
- func (q *Queries) KillStaleRunners(ctx context.Context, timeout time.Duration) (int64, error)
- func (q *Queries) ReplaceDeployment(ctx context.Context, oldDeployment string, newDeployment string, ...) (int64, error)
- func (q *Queries) ReserveRunner(ctx context.Context, reservationTimeout time.Time, ...) (Runner, error)
- func (q *Queries) SetDeploymentDesiredReplicas(ctx context.Context, name model.DeploymentName, minReplicas int32) error
- func (q *Queries) UpsertController(ctx context.Context, key model.ControllerKey, endpoint string) (int64, error)
- func (q *Queries) UpsertModule(ctx context.Context, language string, name string) (int64, error)
- func (q *Queries) UpsertRunner(ctx context.Context, arg UpsertRunnerParams) (optional.Option[int64], error)
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type Request
- type Runner
- type RunnerState
- type Tx
- type UpsertRunnerParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssociateArtefactWithDeploymentParams ¶
type AssociateArtefactWithDeploymentParams struct { Name model.DeploymentName ArtefactID int64 Executable bool Path string }
type Controller ¶
type Controller struct { ID int64 Key model.ControllerKey Created time.Time LastSeen time.Time State ControllerState Endpoint string }
type ControllerState ¶
type ControllerState string
const ( ControllerStateLive ControllerState = "live" ControllerStateDead ControllerState = "dead" )
func (*ControllerState) Scan ¶
func (e *ControllerState) Scan(src interface{}) error
type Deployment ¶
type DeploymentArtefact ¶
type GetActiveDeploymentSchemasRow ¶ added in v0.79.3
type GetActiveDeploymentSchemasRow struct { Name model.DeploymentName Schema *schema.Module }
type GetActiveDeploymentsRow ¶ added in v0.79.3
type GetActiveDeploymentsRow struct { Deployment Deployment ModuleName string Language string }
type GetActiveRunnersRow ¶
type GetAllIngressRoutesRow ¶
type GetArtefactDigestsRow ¶
type GetDeploymentRow ¶
type GetDeploymentRow struct { Deployment Deployment Language string ModuleName string MinReplicas int32 }
type GetIngressRoutesRow ¶
type GetProcessListRow ¶
type GetRouteForRunnerRow ¶
type GetRouteForRunnerRow struct { Endpoint string RunnerKey Key ModuleName optional.Option[string] DeploymentName model.DeploymentName State RunnerState }
type GetRoutingTableRow ¶
type GetRunnerRow ¶
type GetRunnersForDeploymentRow ¶
type GetRunnersForDeploymentRow struct { ID int64 Key Key Created time.Time LastSeen time.Time ReservationTimeout NullTime State RunnerState Endpoint string ModuleName optional.Option[string] DeploymentID optional.Option[int64] Labels []byte ID_2 int64 CreatedAt time.Time ModuleID int64 Name model.DeploymentName Schema *schema.Module Labels_2 []byte MinReplicas int32 }
type IngressRoute ¶
type InsertCallEventParams ¶
type InsertCallEventParams struct { DeploymentName string RequestName optional.Option[string] TimeStamp time.Time SourceModule optional.Option[string] SourceVerb optional.Option[string] DestModule string DestVerb string DurationMs int64 Request []byte Response []byte Error optional.Option[string] Stack optional.Option[string] }
type InsertEventParams ¶
type InsertLogEventParams ¶
type Key ¶
type Key ulid.ULID
Key is a ULID that can be used as a column in a database.
func (*Key) UnmarshalText ¶
type NullControllerState ¶
type NullControllerState struct { ControllerState ControllerState Valid bool // Valid is true if ControllerState is not NULL }
func (*NullControllerState) Scan ¶
func (ns *NullControllerState) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullEventType ¶
type NullEventType struct { EventType EventType Valid bool // Valid is true if EventType is not NULL }
func (*NullEventType) Scan ¶
func (ns *NullEventType) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullKey ¶
func FromOption ¶
FromOption converts a optional.Option[~ulid.ULID] to a NullKey.
type NullOrigin ¶
func (*NullOrigin) Scan ¶
func (ns *NullOrigin) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullRunnerState ¶
type NullRunnerState struct { RunnerState RunnerState Valid bool // Valid is true if RunnerState is not NULL }
func (*NullRunnerState) Scan ¶
func (ns *NullRunnerState) Scan(value interface{}) error
Scan implements the Scanner interface.
type Querier ¶
type Querier interface { AssociateArtefactWithDeployment(ctx context.Context, arg AssociateArtefactWithDeploymentParams) error // Create a new artefact and return the artefact ID. CreateArtefact(ctx context.Context, digest []byte, content []byte) (int64, error) CreateDeployment(ctx context.Context, name model.DeploymentName, moduleName string, schema []byte) error CreateIngressRequest(ctx context.Context, origin Origin, name string, sourceAddr string) error CreateIngressRoute(ctx context.Context, arg CreateIngressRouteParams) error DeregisterRunner(ctx context.Context, key Key) (int64, error) ExpireRunnerReservations(ctx context.Context) (int64, error) GetActiveDeploymentSchemas(ctx context.Context) ([]GetActiveDeploymentSchemasRow, error) GetActiveDeployments(ctx context.Context, all bool) ([]GetActiveDeploymentsRow, error) GetActiveRunners(ctx context.Context, all bool) ([]GetActiveRunnersRow, error) GetAllIngressRoutes(ctx context.Context, all bool) ([]GetAllIngressRoutesRow, error) GetArtefactContentRange(ctx context.Context, start int32, count int32, iD int64) ([]byte, error) // Return the digests that exist in the database. GetArtefactDigests(ctx context.Context, digests [][]byte) ([]GetArtefactDigestsRow, error) GetControllers(ctx context.Context, all bool) ([]Controller, error) GetDeployment(ctx context.Context, name model.DeploymentName) (GetDeploymentRow, error) // Get all artefacts matching the given digests. GetDeploymentArtefacts(ctx context.Context, deploymentID int64) ([]GetDeploymentArtefactsRow, error) GetDeploymentsByID(ctx context.Context, ids []int64) ([]Deployment, error) // Get deployments that have a mismatch between the number of assigned and required replicas. GetDeploymentsNeedingReconciliation(ctx context.Context) ([]GetDeploymentsNeedingReconciliationRow, error) // Get all deployments that have artefacts matching the given digests. GetDeploymentsWithArtefacts(ctx context.Context, digests [][]byte, schema []byte, count int64) ([]GetDeploymentsWithArtefactsRow, error) GetExistingDeploymentForModule(ctx context.Context, name string) (GetExistingDeploymentForModuleRow, error) GetIdleRunners(ctx context.Context, labels []byte, limit int64) ([]Runner, error) // Get the runner endpoints corresponding to the given ingress route. GetIngressRoutes(ctx context.Context, method string) ([]GetIngressRoutesRow, error) GetModulesByID(ctx context.Context, ids []int64) ([]Module, error) GetProcessList(ctx context.Context) ([]GetProcessListRow, error) // Retrieve routing information for a runner. GetRouteForRunner(ctx context.Context, key Key) (GetRouteForRunnerRow, error) GetRoutingTable(ctx context.Context, modules []string) ([]GetRoutingTableRow, error) GetRunner(ctx context.Context, key Key) (GetRunnerRow, error) GetRunnerState(ctx context.Context, key Key) (RunnerState, error) GetRunnersForDeployment(ctx context.Context, name model.DeploymentName) ([]GetRunnersForDeploymentRow, error) InsertCallEvent(ctx context.Context, arg InsertCallEventParams) error InsertDeploymentCreatedEvent(ctx context.Context, arg InsertDeploymentCreatedEventParams) error InsertDeploymentUpdatedEvent(ctx context.Context, arg InsertDeploymentUpdatedEventParams) error InsertEvent(ctx context.Context, arg InsertEventParams) error InsertLogEvent(ctx context.Context, arg InsertLogEventParams) error // Mark any controller entries that haven't been updated recently as dead. KillStaleControllers(ctx context.Context, timeout time.Duration) (int64, error) KillStaleRunners(ctx context.Context, timeout time.Duration) (int64, error) ReplaceDeployment(ctx context.Context, oldDeployment string, newDeployment string, minReplicas int32) (int64, error) // Find an idle runner and reserve it for the given deployment. ReserveRunner(ctx context.Context, reservationTimeout time.Time, deploymentName model.DeploymentName, labels []byte) (Runner, error) SetDeploymentDesiredReplicas(ctx context.Context, name model.DeploymentName, minReplicas int32) error UpsertController(ctx context.Context, key model.ControllerKey, endpoint string) (int64, error) UpsertModule(ctx context.Context, language string, name string) (int64, error) // Upsert a runner and return the deployment ID that it is assigned to, if any. // If the deployment name is null, then deployment_rel.id will be null, // otherwise we try to retrieve the deployments.id using the key. If // there is no corresponding deployment, then the deployment ID is -1 // and the parent statement will fail due to a foreign key constraint. UpsertRunner(ctx context.Context, arg UpsertRunnerParams) (optional.Option[int64], error) }
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) AssociateArtefactWithDeployment ¶
func (q *Queries) AssociateArtefactWithDeployment(ctx context.Context, arg AssociateArtefactWithDeploymentParams) error
func (*Queries) CreateArtefact ¶
Create a new artefact and return the artefact ID.
func (*Queries) CreateDeployment ¶
func (*Queries) CreateIngressRequest ¶
func (*Queries) CreateIngressRoute ¶
func (q *Queries) CreateIngressRoute(ctx context.Context, arg CreateIngressRouteParams) error
func (*Queries) DeregisterRunner ¶
func (*Queries) ExpireRunnerReservations ¶
func (*Queries) GetActiveDeploymentSchemas ¶ added in v0.79.3
func (q *Queries) GetActiveDeploymentSchemas(ctx context.Context) ([]GetActiveDeploymentSchemasRow, error)
func (*Queries) GetActiveDeployments ¶ added in v0.79.3
func (*Queries) GetActiveRunners ¶
func (*Queries) GetAllIngressRoutes ¶
func (*Queries) GetArtefactContentRange ¶
func (*Queries) GetArtefactDigests ¶
func (q *Queries) GetArtefactDigests(ctx context.Context, digests [][]byte) ([]GetArtefactDigestsRow, error)
Return the digests that exist in the database.
func (*Queries) GetControllers ¶
func (*Queries) GetDeployment ¶
func (q *Queries) GetDeployment(ctx context.Context, name model.DeploymentName) (GetDeploymentRow, error)
func (*Queries) GetDeploymentArtefacts ¶
func (q *Queries) GetDeploymentArtefacts(ctx context.Context, deploymentID int64) ([]GetDeploymentArtefactsRow, error)
Get all artefacts matching the given digests.
func (*Queries) GetDeploymentsByID ¶
func (*Queries) GetDeploymentsNeedingReconciliation ¶
func (q *Queries) GetDeploymentsNeedingReconciliation(ctx context.Context) ([]GetDeploymentsNeedingReconciliationRow, error)
Get deployments that have a mismatch between the number of assigned and required replicas.
func (*Queries) GetDeploymentsWithArtefacts ¶
func (q *Queries) GetDeploymentsWithArtefacts(ctx context.Context, digests [][]byte, schema []byte, count int64) ([]GetDeploymentsWithArtefactsRow, error)
Get all deployments that have artefacts matching the given digests.
func (*Queries) GetExistingDeploymentForModule ¶
func (*Queries) GetIdleRunners ¶
func (*Queries) GetIngressRoutes ¶
func (q *Queries) GetIngressRoutes(ctx context.Context, method string) ([]GetIngressRoutesRow, error)
Get the runner endpoints corresponding to the given ingress route.
func (*Queries) GetModulesByID ¶
func (*Queries) GetProcessList ¶
func (q *Queries) GetProcessList(ctx context.Context) ([]GetProcessListRow, error)
func (*Queries) GetRouteForRunner ¶
Retrieve routing information for a runner.
func (*Queries) GetRoutingTable ¶
func (*Queries) GetRunnerState ¶
func (*Queries) GetRunnersForDeployment ¶
func (q *Queries) GetRunnersForDeployment(ctx context.Context, name model.DeploymentName) ([]GetRunnersForDeploymentRow, error)
func (*Queries) InsertCallEvent ¶
func (q *Queries) InsertCallEvent(ctx context.Context, arg InsertCallEventParams) error
func (*Queries) InsertDeploymentCreatedEvent ¶
func (q *Queries) InsertDeploymentCreatedEvent(ctx context.Context, arg InsertDeploymentCreatedEventParams) error
func (*Queries) InsertDeploymentUpdatedEvent ¶
func (q *Queries) InsertDeploymentUpdatedEvent(ctx context.Context, arg InsertDeploymentUpdatedEventParams) error
func (*Queries) InsertEvent ¶
func (q *Queries) InsertEvent(ctx context.Context, arg InsertEventParams) error
func (*Queries) InsertLogEvent ¶
func (q *Queries) InsertLogEvent(ctx context.Context, arg InsertLogEventParams) error
func (*Queries) KillStaleControllers ¶
Mark any controller entries that haven't been updated recently as dead.
func (*Queries) KillStaleRunners ¶
func (*Queries) ReplaceDeployment ¶
func (*Queries) ReserveRunner ¶
func (q *Queries) ReserveRunner(ctx context.Context, reservationTimeout time.Time, deploymentName model.DeploymentName, labels []byte) (Runner, error)
Find an idle runner and reserve it for the given deployment.
func (*Queries) SetDeploymentDesiredReplicas ¶
func (*Queries) UpsertController ¶
func (*Queries) UpsertModule ¶
func (*Queries) UpsertRunner ¶
func (q *Queries) UpsertRunner(ctx context.Context, arg UpsertRunnerParams) (optional.Option[int64], error)
Upsert a runner and return the deployment ID that it is assigned to, if any. If the deployment name is null, then deployment_rel.id will be null, otherwise we try to retrieve the deployments.id using the key. If there is no corresponding deployment, then the deployment ID is -1 and the parent statement will fail due to a foreign key constraint.
type RunnerState ¶
type RunnerState string
const ( RunnerStateIdle RunnerState = "idle" RunnerStateReserved RunnerState = "reserved" RunnerStateAssigned RunnerState = "assigned" RunnerStateDead RunnerState = "dead" )
func (*RunnerState) Scan ¶
func (e *RunnerState) Scan(src interface{}) error
type Tx ¶
type Tx struct { *Queries // contains filtered or unexported fields }
func (*Tx) CommitOrRollback ¶
CommitOrRollback can be used in a defer statement to commit or rollback a transaction depending on whether the enclosing function returned an error.
func myFunc() (err error) { tx, err := db.Begin(ctx) if err != nil { return err } defer tx.CommitOrRollback(ctx, &err) ... }