Documentation ¶
Overview ¶
Package state manages the state that the singleprocess server has, providing operations to mutate that state safely as needed.
Index ¶
- type IndexTime
- type InstanceLogs
- type State
- func (s *State) AppDelete(ref *pb.Ref_Application) error
- func (s *State) AppGet(ref *pb.Ref_Application) (*pb.Application, error)
- func (s *State) AppPut(app *pb.Application) (*pb.Application, error)
- func (s *State) ApplicationPollComplete(project *pb.Project, t time.Time) error
- func (s *State) ApplicationPollPeek(ws memdb.WatchSet) (*pb.Project, time.Time, error)
- func (s *State) ArtifactGet(ref *pb.Ref_Operation) (*pb.PushedArtifact, error)
- func (s *State) ArtifactLatest(ref *pb.Ref_Application, ws *pb.Ref_Workspace) (*pb.PushedArtifact, error)
- func (s *State) ArtifactList(ref *pb.Ref_Application, opts ...serverstate.ListOperationOption) ([]*pb.PushedArtifact, error)
- func (s *State) ArtifactPut(update bool, b *pb.PushedArtifact) error
- func (s *State) AuthMethodDelete(ref *pb.Ref_AuthMethod) error
- func (s *State) AuthMethodGet(ref *pb.Ref_AuthMethod) (*pb.AuthMethod, error)
- func (s *State) AuthMethodList() ([]*pb.AuthMethod, error)
- func (s *State) AuthMethodPut(v *pb.AuthMethod) error
- func (s *State) BuildGet(ref *pb.Ref_Operation) (*pb.Build, error)
- func (s *State) BuildLatest(ref *pb.Ref_Application, ws *pb.Ref_Workspace) (*pb.Build, error)
- func (s *State) BuildList(ref *pb.Ref_Application, opts ...serverstate.ListOperationOption) ([]*pb.Build, error)
- func (s *State) BuildPut(update bool, b *pb.Build) error
- func (s *State) Close() error
- func (s *State) ConfigGet(req *pb.ConfigGetRequest) ([]*pb.ConfigVar, error)
- func (s *State) ConfigGetWatch(req *pb.ConfigGetRequest, ws memdb.WatchSet) ([]*pb.ConfigVar, error)
- func (s *State) ConfigSet(vs ...*pb.ConfigVar) error
- func (s *State) ConfigSourceGet(req *pb.GetConfigSourceRequest) ([]*pb.ConfigSource, error)
- func (s *State) ConfigSourceGetWatch(req *pb.GetConfigSourceRequest, ws memdb.WatchSet) ([]*pb.ConfigSource, error)
- func (s *State) ConfigSourceSet(vs ...*pb.ConfigSource) error
- func (s *State) CreateSnapshot(w io.Writer) error
- func (s *State) DeploymentGet(ref *pb.Ref_Operation) (*pb.Deployment, error)
- func (s *State) DeploymentLatest(ref *pb.Ref_Application, ws *pb.Ref_Workspace) (*pb.Deployment, error)
- func (s *State) DeploymentList(ref *pb.Ref_Application, opts ...serverstate.ListOperationOption) ([]*pb.Deployment, error)
- func (s *State) DeploymentPut(update bool, b *pb.Deployment) error
- func (s *State) GetFileChangeSignal(scope *pb.Ref_Application) (string, error)
- func (s *State) HMACKeyCreateIfNotExist(id string, size int) (*pb.HMACKey, error)
- func (s *State) HMACKeyEmpty() bool
- func (s *State) HMACKeyGet(id string) (*pb.HMACKey, error)
- func (s *State) InstanceById(id string) (*serverstate.Instance, error)
- func (s *State) InstanceCreate(rec *serverstate.Instance) error
- func (s *State) InstanceDelete(id string) error
- func (s *State) InstanceExecById(id int64) (*serverstate.InstanceExec, error)
- func (s *State) InstanceExecConnect(ctx context.Context, id int64) (*serverstate.InstanceExec, error)
- func (s *State) InstanceExecCreateByDeployment(did string, exec *serverstate.InstanceExec) error
- func (s *State) InstanceExecCreateByTargetedInstance(id string, exec *serverstate.InstanceExec) error
- func (s *State) InstanceExecCreateForVirtualInstance(ctx context.Context, id string, exec *serverstate.InstanceExec) error
- func (s *State) InstanceExecDelete(id int64) error
- func (s *State) InstanceExecListByInstanceId(id string, ws memdb.WatchSet) ([]*serverstate.InstanceExec, error)
- func (s *State) InstanceExecWaitConnected(ctx context.Context, exec *serverstate.InstanceExec) error
- func (s *State) InstanceLogsById(id int64) (*InstanceLogs, error)
- func (s *State) InstanceLogsByInstanceId(id string) (*InstanceLogs, error)
- func (s *State) InstanceLogsCreate(id string, logs *InstanceLogs) error
- func (s *State) InstanceLogsDelete(id int64) error
- func (s *State) InstanceLogsListByInstanceId(id string, ws memdb.WatchSet) ([]*InstanceLogs, error)
- func (s *State) InstancesByApp(ref *pb.Ref_Application, refws *pb.Ref_Workspace, ws memdb.WatchSet) ([]*serverstate.Instance, error)
- func (s *State) InstancesByDeployment(id string, ws memdb.WatchSet) ([]*serverstate.Instance, error)
- func (s *State) JobAck(id string, ack bool) (*serverstate.Job, error)
- func (s *State) JobAssignForRunner(ctx context.Context, r *pb.Runner) (*serverstate.Job, error)
- func (s *State) JobById(id string, ws memdb.WatchSet) (*serverstate.Job, error)
- func (s *State) JobCancel(id string, force bool) error
- func (s *State) JobComplete(id string, result *pb.Job_Result, cerr error) error
- func (s *State) JobCreate(jobs ...*pb.Job) error
- func (s *State) JobExpire(id string) error
- func (s *State) JobHeartbeat(id string) error
- func (s *State) JobIsAssignable(ctx context.Context, jobpb *pb.Job) (bool, error)
- func (s *State) JobList(req *pb.ListJobsRequest) ([]*pb.Job, error)
- func (s *State) JobPeekForRunner(ctx context.Context, r *pb.Runner) (*serverstate.Job, error)
- func (s *State) JobProjectScopedRequest(pRef *pb.Ref_Project, jobTemplate *pb.Job) ([]*pb.QueueJobRequest, error)
- func (s *State) JobUpdate(id string, cb func(jobpb *pb.Job) error) error
- func (s *State) JobUpdateRef(id string, ref *pb.Job_DataSource_Ref) error
- func (s *State) JobsByTaskRef(task *pb.Task) (startJob *pb.Job, taskJob *pb.Job, stopJob *pb.Job, watchJob *pb.Job, ...)
- func (s *State) OnDemandRunnerConfigDefault() ([]*pb.Ref_OnDemandRunnerConfig, error)
- func (s *State) OnDemandRunnerConfigDelete(ref *pb.Ref_OnDemandRunnerConfig) error
- func (s *State) OnDemandRunnerConfigGet(ref *pb.Ref_OnDemandRunnerConfig) (*pb.OnDemandRunnerConfig, error)
- func (s *State) OnDemandRunnerConfigList() ([]*pb.OnDemandRunnerConfig, error)
- func (s *State) OnDemandRunnerConfigPut(o *pb.OnDemandRunnerConfig) error
- func (s *State) ProjectDelete(ref *pb.Ref_Project) error
- func (s *State) ProjectGet(ref *pb.Ref_Project) (*pb.Project, error)
- func (s *State) ProjectList() ([]*pb.Ref_Project, error)
- func (s *State) ProjectListWorkspaces(ref *pb.Ref_Project) ([]*pb.Workspace_Project, error)
- func (s *State) ProjectPollComplete(p *pb.Project, t time.Time) error
- func (s *State) ProjectPollPeek(ws memdb.WatchSet) (*pb.Project, time.Time, error)
- func (s *State) ProjectPut(p *pb.Project) error
- func (s *State) ProjectUpdateDataRef(ref *pb.Ref_Project, ws *pb.Ref_Workspace, dataRef *pb.Job_DataSource_Ref) error
- func (s *State) Prune() error
- func (s *State) ReleaseGet(ref *pb.Ref_Operation) (*pb.Release, error)
- func (s *State) ReleaseLatest(ref *pb.Ref_Application, ws *pb.Ref_Workspace) (*pb.Release, error)
- func (s *State) ReleaseList(ref *pb.Ref_Application, opts ...serverstate.ListOperationOption) ([]*pb.Release, error)
- func (s *State) ReleasePut(update bool, b *pb.Release) error
- func (s *State) RunnerAdopt(id string, implicit bool) error
- func (s *State) RunnerById(id string, ws memdb.WatchSet) (*pb.Runner, error)
- func (s *State) RunnerCreate(r *pb.Runner) error
- func (s *State) RunnerDelete(id string) error
- func (s *State) RunnerList() ([]*pb.Runner, error)
- func (s *State) RunnerOffline(id string) error
- func (s *State) RunnerReject(id string) error
- func (s *State) ServerConfigGet() (*pb.ServerConfig, error)
- func (s *State) ServerConfigSet(c *pb.ServerConfig) error
- func (s *State) ServerIdGet() (string, error)
- func (s *State) ServerIdSet(id string) error
- func (s *State) ServerURLTokenGet() (string, error)
- func (s *State) ServerURLTokenSet(token string) error
- func (s *State) StageRestoreSnapshot(r io.Reader) error
- func (s *State) StatusReportGet(ref *pb.Ref_Operation) (*pb.StatusReport, error)
- func (s *State) StatusReportLatest(ref *pb.Ref_Application, ws *pb.Ref_Workspace, ...) (*pb.StatusReport, error)
- func (s *State) StatusReportList(ref *pb.Ref_Application, opts ...serverstate.ListOperationOption) ([]*pb.StatusReport, error)
- func (s *State) StatusReportPut(update bool, report *pb.StatusReport) error
- func (s *State) TaskCancel(ref *pb.Ref_Task) error
- func (s *State) TaskDelete(ref *pb.Ref_Task) error
- func (s *State) TaskGet(ref *pb.Ref_Task) (*pb.Task, error)
- func (s *State) TaskList(req *pb.ListTaskRequest) ([]*pb.Task, error)
- func (s *State) TaskPut(t *pb.Task) error
- func (s *State) TriggerDelete(ref *pb.Ref_Trigger) error
- func (s *State) TriggerGet(ref *pb.Ref_Trigger) (*pb.Trigger, error)
- func (s *State) TriggerList(refws *pb.Ref_Workspace, refproj *pb.Ref_Project, refapp *pb.Ref_Application, ...) ([]*pb.Trigger, error)
- func (s *State) TriggerPut(t *pb.Trigger) error
- func (s *State) UserDelete(ref *pb.Ref_User) error
- func (s *State) UserEmpty() (bool, error)
- func (s *State) UserGet(ref *pb.Ref_User) (*pb.User, error)
- func (s *State) UserGetEmail(email string) (*pb.User, error)
- func (s *State) UserGetOIDC(iss, sub string) (*pb.User, error)
- func (s *State) UserList() ([]*pb.User, error)
- func (s *State) UserPut(user *pb.User) error
- func (s *State) WorkspaceGet(n string) (*pb.Workspace, error)
- func (s *State) WorkspaceList() ([]*pb.Workspace, error)
- func (s *State) WorkspaceListByApp(ref *pb.Ref_Application) ([]*pb.Workspace, error)
- func (s *State) WorkspaceListByProject(ref *pb.Ref_Project) ([]*pb.Workspace, error)
- func (s *State) WorkspacePut(workspace *pb.Workspace) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexTime ¶
type IndexTime struct { Field string // Asc if true will index with ascending order. Usually you want to // find the most recent data so this is false by default. Asc bool }
IndexTime indexes a time.Time field of a struct. TODO(mitchellh): test
type InstanceLogs ¶
InstanceLogs is a value that can be created to assist in coordination log writers and readers. It is a lighter weight version of an Instance used to manage virtual CEBs sending logs.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the primary API for state mutation for the server.
func TestState ¶
func TestState(t testing.T) *State
TestState returns an initialized State for testing.
func TestStateRestart ¶
TestStateRestart closes the given state and restarts it against the same DB file.
func (*State) AppDelete ¶
func (s *State) AppDelete(ref *pb.Ref_Application) error
AppDelete deletes an application from a project. This will also delete all the operations associated with this application.
func (*State) AppGet ¶
func (s *State) AppGet(ref *pb.Ref_Application) (*pb.Application, error)
AppGet retrieves the application..
func (*State) AppPut ¶
func (s *State) AppPut(app *pb.Application) (*pb.Application, error)
AppPut creates or updates the application.
func (*State) ApplicationPollComplete ¶
ApplicationPollComplete sets the next poll time for a given project given the app reference along with the time interval "t".
func (*State) ApplicationPollPeek ¶
ApplicationPollPeek peeks at the next available project that will be polled against, and returns the project as the result along with the poll time. The poll queuer will queue a job against every defined application for the given project. For more information on how ProjectPollPeek works, refer to the ProjectPollPeek docs.
func (*State) ArtifactGet ¶
func (s *State) ArtifactGet(ref *pb.Ref_Operation) (*pb.PushedArtifact, error)
ArtifactGet gets a artifact by ref.
func (*State) ArtifactLatest ¶
func (s *State) ArtifactLatest( ref *pb.Ref_Application, ws *pb.Ref_Workspace, ) (*pb.PushedArtifact, error)
ArtifactLatest gets the latest artifact that was completed successfully.
func (*State) ArtifactList ¶
func (s *State) ArtifactList( ref *pb.Ref_Application, opts ...serverstate.ListOperationOption, ) ([]*pb.PushedArtifact, error)
func (*State) ArtifactPut ¶
func (s *State) ArtifactPut(update bool, b *pb.PushedArtifact) error
ArtifactPut inserts or updates a artifact record.
func (*State) AuthMethodDelete ¶
func (s *State) AuthMethodDelete(ref *pb.Ref_AuthMethod) error
AuthMethodDelete deletes an auth method by reference.
func (*State) AuthMethodGet ¶
func (s *State) AuthMethodGet(ref *pb.Ref_AuthMethod) (*pb.AuthMethod, error)
AuthMethodGet gets a auth method by reference.
func (*State) AuthMethodList ¶
func (s *State) AuthMethodList() ([]*pb.AuthMethod, error)
AuthMethodList returns the list of projects.
func (*State) AuthMethodPut ¶
func (s *State) AuthMethodPut(v *pb.AuthMethod) error
AuthMethodPut creates or updates the given auth method. .
func (*State) BuildLatest ¶
func (s *State) BuildLatest( ref *pb.Ref_Application, ws *pb.Ref_Workspace, ) (*pb.Build, error)
BuildLatest gets the latest build that was completed successfully.
func (*State) BuildList ¶
func (s *State) BuildList( ref *pb.Ref_Application, opts ...serverstate.ListOperationOption, ) ([]*pb.Build, error)
func (*State) ConfigGetWatch ¶
func (s *State) ConfigGetWatch(req *pb.ConfigGetRequest, ws memdb.WatchSet) ([]*pb.ConfigVar, error)
ConfigGetWatch gets all the configuration for the given request. If a non-nil WatchSet is given, this can be watched for potential changes in the config.
func (*State) ConfigSet ¶
ConfigSet writes a configuration variable to the data store. Deletes are always ordered before writes so that you can't delete a new value in a single ConfigSet (you should never want to do this).
func (*State) ConfigSourceGet ¶
func (s *State) ConfigSourceGet(req *pb.GetConfigSourceRequest) ([]*pb.ConfigSource, error)
ConfigSourceGet gets all the configuration sources for the given request.
func (*State) ConfigSourceGetWatch ¶
func (s *State) ConfigSourceGetWatch(req *pb.GetConfigSourceRequest, ws memdb.WatchSet) ([]*pb.ConfigSource, error)
ConfigSourceGetWatch gets all the configuration sources for the given request. If a non-nil WatchSet is given, this can be watched for potential changes in the config source settings.
func (*State) ConfigSourceSet ¶
func (s *State) ConfigSourceSet(vs ...*pb.ConfigSource) error
ConfigSourceSet writes a set of config source values to the database.
func (*State) CreateSnapshot ¶
CreateSnapshot creates a database snapshot and writes it to the given writer.
This will NOT buffer data to w, so you should wrap w in a bufio.Writer if you want buffering.
func (*State) DeploymentGet ¶
func (s *State) DeploymentGet(ref *pb.Ref_Operation) (*pb.Deployment, error)
DeploymentGet gets a deployment by ref.
func (*State) DeploymentLatest ¶
func (s *State) DeploymentLatest( ref *pb.Ref_Application, ws *pb.Ref_Workspace, ) (*pb.Deployment, error)
DeploymentLatest gets the latest deployment that was completed successfully.
func (*State) DeploymentList ¶
func (s *State) DeploymentList( ref *pb.Ref_Application, opts ...serverstate.ListOperationOption, ) ([]*pb.Deployment, error)
func (*State) DeploymentPut ¶
func (s *State) DeploymentPut(update bool, b *pb.Deployment) error
DeploymentPut inserts or updates a deployment record.
func (*State) GetFileChangeSignal ¶
func (s *State) GetFileChangeSignal(scope *pb.Ref_Application) (string, error)
GetFileChangeSignal checks the metadata for the given application and its project, returning the value of FileChangeSignal that is most relevent.
func (*State) HMACKeyCreateIfNotExist ¶
HMACKeyCreateIfNotExist creates a new HMAC key with the given ID and size. If a key with the given ID exists already it will be returned.
func (*State) HMACKeyEmpty ¶
HMACKeyEmpty returns true if no HMAC keys have been created. This will be true only when the server is in a bootstrap state.
func (*State) HMACKeyGet ¶
HMACKeyGet gets an HMAC key by ID. This will return a nil value if it doesn't exist.
func (*State) InstanceById ¶
func (s *State) InstanceById(id string) (*serverstate.Instance, error)
func (*State) InstanceCreate ¶
func (s *State) InstanceCreate(rec *serverstate.Instance) error
func (*State) InstanceDelete ¶
func (*State) InstanceExecById ¶
func (s *State) InstanceExecById(id int64) (*serverstate.InstanceExec, error)
func (*State) InstanceExecConnect ¶ added in v0.9.0
func (s *State) InstanceExecConnect(ctx context.Context, id int64) (*serverstate.InstanceExec, error)
func (*State) InstanceExecCreateByDeployment ¶
func (s *State) InstanceExecCreateByDeployment(did string, exec *serverstate.InstanceExec) error
func (*State) InstanceExecCreateByTargetedInstance ¶
func (s *State) InstanceExecCreateByTargetedInstance(id string, exec *serverstate.InstanceExec) error
func (*State) InstanceExecCreateForVirtualInstance ¶
func (s *State) InstanceExecCreateForVirtualInstance(ctx context.Context, id string, exec *serverstate.InstanceExec) error
InstanceExecCreateForVirtualInstance registers the given InstanceExec record on the instance specified. The instance does not yet have to be known (as it may not yet have connected to the server) so this code will use memdb watchers to detect the instance as it connects and then register the exec.
func (*State) InstanceExecDelete ¶
func (*State) InstanceExecListByInstanceId ¶
func (s *State) InstanceExecListByInstanceId(id string, ws memdb.WatchSet) ([]*serverstate.InstanceExec, error)
func (*State) InstanceExecWaitConnected ¶ added in v0.9.0
func (s *State) InstanceExecWaitConnected(ctx context.Context, exec *serverstate.InstanceExec) error
func (*State) InstanceLogsById ¶
func (s *State) InstanceLogsById(id int64) (*InstanceLogs, error)
func (*State) InstanceLogsByInstanceId ¶
func (s *State) InstanceLogsByInstanceId(id string) (*InstanceLogs, error)
func (*State) InstanceLogsCreate ¶
func (s *State) InstanceLogsCreate(id string, logs *InstanceLogs) error
func (*State) InstanceLogsDelete ¶
func (*State) InstanceLogsListByInstanceId ¶
func (s *State) InstanceLogsListByInstanceId(id string, ws memdb.WatchSet) ([]*InstanceLogs, error)
func (*State) InstancesByApp ¶
func (s *State) InstancesByApp( ref *pb.Ref_Application, refws *pb.Ref_Workspace, ws memdb.WatchSet, ) ([]*serverstate.Instance, error)
func (*State) InstancesByDeployment ¶
func (s *State) InstancesByDeployment(id string, ws memdb.WatchSet) ([]*serverstate.Instance, error)
func (*State) JobAck ¶
JobAck acknowledges that a job has been accepted or rejected by the runner. If ack is false, then this will move the job back to the queued state and be eligible for assignment. Additionally, if a job is associated with an on-demand runner task, this func will progress the Tasks state machine depending on which job has currently been acked.
func (*State) JobAssignForRunner ¶
JobAssignForRunner will wait for and assign a job to a specific runner. This will automatically evaluate any conditions that the runner and/or job may have on assignability.
The assigned job is put into a "waiting" state until the runner acks the assignment which can be set with JobAck.
If ctx is provided and assignment has to block waiting for new jobs, this will cancel when the context is done.
func (*State) JobById ¶
func (s *State) JobById(id string, ws memdb.WatchSet) (*serverstate.Job, error)
JobById looks up a job by ID. The returned Job will be a deep copy of the job so it is safe to read/write. If the job can't be found, a nil result with no error is returned.
func (*State) JobCancel ¶
JobCancel marks a job as cancelled. This will set the internal state and request the cancel but if the job is running then it is up to downstream to listen for and react to Job changes for cancellation.
func (*State) JobComplete ¶
JobComplete marks a running job as complete. If an error is given, the job is marked as failed (a completed state). If no error is given, the job is marked as successful.
func (*State) JobCreate ¶
JobCreate queues the given jobs. If any job fails to queue, no jobs are queued. If partial failures are acceptable, call this multiple times with a single job.
func (*State) JobHeartbeat ¶
JobHeartbeat resets the heartbeat timer for a running job. If the job is not currently running this does nothing, it will not return an error. If the job doesn't exist then this will return an error.
func (*State) JobIsAssignable ¶
JobIsAssignable returns whether there is a registered runner that meets the requirements to run this job.
If this returns true, the job if queued should eventually be assigned successfully to a runner. An assignable result does NOT mean that it will be in queue a short amount of time.
Note the result is a point-in-time result. If the only candidate runners deregister between this returning true and queueing, the job may still sit in a queue indefinitely.
func (*State) JobPeekForRunner ¶
JobPeekForRunner effectively simulates JobAssignForRunner with two changes: (1) jobs are not actually assigned (they remain queued) and (2) this will not block if a job isn't available. If a job isn't available, this will return (nil, nil).
func (*State) JobProjectScopedRequest ¶
func (s *State) JobProjectScopedRequest( pRef *pb.Ref_Project, jobTemplate *pb.Job, ) ([]*pb.QueueJobRequest, error)
Given a Project Ref and a Job Template, this function will generate a slice of QueueJobRequests for every application inside the requested Project
func (*State) JobUpdate ¶
JobUpdate calls the given callback to update fields on the job data. The callback is called in the context of a database write lock so it should NOT compute anything and should be fast. The callback can return an error to abort the transaction.
Job states should NOT be modified using this, only metadata.
func (*State) JobUpdateRef ¶
func (s *State) JobUpdateRef(id string, ref *pb.Job_DataSource_Ref) error
JobUpdateRef sets the data_source_ref field for a job. This job can be in any state.
func (*State) JobsByTaskRef ¶ added in v0.9.0
func (s *State) JobsByTaskRef( task *pb.Task, ) (startJob *pb.Job, taskJob *pb.Job, stopJob *pb.Job, watchJob *pb.Job, err error)
GetJobsByTaskRef will look up every job triple by Task ref in a single memdb transaction. This is often used via the API for building out a complete picture of a task beyond the job ID refs.
func (*State) OnDemandRunnerConfigDefault ¶
func (s *State) OnDemandRunnerConfigDefault() ([]*pb.Ref_OnDemandRunnerConfig, error)
OnDemandRunnerConfigDefault returns the list of ondemandRunners that are defaults.
func (*State) OnDemandRunnerConfigDelete ¶
func (s *State) OnDemandRunnerConfigDelete(ref *pb.Ref_OnDemandRunnerConfig) error
OnDemandRunnerConfigDelete deletes a ondemandRunner by reference. This is a complete data delete. This will delete all operations associated with this ondemandRunner as well.
func (*State) OnDemandRunnerConfigGet ¶
func (s *State) OnDemandRunnerConfigGet(ref *pb.Ref_OnDemandRunnerConfig) (*pb.OnDemandRunnerConfig, error)
OnDemandRunnerConfigGet gets a ondemandRunner by reference.
func (*State) OnDemandRunnerConfigList ¶
func (s *State) OnDemandRunnerConfigList() ([]*pb.OnDemandRunnerConfig, error)
OnDemandRunnerConfigList returns the list of ondemandRunners.
func (*State) OnDemandRunnerConfigPut ¶
func (s *State) OnDemandRunnerConfigPut(o *pb.OnDemandRunnerConfig) error
OnDemandRunnerConfigPut creates or updates the given ondemandRunner.
Application changes will be ignored, you must use the Application APIs.
func (*State) ProjectDelete ¶
func (s *State) ProjectDelete(ref *pb.Ref_Project) error
ProjectDelete deletes a project by reference. This is a complete data delete. This will delete all operations associated with this project as well.
func (*State) ProjectGet ¶
ProjectGet gets a project by reference.
func (*State) ProjectList ¶
func (s *State) ProjectList() ([]*pb.Ref_Project, error)
ProjectList returns the list of projects.
func (*State) ProjectListWorkspaces ¶
func (s *State) ProjectListWorkspaces(ref *pb.Ref_Project) ([]*pb.Workspace_Project, error)
ProjectListWorkspaces returns the list of workspaces that a project is in.
func (*State) ProjectPollComplete ¶
ProjectPollComplete sets the next poll time for the given project to the time "t" plus the interval time for the project.
func (*State) ProjectPollPeek ¶
ProjectPollPeek returns the next project that should be polled. This will return (nil,nil) if there are no projects to poll currently.
This is a "peek" operation so it does not update the project's next poll time. Therefore, calling this multiple times should return the same result unless a function like ProjectPollComplete is called.
If ws is non-nil, the WatchSet can be watched for any changes to projects to poll. This can be watched, for example, to detect when projects to poll are added. This is important functionality since callers may be sleeping on a deadline for awhile when a new project is inserted to poll immediately.
func (*State) ProjectPut ¶
ProjectPut creates or updates the given project.
Application changes will be ignored, you must use the Application APIs.
func (*State) ProjectUpdateDataRef ¶
func (s *State) ProjectUpdateDataRef( ref *pb.Ref_Project, ws *pb.Ref_Workspace, dataRef *pb.Job_DataSource_Ref, ) error
ProjectUpdateDataRef updates the latest data ref used for a project. This data is available via the APIs for querying workspaces.
func (*State) Prune ¶
Prune should be called in a on a regular interval to allow State to prune out old data.
func (*State) ReleaseGet ¶
ReleaseGet gets a release by ref.
func (*State) ReleaseLatest ¶
func (s *State) ReleaseLatest( ref *pb.Ref_Application, ws *pb.Ref_Workspace, ) (*pb.Release, error)
ReleaseLatest gets the latest release that was completed successfully.
func (*State) ReleaseList ¶
func (s *State) ReleaseList( ref *pb.Ref_Application, opts ...serverstate.ListOperationOption, ) ([]*pb.Release, error)
func (*State) ReleasePut ¶
ReleasePut inserts or updates a release record.
func (*State) RunnerAdopt ¶
RunnerAdopt marks a runner as adopted.
If "implicit" is true, then this runner is implicitly adopted and the state goes to "PREADOPTED". This means that the runner instance itself was never explicitly adopted, but it already has a valid token so it is accepted.
func (*State) RunnerById ¶
func (*State) RunnerDelete ¶
RunnerDelete permanently deletes the runner record including any on-disk state such as adoption state. This effectively "forgets" the runner.
func (*State) RunnerList ¶
RunnerList lists all the runners. This isn't a list of only online runners; this is ALL runners the database currently knows about.
func (*State) RunnerOffline ¶
RunnerOffline marks that a runner has gone offline. This is the preferred approach to deregistering a runner, since this will keep the adoption state around.
func (*State) RunnerReject ¶
RunnerReject marks a runner as rejected.
func (*State) ServerConfigGet ¶
func (s *State) ServerConfigGet() (*pb.ServerConfig, error)
ServerConfigGet gets the server configuration.
func (*State) ServerConfigSet ¶
func (s *State) ServerConfigSet(c *pb.ServerConfig) error
ServerConfigSet writes the server configuration.
func (*State) ServerIdGet ¶
ServerIdGet gets the server ID.
func (*State) ServerIdSet ¶
ServerIdSet writes the server ID.
func (*State) ServerURLTokenGet ¶
ServerURLTokenGet gets the server URL token.
func (*State) ServerURLTokenSet ¶
ServerURLTokenSet writes the server URL token.
func (*State) StageRestoreSnapshot ¶
StageRestoreSnapshot stages a database restore for the next server restart. This will create a temporary file alongside the data file so we must have write access to the directory containing the database.
func (*State) StatusReportGet ¶
func (s *State) StatusReportGet(ref *pb.Ref_Operation) (*pb.StatusReport, error)
get status report by referenced operation
func (*State) StatusReportLatest ¶
func (s *State) StatusReportLatest( ref *pb.Ref_Application, ws *pb.Ref_Workspace, filter func(*pb.StatusReport) (bool, error), ) (*pb.StatusReport, error)
StatusReportLatest gets the latest generated status report
func (*State) StatusReportList ¶
func (s *State) StatusReportList( ref *pb.Ref_Application, opts ...serverstate.ListOperationOption, ) ([]*pb.StatusReport, error)
func (*State) StatusReportPut ¶
func (s *State) StatusReportPut(update bool, report *pb.StatusReport) error
create or update the latest status report
func (*State) TaskCancel ¶ added in v0.9.0
TaskCancel cancels a tasks jobs by task id or run job id reference. NOTE(briancain): this way means each cancel is its own transaction and commit, not the greatest. Previously I attempted to implement this with taskCancel where the entire job triple was canceled inside a single transaction. This ended up deadlocking because when we cancel a job, we also call a `db.Update` on each job when we update its state in the database. This caused a deadlock. For now we cancel each job separately.
func (*State) TaskDelete ¶
TaskDelete deletes a task by reference.
func (*State) TriggerDelete ¶
func (s *State) TriggerDelete(ref *pb.Ref_Trigger) error
TriggerDelete deletes a trigger by reference.
func (*State) TriggerGet ¶
TriggerGet gets a trigger by reference.
func (*State) TriggerList ¶
func (s *State) TriggerList( refws *pb.Ref_Workspace, refproj *pb.Ref_Project, refapp *pb.Ref_Application, tagFilter []string, ) ([]*pb.Trigger, error)
TriggerList returns the list of triggers.
func (*State) TriggerPut ¶
TriggerPut creates or updates the given Trigger.
func (*State) UserDelete ¶
UserDelete deletes a user by reference.
func (*State) UserGetEmail ¶
UserGetEmail gets a user by by email lookup. This will return a codes.NotFound error if the user is not found.
func (*State) UserGetOIDC ¶
UserGetOIDC gets a user by by OIDC link lookup. This will return a codes.NotFound error if the user is not found.
func (*State) UserPut ¶
UserPut creates or updates the given user. If the user has no ID set then an ID will be written directly to the parameter.
func (*State) WorkspaceGet ¶
WorkspaceGet gets a workspace with a specific name. If it doesn't exist, this will return an error with codes.NotFound.
func (*State) WorkspaceList ¶
WorkspaceList lists all the workspaces.
func (*State) WorkspaceListByApp ¶
WorkspaceListByApp lists all the workspaces used by a specific application.
func (*State) WorkspaceListByProject ¶
WorkspaceListByProject lists all the workspaces used by a project.
Source Files ¶
- app_operation.go
- application.go
- artifact.go
- auth_method.go
- build.go
- config.go
- config_source.go
- db.go
- deployment.go
- hmac.go
- index_time.go
- instance.go
- instance_exec.go
- instance_logs.go
- job.go
- job_assigned.go
- ondemand_runner.go
- project.go
- prune.go
- release.go
- runner.go
- server_config.go
- server_id.go
- server_urltoken.go
- snapshot.go
- state.go
- status_report.go
- task.go
- testing.go
- trigger.go
- ulid.go
- user.go
- workspace.go