repository

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStepRunIsNotPending = fmt.Errorf("step run is not pending")

Functions

func BoolPtr

func BoolPtr(b bool) *bool

func HashPassword

func HashPassword(pw string) (*string, error)

func JobRunStatusPtr

func JobRunStatusPtr(status db.JobRunStatus) *db.JobRunStatus

func StepRunStatusPtr

func StepRunStatusPtr(status db.StepRunStatus) *db.StepRunStatus

func StringPtr

func StringPtr(s string) *string

func VerifyPassword

func VerifyPassword(hashedPW, candidate string) (bool, error)

Types

type APITokenRepository added in v0.7.0

type APITokenRepository interface {
	GetAPITokenById(id string) (*db.APITokenModel, error)
	CreateAPIToken(opts *CreateAPITokenOpts) (*db.APITokenModel, error)
	RevokeAPIToken(id string) error
	ListAPITokensByTenant(tenantId string) ([]db.APITokenModel, error)
}

type CreateAPITokenOpts added in v0.7.0

type CreateAPITokenOpts struct {
	// The id of the token
	ID string `validate:"required,uuid"`

	// When the token expires
	ExpiresAt time.Time

	// (optional) A tenant ID for this API token
	TenantId *string `validate:"omitempty,uuid"`

	// (optional) A name for this API token
	Name *string `validate:"omitempty,max=255"`
}

type CreateDispatcherOpts

type CreateDispatcherOpts struct {
	ID string `validate:"required,uuid"`
}

type CreateEventOpts

type CreateEventOpts struct {
	// (required) the tenant id
	TenantId string `validate:"required,uuid"`

	// (required) the event key
	Key string `validate:"required"`

	// (optional) the event data
	Data *db.JSON

	// (optional) the event that this event is replaying
	ReplayedEvent *string `validate:"omitempty,uuid"`
}

type CreateGithubAppOAuthOpts added in v0.11.0

type CreateGithubAppOAuthOpts struct {
	// (required) the oauth provider's user id
	GithubUserID int `validate:"required"`

	// (required) the oauth provider's access token
	AccessToken []byte `validate:"required,min=1"`

	// (optional) the oauth provider's refresh token
	RefreshToken *[]byte

	// (optional) the oauth provider's expiry time
	ExpiresAt *time.Time

	// (optional) the oauth provider's configuration
	Config *types.JSON
}

type CreateGithubWebhookOpts added in v0.11.0

type CreateGithubWebhookOpts struct {
	// (required) the repo owner
	RepoOwner string `validate:"required"`

	// (required) the repo name
	RepoName string `validate:"required"`

	// (required) the signing secret
	SigningSecret []byte `validate:"required,min=1"`
}

func NewGithubWebhookCreateOpts added in v0.11.0

func NewGithubWebhookCreateOpts(
	enc encryption.EncryptionService,
	repoOwner string,
	repoName string,
) (opts *CreateGithubWebhookOpts, signingSecret string, err error)

type CreateGroupKeyRunOpts added in v0.8.0

type CreateGroupKeyRunOpts struct {
	// (optional) the input data
	Input []byte
}

type CreateInstallationOpts added in v0.11.0

type CreateInstallationOpts struct {
	// (required) the installation id
	InstallationID int `validate:"required"`

	// (required) the account ID
	AccountID int `validate:"required"`

	// (required) the account name
	AccountName string `validate:"required"`

	// (optional) the account avatar URL
	AccountAvatarURL *string

	// (optional) the installation settings URL
	InstallationSettingsURL *string

	// (optional) the installation configuration
	Config *types.JSON
}

type CreateSessionOpts

type CreateSessionOpts struct {
	ID string `validate:"required,uuid"`

	ExpiresAt time.Time `validate:"required"`

	// (optional) the user id, can be nil if session is unauthenticated
	UserId *string `validate:"omitempty,uuid"`

	Data *types.JSON
}

type CreateTenantInviteOpts

type CreateTenantInviteOpts struct {
	// (required) the invitee email
	InviteeEmail string `validate:"required,email"`

	// (required) the inviter email
	InviterEmail string `validate:"required,email"`

	// (required) when the invite expires
	ExpiresAt time.Time `validate:"required"`

	// (required) the role of the invitee
	Role string `validate:"omitempty,oneof=OWNER ADMIN MEMBER"`
}

type CreateTenantMemberOpts

type CreateTenantMemberOpts struct {
	Role   string `validate:"required,oneof=OWNER ADMIN MEMBER"`
	UserId string `validate:"required,uuid"`
}

type CreateTenantOpts

type CreateTenantOpts struct {
	// (required) the tenant name
	Name string `validate:"required"`

	// (required) the tenant slug
	Slug string `validate:"required,hatchetName"`

	// (optional) the tenant ID
	ID *string `validate:"omitempty,uuid"`
}

