Documentation
¶
Overview ¶
Package models contains the models and auto generated models for the app.
Index ¶
- Constants
- Variables
- func CreateLineWriter(write func(ownerID, message string, a ...interface{}) string, ownerID string, ...) io.WriteCloser
- type Config
- type DateTime
- type Hash
- type Job
- type JobManager
- type LogEntry
- type Logger
- func (l *Logger) Add(level LogLevel, ownerID string, message string) (string, error)
- func (l *Logger) Debug(message string, a ...interface{}) string
- func (l *Logger) DebugWithOwner(ownerID string, message string, a ...interface{}) string
- func (l *Logger) Error(message string, a ...interface{}) string
- func (l *Logger) ErrorWithOwner(ownerID string, message string, a ...interface{}) string
- func (l *Logger) Info(message string, a ...interface{}) string
- func (l *Logger) InfoWithOwner(ownerID string, message string, a ...interface{}) string
- func (l *Logger) Warning(message string, a ...interface{}) string
- func (l *Logger) WarningWithOwner(ownerID string, message string, a ...interface{}) string
- type NodeManager
- type Process
- type ProcessGroup
- type ProcessManager
- func (p *ProcessManager) Clean(ctx context.Context)
- func (p *ProcessManager) CreateGroup(taskID string) string
- func (p *ProcessManager) Run(command string, processGroupID string, projectID string) string
- func (p *ProcessManager) Start(processID string) error
- func (p *ProcessManager) Stop(processID string) error
- type Project
- type ProjectPathGetter
- type Step
- func (s Step) Commands(nodes *NodeManager, after *string, before *string, first *int, last *int) (CommandConnection, error)
- func (Step) IsNode()
- func (s Step) Projects(nodes *NodeManager, after *string, before *string, first *int, last *int) (ProjectConnection, error)
- func (s Step) Task(nodes *NodeManager) Task
- type System
- func (System) IsNode()
- func (s System) JobMetrics(nodes *NodeManager) JobMetrics
- func (s System) Jobs(nodes *NodeManager, after *string, before *string, first *int, last *int, ...) (JobConnection, error)
- func (s System) LogEntries(nodes *NodeManager, after *string, before *string, first *int, last *int, ...) (LogEntryConnection, error)
- func (s System) LogMetrics(nodes *NodeManager) LogMetrics
- func (s System) ProcessGroups(nodes *NodeManager, after *string, before *string, first *int, last *int, ...) (ProcessGroupConnection, error)
- func (s System) ProcessMetrics(nodes *NodeManager) ProcessMetrics
- type Task
- type User
- func (User) IsNode()
- func (u User) Projects(nodes *NodeManager, after *string, before *string, first *int, last *int) (ProjectConnection, error)
- func (u User) Workspace(nodes *NodeManager, slug string) *Workspace
- func (u User) Workspaces(nodes *NodeManager, after *string, before *string, first *int, last *int) (WorkspaceConnection, error)
- type Workspace
- func (w Workspace) IsAhead(nodes *NodeManager) bool
- func (w Workspace) IsBehind(nodes *NodeManager) bool
- func (w Workspace) IsCloned(nodes *NodeManager, getProjectPath ProjectPathGetter) bool
- func (w Workspace) IsCloning(nodes *NodeManager) bool
- func (Workspace) IsNode()
- func (w Workspace) IsPulling(nodes *NodeManager) bool
- func (w Workspace) Projects(nodes *NodeManager, after *string, before *string, first *int, last *int) (ProjectConnection, error)
- func (w Workspace) Tasks(nodes *NodeManager, after *string, before *string, first *int, last *int) (TaskConnection, error)
Constants ¶
const ( WorkspaceUpdated = "WORKSPACE_UPDATED" ProjectUpdated = "PROJECT_UPDATED" TaskUpdated = "TASK_UPDATED" JobUpserted = "JOB_UPSERTED" JobMetricsUpdated = "JOB_METRICS_UPDATED" ProcessGroupUpserted = "PROCESS_GROUP_UPSERTED" ProcessUpserted = "PROCESS_UPSERTED" ProcessMetricsUpdated = "PROCESS_METRICS_UPDATED" LogEntryAdded = "LOG_ENTRY_ADDED" LogMetricsUpdated = "LOG_METRICS_UPDATED" )
Message types.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrType = errors.New("wrong type") ErrFirstNegative = errors.New("first cannot be negative") ErrLastNegative = errors.New("last cannot be negative") ErrNotRunning = errors.New("project isn't running") ErrNotStopped = errors.New("project isn't stopped") )
Errors.
Functions ¶
func CreateLineWriter ¶
func CreateLineWriter( write func(ownerID, message string, a ...interface{}) string, ownerID string, a ...interface{}, ) io.WriteCloser
CreateLineWriter creates a writer with a line splitter. Remember to call close().
Types ¶
type Config ¶
type Config struct {
Filename string `json:"filename"`
Workspaces []struct {
Slug string `json:"slug"`
Name string `json:"name"`
Description string `json:"description"`
Notes *string `json:"notes"`
Projects []struct {
Slug string `json:"slug"`
Repository string `json:"repository"`
Branch string `json:"branch"`
Description *string `json:"description"`
} `json:"projects"`
Tasks []struct {
Name string `json:"name"`
Steps []struct {
Projects []string `json:"projects"`
Commands []string `json:"commands"`
} `json:"tasks"`
} `json:"tasks"`
} `json:"workspaces"`
}
Config contains all the data in a YAML config file.
func LoadConfigYAML ¶
LoadConfigYAML loads a config from a YAML file.
func (Config) CreateNodes ¶
func (c Config) CreateNodes(nodes *NodeManager, userID string) error
CreateNodes creates nodes for the content of the config. The user node must already exists
type DateTime ¶
DateTime holds a date.
func (DateTime) MarshalGQL ¶
MarshalGQL implements the graphql.Marshaler interface.
func (*DateTime) UnmarshalGQL ¶
UnmarshalGQL implements the graphql.Marshaler interface.
type Hash ¶
type Hash string
Hash holds a Git hash. TODO: change to bytes.
func (Hash) MarshalGQL ¶
MarshalGQL implements the graphql.Marshaler interface.
func (*Hash) UnmarshalGQL ¶
UnmarshalGQL implements the graphql.Marshaler interface.
type Job ¶
type Job struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt DateTime `json:"createdAt"`
UpdatedAt DateTime `json:"updatedAt"`
Status JobStatus `json:"status"`
Priority JobPriority `json:"priority"`
OwnerID string `json:"ownerID"`
}
Job represents a job in the app.
func (Job) Owner ¶
func (j Job) Owner(nodes *NodeManager) Node
Owner returns the node associated with the job.
type JobManager ¶
type JobManager struct {
// contains filtered or unexported fields
}
JobManager manages creating and running jobs.
func NewJobManager ¶
func NewJobManager( nodes *NodeManager, log *Logger, subs *pubsub.PubSub, concurrency int, systemID string, ) *JobManager
NewJobManager creates a JobManager with given concurrency.
type LogEntry ¶
type LogEntry struct {
ID string `json:"id"`
Level LogLevel `json:"level"`
CreatedAt DateTime `json:"createdAt"`
Message string `json:"message"`
OwnerID string `json:"ownerID"`
}
LogEntry represents a log entry in the app.
func (LogEntry) Owner ¶
func (l LogEntry) Owner(nodes *NodeManager) Node
Owner returns the node associated with the LogEntry.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logs messages.
func NewLogger ¶
func NewLogger( nodes *NodeManager, subs *pubsub.PubSub, cap int, level LogLevel, systemID string, ) *Logger
NewLogger creates a Logger with given capacity and level.
func (*Logger) DebugWithOwner ¶
DebugWithOwner adds a debug entry with an owner.
func (*Logger) ErrorWithOwner ¶
ErrorWithOwner adds an error entry with an owner.
func (*Logger) InfoWithOwner ¶
InfoWithOwner adds an info entry with an owner.
type NodeManager ¶
type NodeManager struct {
// contains filtered or unexported fields
}
NodeManager helps manage nodes with global IDs.
func (*NodeManager) MustLoad ¶
func (n *NodeManager) MustLoad(id string) Node
MustLoad loads a node or panics if it doesn't exist.
func (*NodeManager) RLock ¶
func (n *NodeManager) RLock(ids ...string)
RLock read-locks the given IDs.
func (*NodeManager) RUnlock ¶
func (n *NodeManager) RUnlock(ids ...string)
RUnlock read-unlocks the given IDs.
func (*NodeManager) Unlock ¶
func (n *NodeManager) Unlock(ids ...string)
Unlock unlocks the given IDs.
type Process ¶
type Process struct {
ID string `json:"id"`
Command string `json:"command"`
ProcessGroupID string `json:"processGroupID"`
ProjectID string `json:"projectID"`
Status ProcessStatus `json:"status"`
}
Process represents a process in the app.
func (Process) ProcessGroup ¶
func (p Process) ProcessGroup(nodes *NodeManager) ProcessGroup
ProcessGroup returns the ProcessGroup associated with the Process.
func (Process) Project ¶
func (p Process) Project(nodes *NodeManager) Project
Project returns the Project associated with the Process.
type ProcessGroup ¶
type ProcessGroup struct {
ID string `json:"id"`
CreatedAt DateTime `json:"createdAt"`
TaskID string `json:"taskID"`
ProcessIDs []string `json:"processIDs"`
}
ProcessGroup represents a ProcessGroup in the app.
func (ProcessGroup) IsNode ¶
func (ProcessGroup) IsNode()
IsNode tells gqlgen that it implements Node.
func (ProcessGroup) Processes ¶
func (p ProcessGroup) Processes( nodes *NodeManager, after *string, before *string, first *int, last *int, ) (ProcessConnection, error)
Processes returns the ProcessGroup's processes.
func (ProcessGroup) Status ¶
func (p ProcessGroup) Status(nodes *NodeManager) ProcessStatus
Status returns the status of the ProcessGroup.
func (ProcessGroup) Task ¶
func (p ProcessGroup) Task(nodes *NodeManager) Task
Task returns the Task associated with the ProcessGroup.
type ProcessManager ¶
type ProcessManager struct {
// contains filtered or unexported fields
}
ProcessManager manages creating and running jobs.
func NewProcessManager ¶
func NewProcessManager( nodes *NodeManager, log *Logger, subs *pubsub.PubSub, getProjectPath ProjectPathGetter, systemID string, ) *ProcessManager
NewProcessManager creates a ProcessManager. TODO: Add Clean() method to terminate all processes on shutdown.
func (*ProcessManager) Clean ¶
func (p *ProcessManager) Clean(ctx context.Context)
Clean terminates all running processes.
func (*ProcessManager) CreateGroup ¶
func (p *ProcessManager) CreateGroup(taskID string) string
CreateGroup creates a new ProcessGroup and returns its ID.
func (*ProcessManager) Run ¶
func (p *ProcessManager) Run( command string, processGroupID string, projectID string, ) string
Run launches a new Process and adds it to a ProcessGroup.
func (*ProcessManager) Start ¶
func (p *ProcessManager) Start(processID string) error
Start starts a process that was stopped.
func (*ProcessManager) Stop ¶
func (p *ProcessManager) Stop(processID string) error
Stop stops a running process.
type Project ¶
type Project struct {
ID string `json:"id"`
Slug string `json:"slug"`
Repository string `json:"repository"`
Branch string `json:"branch"`
Description *string `json:"description"`
WorkspaceID string `json:"workspaceID"`
CommitIDs []string `json:"commitIDs"`
Tasks []Task `json:"projects"`
IsLoadingCommits bool `json:"isLoadingCommits"`
IsCloning bool `json:"isCloning"`
IsPulling bool `json:"isPulling"`
IsBehind bool `json:"isBehind"`
IsAhead bool `json:"isAhead"`
}
Project represents a project in the app.
func (Project) Commits ¶
func (p Project) Commits( nodes *NodeManager, after *string, before *string, first *int, last *int, ) (CommitConnection, error)
Commits returns paginated commits.
func (Project) IsCloned ¶
func (p Project) IsCloned( nodes *NodeManager, getProjectPath ProjectPathGetter, ) bool
IsCloned checks if the project is cloned.
func (Project) Workspace ¶
func (p Project) Workspace(nodes *NodeManager) Workspace
Workspace returns the workspace associated with the project.
type ProjectPathGetter ¶
ProjectPathGetter is a function that returns the path to a project.
type Step ¶
type Step struct {
ID string `json:"id"`
ProjectIDs []string `json:"projectIDs"`
CommandIDs []string `json:"commandIDs"`
TaskID string `json:"taskID"`
}
Step represents a task step in the app.
func (Step) Commands ¶
func (s Step) Commands( nodes *NodeManager, after *string, before *string, first *int, last *int, ) (CommandConnection, error)
Commands returns the step's commands.
type System ¶
type System struct {
ID string `json:"id"`
JobIDs []string `json:"jobsIDs"`
JobMetricsID string `json:"jobMetricsID"`
ProcessGroupIDs []string `json:"processGroupIDs"`
ProcessMetricsID string `json:"processMetricsID"`
LogEntryIDs []string `json:"logEntryIDs"`
LogMetricsID string `json:"logMetricsID"`
}
System contains information about the running app.
func (System) JobMetrics ¶
func (s System) JobMetrics(nodes *NodeManager) JobMetrics
JobMetrics returns the JobMetrics node.
func (System) Jobs ¶
func (s System) Jobs( nodes *NodeManager, after *string, before *string, first *int, last *int, status []JobStatus, ) (JobConnection, error)
Jobs returns paginated jobs.
func (System) LogEntries ¶
func (s System) LogEntries( nodes *NodeManager, after *string, before *string, first *int, last *int, level []LogLevel, ownerID *string, ) (LogEntryConnection, error)
LogEntries returns paginated log entries.
func (System) LogMetrics ¶
func (s System) LogMetrics(nodes *NodeManager) LogMetrics
LogMetrics returns the LogMetrics node.
func (System) ProcessGroups ¶
func (s System) ProcessGroups( nodes *NodeManager, after *string, before *string, first *int, last *int, status []ProcessStatus, ) (ProcessGroupConnection, error)
ProcessGroups returns paginated process groups.
func (System) ProcessMetrics ¶
func (s System) ProcessMetrics(nodes *NodeManager) ProcessMetrics
ProcessMetrics returns the ProcessMetrics node.
type Task ¶
type Task struct {
ID string `json:"id"`
Name string `json:"name"`
StepIDs []string `json:"stepIDs"`
WorkspaceID string `json:"workspace"`
IsRunning bool `json:"isRunning"`
}
Task represents a workspace task in the app.
func (Task) Steps ¶
func (t Task) Steps( nodes *NodeManager, after *string, before *string, first *int, last *int, ) (StepConnection, error)
Steps returns the task's steps.
func (Task) Workspace ¶
func (t Task) Workspace(nodes *NodeManager) Workspace
Workspace returns the task's workspace.
type User ¶
User contains all the data of the person using the app.
func (User) Projects ¶
func (u User) Projects( nodes *NodeManager, after *string, before *string, first *int, last *int, ) (ProjectConnection, error)
Projects returns the user's projects.
func (User) Workspace ¶
func (u User) Workspace(nodes *NodeManager, slug string) *Workspace
Workspace finds a workspace.
func (User) Workspaces ¶
func (u User) Workspaces( nodes *NodeManager, after *string, before *string, first *int, last *int, ) (WorkspaceConnection, error)
Workspaces returns the user's workspaces.
type Workspace ¶
type Workspace struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
ProjectIDs []string `json:"projectIDs"`
TaskIDs []string `json:"taskIDs"`
Description string `json:"description"`
Notes *string `json:"notes"`
}
Workspace represents a workspace in the app.
func (Workspace) IsAhead ¶
func (w Workspace) IsAhead(nodes *NodeManager) bool
IsAhead returns true if any of the projects is ahead origin.
func (Workspace) IsBehind ¶
func (w Workspace) IsBehind(nodes *NodeManager) bool
IsBehind returns true if any of the projects is behind origin.
func (Workspace) IsCloned ¶
func (w Workspace) IsCloned(nodes *NodeManager, getProjectPath ProjectPathGetter) bool
IsCloned returns true if all the projects are cloned.
func (Workspace) IsCloning ¶
func (w Workspace) IsCloning(nodes *NodeManager) bool
IsCloning returns true if any of the projects is cloning.
func (Workspace) IsPulling ¶
func (w Workspace) IsPulling(nodes *NodeManager) bool
IsPulling returns true if any of the projects is pulling.