backend

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NatsConnectionTimeout       = 350 * time.Millisecond
	NatsConnectionRetryInterval = 100 * time.Millisecond
	NatsRequestTimeout          = 10 * time.Second

	StreamPrefix = "gha_"
)
View Source
const (
	RunnerRegular       = "firecracker"
	RunnerHigh          = "f0"
	RunnerLabelDetector = "label-detector"
)

Variables

This section is empty.

Functions

func CollectConsumerInfo added in v0.0.14

func CollectConsumerInfo(nc *nats.Conn, streamName string) ([]*jetstream.ConsumerInfo, error)

func CollectStreamInfo added in v0.0.14

func CollectStreamInfo(nc *nats.Conn, names []string) ([]*jetstream.StreamInfo, error)

func ConvertToHumanReadableDateType added in v0.0.14

func ConvertToHumanReadableDateType(timestamp *time.Time) string

ConvertToHumanReadableDateType returns the elapsed time since timestamp in human-readable approximation. ref: https://github.com/kubernetes/apimachinery/blob/v0.21.1/pkg/api/meta/table/table.go#L63-L70 But works for timestamp before or after now.

func ErrorToAPIStatus

func ErrorToAPIStatus(err error) *metav1.Status

ErrorToAPIStatus converts an error to an metav1.Status object.

func GRPCCode

func GRPCCode(err error) gcerrors.ErrorCode

GRPCCode extracts the gRPC status code and converts it into an ErrorCode. It returns Unknown if the error isn't from gRPC.

func HTTPStatusFromCode

func HTTPStatusFromCode(code gcerrors.ErrorCode) int32

HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto See: https://github.com/grpc-ecosystem/grpc-gateway/blob/v2.11.3/runtime/errors.go#L34-L77

func NewConnection

func NewConnection(addr, credFile string) (nc *nats.Conn, err error)

NewConnection creates a new NATS connection

func RenderConsumerInfo added in v0.0.14

func RenderConsumerInfo(consumers []*jetstream.ConsumerInfo) []byte

func RenderStreamInfo added in v0.0.14

func RenderStreamInfo(streams []*jetstream.StreamInfo) []byte

func ReportStatus added in v0.0.14

func ReportStatus(nc *nats.Conn, name string, s Status, comments ...string)

func RunsOnSelfHosted added in v0.0.14

func RunsOnSelfHosted(e *github.WorkflowJobEvent) (string, bool)

func SubmitPayload

func SubmitPayload(gh *github.Client, nc *nats.Conn, r *http.Request, secretToken []byte) error

func UseHighPriorityRunner added in v0.0.14

func UseHighPriorityRunner(gh *github.Client, org string, private bool) string

func UseRegularRunner added in v0.0.14

func UseRegularRunner(gh *github.Client, org string, private bool) string

Types

type MachineStatus added in v0.0.14

type MachineStatus struct {
	Name      string
	Status    Status
	Timestamp time.Time
	Comment   string
}

func (MachineStatus) Strings added in v0.0.14

func (ms MachineStatus) Strings() []string

type Manager

type Manager struct {
	Provider api.Interface
	// contains filtered or unexported fields
}

func New

func New(nc *nats.Conn, opts Options) *Manager

func (*Manager) EnsureStreams added in v0.0.14

func (mgr *Manager) EnsureStreams(jsOpts ...jetstream.JetStreamOpt) error

func (*Manager) ProcessCompletedJobs added in v0.0.14

func (mgr *Manager) ProcessCompletedJobs() error

func (*Manager) ProcessCompletedJobs__ added in v0.0.14

func (mgr *Manager) ProcessCompletedJobs__() error

func (*Manager) ProcessCompletedMsg

func (mgr *Manager) ProcessCompletedMsg(payload []byte) (*github.WorkflowJobEvent, error)

func (*Manager) RunVMs added in v0.0.14

func (mgr *Manager) RunVMs()

func (*Manager) Start

func (mgr *Manager) Start(ctx context.Context, jsOpts ...jetstream.JetStreamOpt) error

type NATSOptions

type NATSOptions struct {
	Addr     string
	CredFile string
}

func NewNATSOptions

func NewNATSOptions() *NATSOptions

func (*NATSOptions) AddFlags

func (opts *NATSOptions) AddFlags(fs *pflag.FlagSet)

type Options

type Options struct {
	AckWait time.Duration

	// hostname
	Name       string
	NumWorkers int

	Provider string
}

func DefaultOptions

func DefaultOptions() Options

func (*Options) AddFlags

func (opts *Options) AddFlags(fs *pflag.FlagSet)

type Status added in v0.0.14

type Status string
const (
	StatusStarting Status = "starting"
	StatusStarted  Status = "started"
	StatusWaiting  Status = "waiting"
	StatusPicked   Status = "picked"
	StatusStopping Status = "stopping"
	StatusStopped  Status = "stopped"
)

type StatusReporter added in v0.0.14

type StatusReporter struct {
	// contains filtered or unexported fields
}

func NewStatusReporter added in v0.0.14

func NewStatusReporter(nc *nats.Conn) (*StatusReporter, error)

func (*StatusReporter) GenerateHTMLReport added in v0.0.14

func (sp *StatusReporter) GenerateHTMLReport() (string, error)

func (*StatusReporter) GenerateMarkdownReport added in v0.0.14

func (sp *StatusReporter) GenerateMarkdownReport() ([]byte, error)

Jump to

Keyboard shortcuts

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