type CreateTickerOpts

type CreateTickerOpts struct {
	ID string `validate:"required,uuid"`
}

type CreateUserOpts

type CreateUserOpts struct {
	Email         string `validate:"required,email"`
	EmailVerified *bool
	Name          *string

	// auth options
	Password *string    `validate:"omitempty,required_without=OAuth,excluded_with=OAuth"`
	OAuth    *OAuthOpts `validate:"omitempty,required_without=Password,excluded_with=Password"`
}

type CreateWorkerOpts

type CreateWorkerOpts struct {
	// The id of the dispatcher
	DispatcherId string `validate:"required,uuid"`

	// The name of the worker
	Name string `validate:"required,hatchetName"`

	// The name of the service
	Services []string `validate:"dive,hatchetName"`

	// A list of actions this worker can run
	Actions []string `validate:"dive,actionId"`
}

type CreateWorkflowConcurrencyOpts added in v0.8.0

type CreateWorkflowConcurrencyOpts struct {
	// (required) the action id for getting the concurrency group
	Action string `validate:"required,actionId"`

	// (optional) the maximum number of concurrent workflow runs, default 1
	MaxRuns *int32

	// (optional) the strategy to use when the concurrency limit is reached, default CANCEL_IN_PROGRESS
	LimitStrategy *string `validate:"omitnil,oneof=CANCEL_IN_PROGRESS DROP_NEWEST QUEUE_NEWEST"`
}

type CreateWorkflowJobOpts

type CreateWorkflowJobOpts struct {
	// (required) the job name
	Name string `validate:"required,hatchetName"`

	// (optional) the job description
	Description *string

	// (optional) the job timeout
	Timeout *string

	// (required) the job steps
	Steps []CreateWorkflowStepOpts `validate:"required,min=1,dive"`
}

type CreateWorkflowJobRunOpts

type CreateWorkflowJobRunOpts struct {
	// (required) the job id
	JobId string `validate:"required,uuid"`

	// (optional) the job run input
	InputData []byte

	TriggeredBy string

	// (required) the job step runs
	StepRuns []CreateWorkflowStepRunOpts `validate:"required,min=1,dive"`

	// (optional) the job run requeue after time, if not set this defaults to 5 seconds after the
	// current time
	RequeueAfter *time.Time `validate:"omitempty"`
}

type CreateWorkflowRunOpts

type CreateWorkflowRunOpts struct {
	// (optional) the workflow run display name
	DisplayName *string

	// (required) the workflow version id
	WorkflowVersionId string `validate:"required,uuid"`

	ManualTriggerInput *string `` /* 197-byte string literal not displayed */

	// (optional) the event id that triggered the workflow run
	TriggeringEventId *string `` /* 204-byte string literal not displayed */

	// (optional) the cron schedule that triggered the workflow run
	Cron         *string `` /* 230-byte string literal not displayed */
	CronParentId *string `` /* 230-byte string literal not displayed */

	// (optional) the scheduled trigger
	ScheduledWorkflowId *string `` /* 200-byte string literal not displayed */

	// (required) the workflow jobs
	JobRuns []CreateWorkflowJobRunOpts `validate:"required,min=1,dive"`

	GetGroupKeyRun *CreateGroupKeyRunOpts `validate:"omitempty"`
}

func GetCreateWorkflowRunOptsFromCron

func GetCreateWorkflowRunOptsFromCron(cron, cronParentId string, workflowVersion *db.WorkflowVersionModel) (*CreateWorkflowRunOpts, error)

func GetCreateWorkflowRunOptsFromEvent

func GetCreateWorkflowRunOptsFromEvent(event *db.EventModel, workflowVersion *db.WorkflowVersionModel) (*CreateWorkflowRunOpts, error)

func GetCreateWorkflowRunOptsFromManual added in v0.9.0

func GetCreateWorkflowRunOptsFromManual(workflowVersion *db.WorkflowVersionModel, input []byte) (*CreateWorkflowRunOpts, error)

func GetCreateWorkflowRunOptsFromSchedule

func GetCreateWorkflowRunOptsFromSchedule(scheduledTrigger *db.WorkflowTriggerScheduledRefModel, workflowVersion *db.WorkflowVersionModel) (*CreateWorkflowRunOpts, error)

type CreateWorkflowRunPullRequestOpts added in v0.11.0

type CreateWorkflowRunPullRequestOpts struct {
	RepositoryOwner       string
	RepositoryName        string
	PullRequestID         int
	PullRequestTitle      string
	PullRequestNumber     int
	PullRequestHeadBranch string
	PullRequestBaseBranch string
	PullRequestState      string
}

