db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggedRollback

func LoggedRollback(z *zap.Logger, tx Transaction)

func Setup

func Setup(z *zap.Logger, db DB) error

Setup both sets up the db and also initializes fundemental data.

Types

type DB

type DB interface {
	Connect(context.Context) error
	Setup(context.Context) error
	Teardown(context.Context) error

	Debug() DB

	// Begina a transaction.
	Begin(context.Context) (Transaction, error)

	Transaction(context.Context, func(tx DB) error) error

	// Returns sdkerrors.ErrAlreadyExists if either id or name is duplicate.
	CreateProject(context.Context, sdktypes.Project) error

	// Returns sdkerrors.ErrNotFound if not found.
	GetProjectByID(context.Context, sdktypes.ProjectID) (sdktypes.Project, error)

	// Returns sdkerrors.ErrNotFound if not found.
	GetProjectByName(context.Context, sdktypes.Name) (sdktypes.Project, error)

	ListProjects(context.Context) ([]sdktypes.Project, error)

	GetProjectResources(context.Context, sdktypes.ProjectID) (map[string][]byte, error)

	SetProjectResources(context.Context, sdktypes.ProjectID, map[string][]byte) error

	// Returns sdkerrors.ErrAlreadyExists if either id or name is duplicate.
	CreateEnv(context.Context, sdktypes.Env) error

	// Returns sdkerrors.ErrNotFound if id is not found.
	GetEnvByID(context.Context, sdktypes.EnvID) (sdktypes.Env, error)

	// Returns sdkerrors.ErrNotFound if name is not found.
	GetEnvByName(context.Context, sdktypes.ProjectID, sdktypes.Name) (sdktypes.Env, error)

	ListProjectEnvs(context.Context, sdktypes.ProjectID) ([]sdktypes.Env, error)

	SetEnvVar(context.Context, sdktypes.EnvVar) error

	GetEnvVars(context.Context, sdktypes.EnvID) ([]sdktypes.EnvVar, error)

	// Return sdkerrors.ErrNotFound if var not found.
	RevealEnvVar(context.Context, sdktypes.EnvID, sdktypes.Symbol) (string, error)

	// This is idempotent.
	SaveEvent(context.Context, sdktypes.Event) error
	GetEventByID(context.Context, sdktypes.EventID) (sdktypes.Event, error)
	ListEvents(context.Context, sdkservices.ListEventsFilter) ([]sdktypes.Event, error)
	AddEventRecord(context.Context, sdktypes.EventRecord) error
	ListEventRecords(context.Context, sdkservices.ListEventRecordsFilter) ([]sdktypes.EventRecord, error)
	GetLatestEventSequence(context.Context) (uint64, error)

	CreateMapping(context.Context, sdktypes.Mapping) error
	GetMapping(context.Context, sdktypes.MappingID) (sdktypes.Mapping, error)
	DeleteMapping(context.Context, sdktypes.MappingID) error
	ListMappings(context.Context, sdkservices.ListMappingsFilter) ([]sdktypes.Mapping, error)

	GetBuild(ctx context.Context, buildID sdktypes.BuildID) (sdktypes.Build, error)
	ListBuilds(ctx context.Context, filter sdkservices.ListBuildsFilter) ([]sdktypes.Build, error)
	GetBuildData(ctx context.Context, id sdktypes.BuildID) ([]byte, error)
	SaveBuild(ctx context.Context, Build sdktypes.Build, data []byte) error
	DeleteBuild(ctx context.Context, buildID sdktypes.BuildID) error

	CreateConnection(ctx context.Context, conn sdktypes.Connection) error
	UpdateConnection(ctx context.Context, conn sdktypes.Connection) error
	DeleteConnection(ctx context.Context, id sdktypes.ConnectionID) error
	GetConnection(ctx context.Context, id sdktypes.ConnectionID) (sdktypes.Connection, error)
	ListConnections(ctx context.Context, filter sdkservices.ListConnectionsFilter) ([]sdktypes.Connection, error)

	GetDeployment(ctx context.Context, id sdktypes.DeploymentID) (sdktypes.Deployment, error)

	// Returns deployments in ascending order by creation time.
	ListDeployments(ctx context.Context, filter sdkservices.ListDeploymentsFilter) ([]sdktypes.Deployment, error)
	UpdateDeploymentState(ctx context.Context, id sdktypes.DeploymentID, state sdktypes.DeploymentState) error
	CreateDeployment(ctx context.Context, deployment sdktypes.Deployment) error
	DeleteDeployment(ctx context.Context, deploymentID sdktypes.DeploymentID) error

	CreateIntegration(ctx context.Context, i sdktypes.Integration) error
	UpdateIntegration(ctx context.Context, i sdktypes.Integration) error
	DeleteIntegration(ctx context.Context, id sdktypes.IntegrationID) error
	GetIntegration(ctx context.Context, id sdktypes.IntegrationID) (sdktypes.Integration, error)
	ListIntegrations(ctx context.Context, filter sdkservices.ListIntegrationsFilter) ([]sdktypes.Integration, error)

	CreateSession(ctx context.Context, session sdktypes.Session) error
	GetSession(ctx context.Context, sessionID sdktypes.SessionID) (sdktypes.Session, error)
	GetSessionLog(ctx context.Context, sessionID sdktypes.SessionID) (sdktypes.SessionLog, error)
	UpdateSessionState(ctx context.Context, sessionID sdktypes.SessionID, state sdktypes.SessionState) error
	AddSessionPrint(ctx context.Context, sessionID sdktypes.SessionID, print string) error
	ListSessions(ctx context.Context, f sdkservices.ListSessionsFilter) ([]sdktypes.Session, int, error)

	CreateSessionCall(ctx context.Context, sessionID sdktypes.SessionID, data sdktypes.SessionCallSpec) error
	GetSessionCallSpec(ctx context.Context, sessionID sdktypes.SessionID, seq uint32) (sdktypes.SessionCallSpec, error)

	StartSessionCallAttempt(ctx context.Context, sessionID sdktypes.SessionID, seq uint32) (uint32, error)
	CompleteSessionCallAttempt(ctx context.Context, sessionID sdktypes.SessionID, seq, attempt uint32, complete sdktypes.SessionCallAttemptComplete) error
	GetSessionCallAttemptResult(ctx context.Context, sessionID sdktypes.SessionID, seq uint32, attempt int64) (sdktypes.SessionCallAttemptResult, error)

	SaveSignal(ctx context.Context, signalID string, workflowID string, connectionID sdktypes.ConnectionID, eventName string) (string, error)
	GetSignal(ctx context.Context, signalID string) (scheme.Signal, error)
	RemoveSignal(ctx context.Context, signalID string) error
	ListSignalsWaitingOnConnection(ctx context.Context, connectionID sdktypes.ConnectionID, eventType string) ([]scheme.Signal, error)
}

type Transaction

type Transaction interface {
	DB
	Commit() error

	// Does nothing if already committed.
	Rollback() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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