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
- func WithModelContext(ctx context.Context, mc *ModelContext) context.Context
- 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 ModelContext
- type NodeManager
- type Process
- type ProcessGroup
- type ProcessManager
- func (p *ProcessManager) Clean(ctx context.Context)
- func (p *ProcessManager) CreateGroup(ctx context.Context, taskID string) string
- func (p *ProcessManager) Run(ctx context.Context, command string, processGroupID string, projectID string) string
- func (p *ProcessManager) Start(ctx context.Context, processID string) error
- func (p *ProcessManager) Stop(ctx context.Context, processID string) error
- type Project
- type ProjectCachePathGetter
- type ProjectPathGetter
- type Step
- func (s Step) Commands(ctx context.Context, after *string, before *string, first *int, last *int) (CommandConnection, error)
- func (Step) IsNode()
- func (s Step) Projects(ctx context.Context, after *string, before *string, first *int, last *int) (ProjectConnection, error)
- func (s Step) Task(ctx context.Context) Task
- type System
- func (System) IsNode()
- func (s System) JobMetrics(ctx context.Context) JobMetrics
- func (s System) Jobs(ctx context.Context, after *string, before *string, first *int, last *int, ...) (JobConnection, error)
- func (s System) LogEntries(ctx context.Context, after *string, before *string, first *int, last *int, ...) (LogEntryConnection, error)
- func (s System) LogMetrics(ctx context.Context) LogMetrics
- func (s System) ProcessGroups(ctx context.Context, after *string, before *string, first *int, last *int, ...) (ProcessGroupConnection, error)
- func (s System) ProcessMetrics(ctx context.Context) ProcessMetrics
- type Task
- type User
- func (User) IsNode()
- func (u User) Projects(ctx context.Context, after *string, before *string, first *int, last *int) (ProjectConnection, error)
- func (u User) Workspace(ctx context.Context, slug string) *Workspace
- func (u User) Workspaces(ctx context.Context, after *string, before *string, first *int, last *int) (WorkspaceConnection, error)
- type Workspace
- func (w Workspace) IsAhead(ctx context.Context) bool
- func (w Workspace) IsBehind(ctx context.Context) bool
- func (w Workspace) IsCloned(ctx context.Context) bool
- func (w Workspace) IsCloning(ctx context.Context) bool
- func (Workspace) IsNode()
- func (w Workspace) IsPulling(ctx context.Context) bool
- func (w Workspace) Projects(ctx context.Context, after *string, before *string, first *int, last *int) (ProjectConnection, error)
- func (w Workspace) Tasks(ctx context.Context, 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.
const DateFormat = "2006-01-02T15:04:05-0700"
DateFormat is the date format used throughout the app.
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().
func WithModelContext ¶ added in v0.1.5
func WithModelContext(ctx context.Context, mc *ModelContext) context.Context
WithModelContext adds a model context to a Go context.
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.
type JobManager ¶
type JobManager struct {
// contains filtered or unexported fields
}
JobManager manages creating and running jobs.
func NewJobManager ¶
func NewJobManager(concurrency int) *JobManager
NewJobManager creates a JobManager with given concurrency.
func (*JobManager) Add ¶
func (j *JobManager) Add( modelCtx *ModelContext, name string, ownerID string, priority JobPriority, fn func(ctx context.Context) error, ) string
Add adds a job to the queue and returns the job's ID.
func (*JobManager) Stop ¶
func (j *JobManager) Stop(modelCtx *ModelContext, id string) error
Stop cancels a running job.
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.
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 ModelContext ¶ added in v0.1.5
type ModelContext struct {
Nodes *NodeManager
Log *Logger
Jobs *JobManager
PM *ProcessManager
Subs *pubsub.PubSub
GetProjectPath ProjectPathGetter
GetProjectCachePath ProjectCachePathGetter
ViewerID string
SystemID string
}
ModelContext contains variables that are passed to model functions.
func GetModelContext ¶ added in v0.1.5
func GetModelContext(ctx context.Context) *ModelContext
GetModelContext retrieves the model context from a Go context.
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(ctx context.Context) ProcessGroup
ProcessGroup returns the ProcessGroup 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( ctx context.Context, after *string, before *string, first *int, last *int, ) (ProcessConnection, error)
Processes returns the ProcessGroup's processes.
func (ProcessGroup) Status ¶
func (p ProcessGroup) Status(ctx context.Context) ProcessStatus
Status returns the status of the ProcessGroup.
type ProcessManager ¶
type ProcessManager struct {
// contains filtered or unexported fields
}
ProcessManager manages creating and running jobs.
func NewProcessManager ¶
func NewProcessManager() *ProcessManager
NewProcessManager creates a ProcessManager.
func (*ProcessManager) Clean ¶
func (p *ProcessManager) Clean(ctx context.Context)
Clean terminates all running processes.
func (*ProcessManager) CreateGroup ¶
func (p *ProcessManager) CreateGroup(ctx context.Context, taskID string) string
CreateGroup creates a new ProcessGroup and returns its ID.
func (*ProcessManager) Run ¶
func (p *ProcessManager) Run( ctx context.Context, command string, processGroupID string, projectID string, ) string
Run launches a new Process and adds it to a ProcessGroup.
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( ctx context.Context, after *string, before *string, first *int, last *int, ) (CommitConnection, error)
Commits returns paginated commits.
type ProjectCachePathGetter ¶ added in v0.1.5
ProjectCachePathGetter is a function that returns the path to a project's cache.
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( ctx context.Context, 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 ¶
JobMetrics returns the JobMetrics node.
func (System) Jobs ¶
func (s System) Jobs( ctx context.Context, after *string, before *string, first *int, last *int, status []JobStatus, ) (JobConnection, error)
Jobs returns paginated jobs.
func (System) LogEntries ¶
func (s System) LogEntries( ctx context.Context, after *string, before *string, first *int, last *int, level []LogLevel, ownerID *string, ) (LogEntryConnection, error)
LogEntries returns paginated log entries.
func (System) LogMetrics ¶
LogMetrics returns the LogMetrics node.
func (System) ProcessGroups ¶
func (s System) ProcessGroups( ctx context.Context, after *string, before *string, first *int, last *int, status []ProcessStatus, ) (ProcessGroupConnection, error)
ProcessGroups returns paginated process groups.
func (System) 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.
type User ¶
User contains all the data of the person using the app.
func (User) Projects ¶
func (u User) Projects( ctx context.Context, after *string, before *string, first *int, last *int, ) (ProjectConnection, error)
Projects returns the user's projects.
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.