type CreateWorkflowSchedulesOpts

type CreateWorkflowSchedulesOpts struct {
	ScheduledTriggers []time.Time

	Input *db.JSON
}

type CreateWorkflowStepOpts

type CreateWorkflowStepOpts struct {
	// (required) the step name
	ReadableId string `validate:"hatchetName"`

	// (required) the step action id
	Action string `validate:"required,actionId"`

	// (optional) the step timeout
	Timeout *string

	// (optional) the parents that this step depends on
	Parents []string `validate:"dive,hatchetName"`

	// (optional) the custom user data for the step, serialized as a json string
	UserData *string `validate:"omitnil,json"`

	// (optional) the step retry max
	Retries *int `validate:"omitempty,min=0"`
}

type CreateWorkflowStepRunOpts

type CreateWorkflowStepRunOpts struct {
	// (required) the step id
	StepId string `validate:"required,uuid"`
}

type CreateWorkflowTagOpts

type CreateWorkflowTagOpts struct {
	// (required) the tag name
	Name string `validate:"required"`

	// (optional) the tag color
	Color *string
}

type CreateWorkflowVersionOpts

type CreateWorkflowVersionOpts struct {
	// (required) the workflow name
	Name string `validate:"required,hatchetName"`

	Tags []CreateWorkflowTagOpts `validate:"dive"`

	// (optional) the workflow description
	Description *string `json:"description,omitempty"`

	// (optional) the workflow version
	Version *string `json:"version,omitempty"`

	// (optional) event triggers for the workflow
	EventTriggers []string

	// (optional) cron triggers for the workflow
	CronTriggers []string `validate:"dive,cron"`

	// (optional) scheduled triggers for the workflow
	ScheduledTriggers []time.Time

	// (required) the workflow jobs
	Jobs []CreateWorkflowJobOpts `validate:"required,min=1,dive"`

	// (optional) the workflow concurrency groups
	Concurrency *CreateWorkflowConcurrencyOpts `json:"concurrency,omitempty" validator:"omitnil"`
}

func (*CreateWorkflowVersionOpts) Checksum added in v0.7.0

func (o *CreateWorkflowVersionOpts) Checksum() (string, error)

type DispatcherRepository

type DispatcherRepository interface {
	// GetDispatcherForWorker returns the dispatcher connected to a given worker.
	GetDispatcherForWorker(workerId string) (*db.DispatcherModel, error)

	// CreateNewDispatcher creates a new dispatcher for a given tenant.
	CreateNewDispatcher(opts *CreateDispatcherOpts) (*db.DispatcherModel, error)

	// UpdateDispatcher updates a dispatcher for a given tenant.
	UpdateDispatcher(dispatcherId string, opts *UpdateDispatcherOpts) (*db.DispatcherModel, error)

	Delete(dispatcherId string) error

	// AddWorker adds a worker to a dispatcher.
	AddWorker(dispatcherId, workerId string) (*db.DispatcherModel, error)

	UpdateStaleDispatchers(onStale func(dispatcherId string, getValidDispatcherId func() string) error) error
}

type EventRepository

type EventRepository interface {
	// ListEvents returns all events for a given tenant.
	ListEvents(tenantId string, opts *ListEventOpts) (*ListEventResult, error)

	// ListEventKeys returns all unique event keys for a given tenant.
	ListEventKeys(tenantId string) ([]string, error)

	// GetEventById returns an event by id.
	GetEventById(id string) (*db.EventModel, error)

	// ListEventsById returns a list of events by id.
	ListEventsById(tenantId string, ids []string) ([]db.EventModel, error)

	// CreateEvent creates a new event for a given tenant.
	CreateEvent(ctx context.Context, opts *CreateEventOpts) (*db.EventModel, error)
}

type GetGroupKeyRunRepository added in v0.8.0

type GetGroupKeyRunRepository interface {
	// ListGetGroupKeyRuns returns a list of get group key runs for a tenant which match the given options.
	ListGetGroupKeyRuns(tenantId string, opts *ListGetGroupKeyRunsOpts) ([]db.GetGroupKeyRunModel, error)

	UpdateGetGroupKeyRun(tenantId, getGroupKeyRunId string, opts *UpdateGetGroupKeyRunOpts) (*db.GetGroupKeyRunModel, error)

	GetGroupKeyRunById(tenantId, getGroupKeyRunId string) (*db.GetGroupKeyRunModel, error)
}

type GithubRepository added in v0.11.0

