datastore

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

View Source
const (
	TargetStatusInitialize TargetStatus = "initialize"
	TargetStatusActive                  = "active"
	TargetStatusRunning                 = "running"
	TargetStatusSuspend                 = "suspend"
	TargetStatusDeleted                 = "deleted"
	TargetStatusErr                     = "error"
)

TargetStatus variables

View Source
const (
	RunnerStatusCreated        RunnerStatus = "created"
	RunnerStatusCompleted                   = "completed"
	RunnerStatusReachHardLimit              = "reach_hard_limit"
)

RunnerStatus variables

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Error values

Functions

func UpdateTargetStatus added in v1.4.2

func UpdateTargetStatus(ctx context.Context, ds Datastore, targetID uuid.UUID, newStatus TargetStatus, description string) error

UpdateTargetStatus update datastore

Types

type Datastore

type Datastore interface {
	CreateTarget(ctx context.Context, target Target) error
	GetTarget(ctx context.Context, id uuid.UUID) (*Target, error)
	GetTargetByScope(ctx context.Context, gheDomain, scope string) (*Target, error)
	ListTargets(ctx context.Context) ([]Target, error)
	DeleteTarget(ctx context.Context, id uuid.UUID) error

	// Deprecated: Use datastore.UpdateTargetStatus.
	UpdateTargetStatus(ctx context.Context, targetID uuid.UUID, newStatus TargetStatus, description string) error

	EnqueueJob(ctx context.Context, job Job) error
	ListJobs(ctx context.Context) ([]Job, error)
	DeleteJob(ctx context.Context, id uuid.UUID) error

	CreateRunner(ctx context.Context, runner Runner) error
	ListRunners(ctx context.Context) ([]Runner, error)
	GetRunner(ctx context.Context, id uuid.UUID) (*Runner, error)
	DeleteRunner(ctx context.Context, id uuid.UUID, deletedAt time.Time, reason RunnerStatus) error
}

Datastore is persistent storage

type Job

type Job struct {
	UUID           uuid.UUID      `db:"uuid"`
	GHEDomain      sql.NullString `db:"ghe_domain"`
	Repository     string         `db:"repository"` // repo (:owner/:repo)
	CheckEventJSON string         `db:"check_event"`
	TargetID       uuid.UUID      `db:"target_id"`
	CreatedAt      time.Time      `db:"created_at" json:"created_at"`
	UpdatedAt      time.Time      `db:"updated_at" json:"updated_at"`
}

Job is a runner job

type ResourceType

type ResourceType int

ResourceType is runner machine spec

const (
	ResourceTypeUnknown ResourceType = iota
	ResourceTypeNano
	ResourceTypeMicro
	ResourceTypeSmall
	ResourceTypeMedium
	ResourceTypeLarge
	ResourceTypeXLarge
	ResourceType2XLarge
	ResourceType3XLarge
	ResourceType4XLarge
)

ResourceTypes variables

func UnmarshalResourceType added in v1.2.1

func UnmarshalResourceType(src interface{}) ResourceType

UnmarshalResourceType cast type to ResourceType

func UnmarshalResourceTypePb added in v1.2.1

func UnmarshalResourceTypePb(in pb.ResourceType) ResourceType

UnmarshalResourceTypePb cast type from pb.ResourceType to ResourceType

func UnmarshalResourceTypeString added in v1.2.1

func UnmarshalResourceTypeString(in string) ResourceType

UnmarshalResourceTypeString cast type from string to ResourceType

func (ResourceType) MarshalJSON added in v1.4.1

func (r ResourceType) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json Marshaler interface

func (*ResourceType) Scan added in v1.2.1

func (r *ResourceType) Scan(src interface{}) error

Scan implements the database/sql Scanner interface

func (ResourceType) String

func (r ResourceType) String() string

String implement interface for fmt.Stringer

func (ResourceType) ToPb added in v1.2.0

func (r ResourceType) ToPb() pb.ResourceType

ToPb convert type of protobuf

func (*ResourceType) UnmarshalJSON added in v1.4.1

func (r *ResourceType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the encoding/json Unmarshaler interface

func (ResourceType) Value added in v1.2.1

func (r ResourceType) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface

type Runner

type Runner struct {
	UUID      uuid.UUID    `db:"runner_id"`
	ShoesType string       `db:"shoes_type"`
	IPAddress string       `db:"ip_address"`
	TargetID  uuid.UUID    `db:"target_id"`
	CloudID   string       `db:"cloud_id"`
	Deleted   bool         `db:"deleted"`
	Status    RunnerStatus `db:"status"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt time.Time    `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

Runner is a runner

type RunnerStatus added in v1.3.0

type RunnerStatus string

RunnerStatus is status for runner

type Target

type Target struct {
	UUID                uuid.UUID      `db:"uuid" json:"id"`
	Scope               string         `db:"scope" json:"scope"`                                 // repo (:owner/:repo) or org (:organization)
	GitHubPersonalToken string         `db:"github_personal_token" json:"github_personal_token"` // TODO: encrypt
	GHEDomain           sql.NullString `db:"ghe_domain" json:"ghe_domain"`
	ResourceType        ResourceType   `db:"resource_type" json:"resource_type"`
	RunnerUser          sql.NullString `db:"runner_user" json:"runner_user"`
	RunnerVersion       sql.NullString `db:"runner_version" json:"runner_version"`
	ProviderURL         sql.NullString `db:"provider_url" json:"provider_url"`
	Status              TargetStatus   `db:"status" json:"status"`
	StatusDescription   sql.NullString `db:"status_description" json:"status_description"`
	CreatedAt           time.Time      `db:"created_at" json:"created_at"`
	UpdatedAt           time.Time      `db:"updated_at" json:"updated_at"`
}

Target is a target repository that will add auto-scaling runner.

func (*Target) CanReceiveJob added in v1.4.0

func (t *Target) CanReceiveJob() bool

CanReceiveJob check status in target

func (*Target) OwnerRepo

func (t *Target) OwnerRepo() (string, string)

OwnerRepo return :owner and :repo

func (*Target) RepoURL

func (t *Target) RepoURL() string

RepoURL return repository URL.

type TargetStatus added in v1.3.0

type TargetStatus string

TargetStatus is status for target

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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