type GithubRepository interface {
	CreateInstallation(githubUserId int, opts *CreateInstallationOpts) (*db.GithubAppInstallationModel, error)

	AddGithubUserIdToInstallation(installationID, accountID, githubUserId int) (*db.GithubAppInstallationModel, error)

	ReadGithubAppInstallationByID(installationId string) (*db.GithubAppInstallationModel, error)

	ReadGithubWebhookById(id string) (*db.GithubWebhookModel, error)

	ReadGithubWebhook(tenantId, repoOwner, repoName string) (*db.GithubWebhookModel, error)

	ReadGithubAppOAuthByGithubUserID(githubUserID int) (*db.GithubAppOAuthModel, error)

	CanUserAccessInstallation(installationId, userId string) (bool, error)

	ReadGithubAppInstallationByInstallationAndAccountID(installationID, accountID int) (*db.GithubAppInstallationModel, error)

	CreateGithubWebhook(tenantId string, opts *CreateGithubWebhookOpts) (*db.GithubWebhookModel, error)

	UpsertGithubAppOAuth(userId string, opts *CreateGithubAppOAuthOpts) (*db.GithubAppOAuthModel, error)

	DeleteInstallation(installationId, accountId int) (*db.GithubAppInstallationModel, error)

	ListGithubAppInstallationsByUserID(userId string) ([]db.GithubAppInstallationModel, error)

	UpdatePullRequest(tenantId, prId string, opts *UpdatePullRequestOpts) (*db.GithubPullRequestModel, error)

	GetPullRequest(tenantId, repoOwner, repoName string, prNumber int) (*db.GithubPullRequestModel, error)
}

type JobRunHasCycleError

type JobRunHasCycleError struct {
	JobName string
}

func (*JobRunHasCycleError) Error

func (e *JobRunHasCycleError) Error() string

type JobRunRepository

type JobRunRepository interface {
	ListAllJobRuns(opts *ListAllJobRunsOpts) ([]db.JobRunModel, error)

	GetJobRunById(tenantId, jobRunId string) (*db.JobRunModel, error)

	// SetJobRunStatusRunning resets the status of a job run to a RUNNING status. This is useful if a step
	// run is being manually replayed, but shouldn't be used by most callers.
	SetJobRunStatusRunning(tenantId, jobRunId string) error

	UpdateJobRun(tenantId, jobRunId string, opts *UpdateJobRunOpts) (*db.JobRunModel, error)

	GetJobRunLookupData(tenantId, jobRunId string) (*db.JobRunLookupDataModel, error)

	UpdateJobRunLookupData(tenantId, jobRunId string, opts *UpdateJobRunLookupDataOpts) error
}

type ListAllJobRunsOpts

type ListAllJobRunsOpts struct {
	TickerId *string

	NoTickerId *bool

	Status *db.JobRunStatus
}

type ListAllStepRunsOpts

type ListAllStepRunsOpts struct {
	TickerId *string

	NoTickerId *bool

	Status *db.StepRunStatus
}

type ListEventOpts

type ListEventOpts struct {
	// (optional) a list of event keys to filter by
	Keys []string

	// (optional) a list of workflow IDs to filter by
	Workflows []string

	// (optional) number of events to skip
	Offset *int

	// (optional) number of events to return
	Limit *int

	// (optional) a search query
	Search *string

	// (optional) the event that this event is replaying
	ReplayedEvent *string `validate:"omitempty,uuid"`

	// (optional) the order by field
	OrderBy *string `validate:"omitempty,oneof=createdAt"`

	// (optional) the order direction
	OrderDirection *string `validate:"omitempty,oneof=ASC DESC"`
}

type ListEventResult

type ListEventResult struct {
	Rows  []*dbsqlc.ListEventsRow
	Count int
}

type ListGetGroupKeyRunsOpts added in v0.8.0

type ListGetGroupKeyRunsOpts struct {
	Requeuable *bool

	Status *db.StepRunStatus
}

type ListPullRequestsForWorkflowRunOpts added in v0.11.0

type ListPullRequestsForWorkflowRunOpts struct {
	State *string
}

type ListStepRunsOpts

type ListStepRunsOpts struct {
	Requeuable *bool

	JobRunId *string

	WorkflowRunId *string

	Status *db.StepRunStatus
}

type ListTenantInvitesOpts

type ListTenantInvitesOpts struct {
	// (optional) the status of the invite
	Status *string `validate:"omitempty,oneof=PENDING ACCEPTED REJECTED"`

	// (optional) whether the invite has expired
	Expired *bool `validate:"omitempty"`
}

type ListTickerOpts

type ListTickerOpts struct {
	// Set this to only return tickers whose heartbeat is more recent than this time
	LatestHeartbeatAt *time.Time

	Active *bool
}

type ListWorkersOpts

type ListWorkersOpts struct {
	Action *string `validate:"omitempty,actionId"`

	LastHeartbeatAfter *time.Time
}

type ListWorkflowRunsOpts

type ListWorkflowRunsOpts struct {
	// (optional) the workflow id
	WorkflowId *string `validate:"omitempty,uuid"`

	// (optional) the workflow version id
	WorkflowVersionId *string `validate:"omitempty,uuid"`

	// (optional) the event id that triggered the workflow run
	EventId *string `validate:"omitempty,uuid"`

	// (optional) the group key for the workflow run
	GroupKey *string

	// (optional) the status of the workflow run
	Status *db.WorkflowRunStatus

	// (optional) number of events to skip
	Offset *int

	// (optional) number of events to return
	Limit *int

	// (optional) the order by field
	OrderBy *string `validate:"omitempty,oneof=createdAt"`

	// (optional) the order direction
	OrderDirection *string `validate:"omitempty,oneof=ASC DESC"`
}

type ListWorkflowRunsResult

type ListWorkflowRunsResult struct {
	Rows  []*dbsqlc.ListWorkflowRunsRow
	Count int
}

type ListWorkflowsOpts

type ListWorkflowsOpts struct {
	// (optional) number of workflows to skip
	Offset *int

	// (optional) number of workflows to return
	Limit *int

	// (optional) the event key to filter by
	EventKey *string
}

type ListWorkflowsResult

type ListWorkflowsResult struct {
	Rows  []*ListWorkflowsRow
	Count int
}

type ListWorkflowsRow

type ListWorkflowsRow struct {
	*db.WorkflowModel

	LatestRun *db.WorkflowRunModel
}

type OAuthOpts

type OAuthOpts struct {
	Provider       string     `validate:"required,oneof=google"`
	ProviderUserId string     `validate:"required,min=1"`
	AccessToken    []byte     `validate:"required,min=1"`
	RefreshToken   *[]byte    // optional
	ExpiresAt      *time.Time // optional
}

type Repository

type Repository interface {
	APIToken() APITokenRepository
	Event() EventRepository
	Tenant() TenantRepository
	TenantInvite() TenantInviteRepository
	Workflow() WorkflowRepository
	WorkflowRun() WorkflowRunRepository
	JobRun() JobRunRepository
	StepRun() StepRunRepository
	GetGroupKeyRun() GetGroupKeyRunRepository
	Github() GithubRepository
	Step() StepRepository
	Dispatcher() DispatcherRepository
	Ticker() TickerRepository
	Worker() WorkerRepository
	UserSession() UserSessionRepository
	User() UserRepository
}

type StepRepository

type StepRepository interface {
	// ListStepsByActions returns a list of steps for a tenant which match the action ids.
	ListStepsByActions(tenantId string, actions []string) ([]db.StepModel, error)
}

type StepRunRepository

type StepRunRepository interface {
	// ListAllStepRuns returns a list of all step runs which match the given options.
	ListAllStepRuns(opts *ListAllStepRunsOpts) ([]db.StepRunModel, error)

	// ListStepRuns returns a list of step runs for a tenant which match the given options.
	ListStepRuns(tenantId string, opts *ListStepRunsOpts) ([]db.StepRunModel, error)

	UpdateStepRun(tenantId, stepRunId string, opts *UpdateStepRunOpts) (*db.StepRunModel, *StepRunUpdateInfo, error)

	// UpdateStepRunOverridesData updates the overrides data field in the input for a step run. This returns the input
	// bytes.
	UpdateStepRunOverridesData(tenantId, stepRunId string, opts *UpdateStepRunOverridesDataOpts) ([]byte, error)

	UpdateStepRunInputSchema(tenantId, stepRunId string, schema []byte) ([]byte, error)

	GetStepRunById(tenantId, stepRunId string) (*db.StepRunModel, error)

	// QueueStepRun is like UpdateStepRun, except that it will only update the step run if it is in
	// a pending state.
	QueueStepRun(tenantId, stepRunId string, opts *UpdateStepRunOpts) (*db.StepRunModel, error)

	CancelPendingStepRuns(tenantId, jobRunId, reason string) error

	ListStartableStepRuns(tenantId, jobRunId, parentStepRunId string) ([]*dbsqlc.StepRun, error)

	ArchiveStepRunResult(tenantId, stepRunId string) error

	ListArchivedStepRunResults(tenantId, stepRunId string) ([]db.StepRunResultArchiveModel, error)

	GetFirstArchivedStepRunResult(tenantId, stepRunId string) (*db.StepRunResultArchiveModel, error)
}

type StepRunUpdateInfo added in v0.10.2

type StepRunUpdateInfo struct {
	JobRunFinalState      bool
	WorkflowRunFinalState bool
	WorkflowRunId         string
	WorkflowRunStatus     string
}

type TenantInviteRepository

type TenantInviteRepository interface {
	// CreateTenantInvite creates a new tenant invite with the given options
	CreateTenantInvite(tenantId string, opts *CreateTenantInviteOpts) (*db.TenantInviteLinkModel, error)

	// GetTenantInvite returns the tenant invite with the given id
	GetTenantInvite(id string) (*db.TenantInviteLinkModel, error)

	// ListTenantInvitesByEmail returns the list of tenant invites for the given invitee email
	ListTenantInvitesByEmail(email string) ([]db.TenantInviteLinkModel, error)

	// ListTenantInvitesByTenantId returns the list of tenant invites for the given tenant id
	ListTenantInvitesByTenantId(tenantId string, opts *ListTenantInvitesOpts) ([]db.TenantInviteLinkModel, error)

	// UpdateTenantInvite updates the tenant invite with the given id
	UpdateTenantInvite(id string, opts *UpdateTenantInviteOpts) (*db.TenantInviteLinkModel, error)

	// DeleteTenantInvite deletes the tenant invite with the given id
	DeleteTenantInvite(id string) error
}

type TenantRepository

type TenantRepository interface {
	// CreateTenant creates a new tenant.
	CreateTenant(opts *CreateTenantOpts) (*db.TenantModel, error)

	// ListTenants lists all tenants in the instance
	ListTenants() ([]db.TenantModel, error)

	// GetTenantByID returns the tenant with the given id
	GetTenantByID(tenantId string) (*db.TenantModel, error)

	// GetTenantBySlug returns the tenant with the given slug
	GetTenantBySlug(slug string) (*db.TenantModel, error)

	// CreateTenantMember creates a new member in the tenant
	CreateTenantMember(tenantId string, opts *CreateTenantMemberOpts) (*db.TenantMemberModel, error)

	// GetTenantMemberByID returns the tenant member with the given id
	GetTenantMemberByID(memberId string) (*db.TenantMemberModel, error)

	// GetTenantMemberByUserID returns the tenant member with the given user id
	GetTenantMemberByUserID(tenantId string, userId string) (*db.TenantMemberModel, error)

	// GetTenantMemberByEmail returns the tenant member with the given email
	GetTenantMemberByEmail(tenantId string, email string) (*db.TenantMemberModel, error)

	// ListTenantMembers returns the list of tenant members for the given tenant
	ListTenantMembers(tenantId string) ([]db.TenantMemberModel, error)

	// UpdateTenantMember updates the tenant member with the given id
	UpdateTenantMember(memberId string, opts *UpdateTenantMemberOpts) (*db.TenantMemberModel, error)

	// DeleteTenantMember deletes the tenant member with the given id
	DeleteTenantMember(memberId string) (*db.TenantMemberModel, error)
}

type TickerRepository

type TickerRepository interface {
	// CreateNewTicker creates a new ticker.
	CreateNewTicker(opts *CreateTickerOpts) (*db.TickerModel, error)

	// UpdateTicker updates a ticker.
	UpdateTicker(tickerId string, opts *UpdateTickerOpts) (*db.TickerModel, error)

	// ListTickers lists tickers.
	ListTickers(opts *ListTickerOpts) ([]db.TickerModel, error)

	GetTickerById(tickerId string) (*db.TickerModel, error)

	// Delete deletes a ticker.
	Delete(tickerId string) error

	// AddJobRun assigns a job run to a ticker.
	AddJobRun(tickerId string, jobRun *db.JobRunModel) (*db.TickerModel, error)

	// AddStepRun assigns a step run to a ticker.
	AddStepRun(tickerId, stepRunId string) (*db.TickerModel, error)

	// AddGetGroupKeyRun assigns a get group key run to a ticker.
	AddGetGroupKeyRun(tickerId, getGroupKeyRunId string) (*db.TickerModel, error)

	// AddCron assigns a cron to a ticker.
	AddCron(tickerId string, cron *db.WorkflowTriggerCronRefModel) (*db.TickerModel, error)

	// RemoveCron removes a cron from a ticker.
	RemoveCron(tickerId string, cron *db.WorkflowTriggerCronRefModel) (*db.TickerModel, error)

	// AddScheduledWorkflow assigns a scheduled workflow to a ticker.
	AddScheduledWorkflow(tickerId string, schedule *db.WorkflowTriggerScheduledRefModel) (*db.TickerModel, error)

	// RemoveScheduledWorkflow removes a scheduled workflow from a ticker.
	RemoveScheduledWorkflow(tickerId string, schedule *db.WorkflowTriggerScheduledRefModel) (*db.TickerModel, error)

	UpdateStaleTickers(onStale func(tickerId string, getValidTickerId func() string) error) error
}

type UpdateDispatcherOpts

type UpdateDispatcherOpts struct {
	LastHeartbeatAt *time.Time
}

type UpdateGetGroupKeyRunOpts added in v0.8.0

type UpdateGetGroupKeyRunOpts struct {
	RequeueAfter *time.Time

	ScheduleTimeoutAt *time.Time

	Status *db.StepRunStatus

	StartedAt *time.Time

	FailedAt *time.Time

	FinishedAt *time.Time

	CancelledAt *time.Time

	CancelledReason *string

	Error *string

	Output *string
}

type UpdateInstallationOpts added in v0.11.0

type UpdateInstallationOpts struct {
}

type UpdateJobRunLookupDataOpts

type UpdateJobRunLookupDataOpts struct {
	FieldPath []string
	Data      []byte
}

type UpdateJobRunOpts

type UpdateJobRunOpts struct {
	Status *db.JobRunStatus
}

type UpdatePullRequestOpts added in v0.11.0

type UpdatePullRequestOpts struct {
	Title *string

	State *string

	HeadBranch *string

	BaseBranch *string
}

type UpdateSessionOpts

type UpdateSessionOpts struct {
	UserId *string `validate:"omitempty,uuid"`

	Data *types.JSON
}

type UpdateStepRunOpts

type UpdateStepRunOpts struct {
	IsRerun bool

	RequeueAfter *time.Time

	ScheduleTimeoutAt *time.Time

	Status *db.StepRunStatus

	StartedAt *time.Time

	FailedAt *time.Time

	FinishedAt *time.Time

	CancelledAt *time.Time

	CancelledReason *string

	Error *string

	Input []byte

	Output []byte

	RetryCount *int
}

type UpdateStepRunOverridesDataOpts added in v0.11.0

type UpdateStepRunOverridesDataOpts struct {
	OverrideKey string
	Data        []byte
	CallerFile  *string
}

type UpdateTenantInviteOpts

type UpdateTenantInviteOpts struct {
	Status *string `validate:"omitempty,oneof=ACCEPTED REJECTED"`

	// (optional) the role of the invitee
	Role *string `validate:"omitempty,oneof=OWNER ADMIN MEMBER"`
}

type UpdateTenantMemberOpts

type UpdateTenantMemberOpts struct {
	Role *string `validate:"omitempty,oneof=OWNER ADMIN MEMBER"`
}

type UpdateTickerOpts

type UpdateTickerOpts struct {
	LastHeartbeatAt *time.Time
}

type UpdateUserOpts

type UpdateUserOpts struct {
	EmailVerified *bool
	Name          *string

	OAuth *OAuthOpts `validate:"omitempty"`
}

type UpdateWorkerOpts

type UpdateWorkerOpts struct {
	// The id of the dispatcher
	DispatcherId *string `validate:"omitempty,uuid"`

	// The status of the worker
	Status *db.WorkerStatus

	// When the last worker heartbeat was
	LastHeartbeatAt *time.Time

	// A list of actions this worker can run
	Actions []string `validate:"dive,actionId"`
}

type UpsertWorkflowDeploymentConfigOpts added in v0.11.0

type UpsertWorkflowDeploymentConfigOpts struct {
	// (required) the github app installation id
	GithubAppInstallationId string `validate:"required,uuid"`

	// (required) the github repository name
	GitRepoName string `validate:"required"`

	// (required) the github repository owner
	GitRepoOwner string `validate:"required"`

	// (required) the github repository branch
	GitRepoBranch string `validate:"required"`
}

type UserRepository

type UserRepository interface {
	// GetUserByID returns the user with the given id
	GetUserByID(id string) (*db.UserModel, error)

	// GetUserByEmail returns the user with the given email
	GetUserByEmail(email string) (*db.UserModel, error)

	// GetUserPassword returns the user password with the given id
	GetUserPassword(id string) (*db.UserPasswordModel, error)

	// CreateUser creates a new user with the given options
	CreateUser(*CreateUserOpts) (*db.UserModel, error)

	// UpdateUser updates the user with the given email
	UpdateUser(id string, opts *UpdateUserOpts) (*db.UserModel, error)

	// ListTenantMemberships returns the list of tenant memberships for the given user
	ListTenantMemberships(userId string) ([]db.TenantMemberModel, error)
}

type UserSessionRepository

type UserSessionRepository interface {
	Create(opts *CreateSessionOpts) (*db.UserSessionModel, error)
	Update(sessionId string, opts *UpdateSessionOpts) (*db.UserSessionModel, error)
	Delete(sessionId string) (*db.UserSessionModel, error)
	GetById(sessionId string) (*db.UserSessionModel, error)
}

UserSessionRepository represents the set of queries on the UserSession model

type WorkerRepository

type WorkerRepository interface {
	// ListWorkers lists workers for the tenant
	ListWorkers(tenantId string, opts *ListWorkersOpts) ([]WorkerWithStepCount, error)

	// ListRecentWorkerStepRuns lists recent step runs for a given worker
	ListRecentWorkerStepRuns(tenantId, workerId string) ([]db.StepRunModel, error)

	// CreateNewWorker creates a new worker for a given tenant.
	CreateNewWorker(tenantId string, opts *CreateWorkerOpts) (*db.WorkerModel, error)

	// UpdateWorker updates a worker for a given tenant.
	UpdateWorker(tenantId, workerId string, opts *UpdateWorkerOpts) (*db.WorkerModel, error)

	// DeleteWorker removes the worker from the database
	DeleteWorker(tenantId, workerId string) error

	// GetWorkerById returns a worker by its id.
	GetWorkerById(workerId string) (*db.WorkerModel, error)

	// AddStepRun assigns a step run to a worker.
	AddStepRun(tenantId, workerId, stepRunId string) error

	// AddGetGroupKeyRun assigns a get group key run to a worker.
	AddGetGroupKeyRun(tenantId, workerId, getGroupKeyRunId string) error
}

type WorkerWithStepCount

type WorkerWithStepCount struct {
	Worker       *db.WorkerModel
	StepRunCount int
}

type WorkflowRepository

type WorkflowRepository interface {
	// ListWorkflows returns all workflows for a given tenant.
	ListWorkflows(tenantId string, opts *ListWorkflowsOpts) (*ListWorkflowsResult, error)

	// CreateNewWorkflow creates a new workflow for a given tenant. It will create the parent
	// workflow based on the version's name.
	CreateNewWorkflow(tenantId string, opts *CreateWorkflowVersionOpts) (*db.WorkflowVersionModel, error)

	// CreateWorkflowVersion creates a new workflow version for a given tenant. This will fail if there is
	// not a parent workflow with the same name already in the database.
	CreateWorkflowVersion(tenantId string, opts *CreateWorkflowVersionOpts) (*db.WorkflowVersionModel, error)

	// CreateSchedules creates schedules for a given workflow version.
	CreateSchedules(tenantId, workflowVersionId string, opts *CreateWorkflowSchedulesOpts) ([]*db.WorkflowTriggerScheduledRefModel, error)

	// GetScheduledById returns a scheduled workflow by its id.
	GetScheduledById(tenantId, scheduleTriggerId string) (*db.WorkflowTriggerScheduledRefModel, error)

	// GetWorkflowById returns a workflow by its name. It will return db.ErrNotFound if the workflow does not exist.
	GetWorkflowById(workflowId string) (*db.WorkflowModel, error)

	// GetWorkflowByName returns a workflow by its name. It will return db.ErrNotFound if the workflow does not exist.
	GetWorkflowByName(tenantId, workflowName string) (*db.WorkflowModel, error)

	// ListWorkflowsForEvent returns the latest workflow versions for a given tenant that are triggered by the
	// given event.
	ListWorkflowsForEvent(ctx context.Context, tenantId, eventKey string) ([]db.WorkflowVersionModel, error)

	// GetWorkflowVersionById returns a workflow version by its id. It will return db.ErrNotFound if the workflow
	// version does not exist.
	GetWorkflowVersionById(tenantId, workflowId string) (*db.WorkflowVersionModel, error)

	// DeleteWorkflow deletes a workflow for a given tenant.
	DeleteWorkflow(tenantId, workflowId string) (*db.WorkflowModel, error)

	UpsertWorkflowDeploymentConfig(workflowId string, opts *UpsertWorkflowDeploymentConfigOpts) (*db.WorkflowDeploymentConfigModel, error)
}

type WorkflowRunRepository

type WorkflowRunRepository interface {
	// ListWorkflowRuns returns workflow runs for a given workflow version id.
	ListWorkflowRuns(tenantId string, opts *ListWorkflowRunsOpts) (*ListWorkflowRunsResult, error)

	// CreateNewWorkflowRun creates a new workflow run for a workflow version.
	CreateNewWorkflowRun(ctx context.Context, tenantId string, opts *CreateWorkflowRunOpts) (*db.WorkflowRunModel, error)

	// GetWorkflowRunById returns a workflow run by id.
	GetWorkflowRunById(tenantId, runId string) (*db.WorkflowRunModel, error)

	CreateWorkflowRunPullRequest(tenantId, workflowRunId string, opts *CreateWorkflowRunPullRequestOpts) (*db.GithubPullRequestModel, error)

	ListPullRequestsForWorkflowRun(tenantId, workflowRunId string, opts *ListPullRequestsForWorkflowRunOpts) ([]db.GithubPullRequestModel, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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